On Thu Apr 9 16:19:01 2026 +0000, Matteo Bruni wrote:
This brings up the "not noticing the layout switch until the next keypress" problem though. I don't know how important it is but it might be a point in favor of listening to Xkb events when available. This seems to be a GNOME specific problem, possibly their bug, and maybe we don't have to worry about it for now. That was with KDE though. As I understand it it's more a matter of what layouts end up in the same keymap and whether you happen to switch between layouts represented by the same keymap or not. I.e., with `pc+us+ru:2+inet(evdev)` I can switch between "us" and "ru" freely without ever triggering a MappingNotify, then a switch to "it" will cause MappingNotify to be sent and the keymap to become `pc+us+it:2+inet(evdev)`. At that point I can instead flip between "it" and "us" without any MappingNotify. Also, I'm not sure that using Xkb events would make any difference, have you checked that it does? Yeah, XkbStateNotify is called immediately every time the layout changes but the underlying keymap doesn't (i.e. it's just an Xkb group switch), while XkbNewKeyboardNotify is triggered when the keymap does change. Both seem to work consistently on Gnome X11 and Xwayland, KDE X11. Just to add another data point: KDE Xwayland seems to only allow switching among the first 4 defined layouts and it does so by changing the Xkb group while keeping the same keymap (thus generating a XkbStateNotify event each time). The output of setxkbmap isn't very interesting:
$ setxkbmap -print
WARNING: Running setxkbmap against an Xwayland server
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us+inet(evdev)" };
xkb_geometry { include "pc(pc105)" };
};
but nonetheless, the Xkb group names have the info we need: ``` 2579.220:0020:0024:trace:keyboard:init_xkb_layouts Found 4 valid group names 2579.220:0020:0024:trace:keyboard:init_xkb_layouts Layout 0 name English (US) 2579.220:0020:0024:trace:keyboard:init_xkb_layouts Layout 1 name Italian 2579.220:0020:0024:trace:keyboard:init_xkb_layouts Layout 2 name Russian 2579.220:0020:0024:trace:keyboard:init_xkb_layouts Layout 3 name Japanese ``` -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10550#note_135729