Bug 444012 - GTK apps do not respect keyboard layout on wayland session
Summary: GTK apps do not respect keyboard layout on wayland session
Status: RESOLVED WORKSFORME
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_keyboard (show other bugs)
Version: 5.23.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
: 444122 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-10-19 02:55 UTC by Mikel Pérez
Modified: 2024-01-11 07:55 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikel Pérez 2021-10-19 02:55:32 UTC
SUMMARY
annoyingly GTK apps do not respect whichever keyboard layout is set when on the wayland session

STEPS TO REPRODUCE
1. set a keyboard layout different from US
2. open a GTK app like Chrome

OBSERVED RESULT
stays on US layout

EXPECTED RESULT
uses selected layout

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora 34
KDE Plasma Version: 5.23.0
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
my default is Spanish and it does not respect that so I don't think it uses your default and not changes when you switch but rather always uses US layout
Comment 1 Mikel Pérez 2021-10-19 16:06:52 UTC
this happens when the ibus tray icon is present. right now it is and these process are running:

mikel     654866  0.3  0.0 536888 13380 ?        Sl   11:03   0:00 /usr/bin/ibus-daemon -r --xim
mikel     654900  0.0  0.0 449480  7536 ?        Sl   11:03   0:00 /usr/libexec/ibus-dconf
mikel     654901  1.0  0.3 3536140 106860 ?      Sl   11:03   0:01 /usr/libexec/ibus-ui-gtk3
mikel     654908  1.8  0.1 579544 46240 ?        Sl   11:03   0:01 /usr/libexec/ibus-extension-gtk3
mikel     654910  0.1  0.1 2166532 62152 ?       Sl   11:03   0:00 /usr/libexec/ibus-x11 --kill-daemon
mikel     654919  0.0  0.0 449176  6728 ?        Ssl  11:03   0:00 /usr/libexec/ibus-portal
mikel     655104  0.0  0.0 375416  7448 ?        Sl   11:03   0:00 /usr/libexec/ibus-engine-simple
mikel     709968  0.0  0.0 221532   860 pts/2    S+   11:05   0:00 grep --color=auto ibus

sometimes it does not autostart and doesn't happen and gtk apps follow KDE keyboard layout
Comment 2 Andrey 2021-10-20 15:25:35 UTC
IIRC that was considered as packaging issue so that ibus is pulled as dependency and started by default.
Comment 3 Victor Sanchez 2021-10-20 15:50:27 UTC
Are you running Wayland? What I find is that the keyboard layout is not set correctly for the XWayland session. In my case, I have defined the "latam" keyboard in the configuration but Xwayland is receiving the "es" (Spanish) layout.

Typing:

setxbmap latam 

"fixes" the situation but it needs to be done everytime.
Comment 4 Mikel Pérez 2021-10-20 15:56:40 UTC
(In reply to Victor Sanchez from comment #3)
> Are you running Wayland? What I find is that the keyboard layout is not set
> correctly for the XWayland session. In my case, I have defined the "latam"
> keyboard in the configuration but Xwayland is receiving the "es" (Spanish)
> layout.
> 
> Typing:
> 
> setxbmap latam 
> 
> "fixes" the situation but it needs to be done everytime.

Yes I am. Doesn't happen on the X11 session
Comment 5 Nate Graham 2021-10-21 16:45:27 UTC
*** Bug 444122 has been marked as a duplicate of this bug. ***
Comment 6 Naoto Kondo 2022-07-21 15:15:25 UTC
I had the same problem, but solved it to a limited extent.
kwin send keymap change callback to gtk application. At that time keymap is created with KConfigGroup variable.

> const QByteArray model = m_configGroup.readEntry("Model", "pc104").toLatin1();
> const QByteArray layout = m_configGroup.readEntry("LayoutList").toLatin1();
> const QByteArray variant = m_configGroup.readEntry("VariantList").toLatin1();
> const QByteArray options = m_configGroup.readEntry("Options").toLatin1();
> 
> xkb_rule_names ruleNames = {
>      .rules = nullptr,
>      .model = model.constData(),
>      .layout = layout.constData(),
>      .variant = variant.constData(),
>      .options = nullptr,
> };

So, SytemSettings > Input Device > Keyboard > Layout > Layout Settings of top item is respected.
But this settings is cleared at system reboot :(
Comment 7 Naoto Kondo 2022-07-21 15:34:59 UTC
It is curiously that this problem doesn't occur in qt applications, but I think it is solved by the input method through the platforminputcontexts plugin.
Comment 8 Mikel Pérez 2024-01-11 07:55:27 UTC
(In reply to Victor Sanchez from comment #3)
> Are you running Wayland? What I find is that the keyboard layout is not set
> correctly for the XWayland session. [...]

(In reply to Nate Graham from comment #5)
> *** Bug 444122 has been marked as a duplicate of this bug. ***

I think I may have originally missed the XWayland or was very vague just replying that yes I was running Wayland and that it didn't happen on the X11 session, sorry about that I can't remember lol.
Anyways, this isn't happening to me anymore and I've also tried with GDK_BACKEND=x11 so it isn't broken on XWayland either. I don't know what fixed this nor when so I'm going to close it as RESOLVED WORKSFORME.