GNOME Bugzilla – Bug 678001
Keybindings are keyboard-layout-dependent
Last modified: 2014-09-02 08:43:47 UTC
Keybindings saved in English keyboard layout (e.g. Ctrl+Alt+L) do not work when Russian keyboard layout is activated. Other keybindings (such as mutter keybindings or Ctrl+C/Ctrl+V in text entries) work independent of active keyboard layout. The core issue seems to be that function match_xi2_key() function tries to convert keycode to keysym and compare keysyms, rather than simply compare keycodes.
FWIW, the bug is still present in GNOME 3.5.91 (tested via LiveCD).
*** Bug 687502 has been marked as a duplicate of this bug. ***
Created attachment 228204 [details] [review] keygrab: Also match on other group indexes for the keycode -- I'm not really proposing this patch although it works. It's just to clearly point out the bug. The problem is indeed that gsd-keygrab.c tries really hard to match only the specific keysym with the modifiers configured. I'd need to know more about the story of this code to understand why it does it this way. Bastien, do you know? mutter/metacity only consider the keycode and thus, triggers a keybinding on say <ctrl><alt>k the same way it does on <ctrl><alt>л . Finally, since fallback mode is going away and all global keybindings are going to move into mutter/gnome-shell I'm not sure it's worth it to try to fix gsd-keygrab.c properly.
*** Bug 652359 has been marked as a duplicate of this bug. ***
*** Bug 689268 has been marked as a duplicate of this bug. ***
Reassigning to gnome-shell, that's where key capture is done now.
It turns out that my comment 3 above isn't completely right. mutter does check keysym in some cases but not all. It's basically up to the handler function and most of the builtin handlers don't check it at all like e.g. handle_toggle_fullscreen() . Only handlers that call into display_get_keybinding() check the keysym, but I don't see how anything would break if we just stop doing it.
Created attachment 238149 [details] [review] keybindings: Don't use the keysym to match keybindings We explicitly don't match the keysym so that e.g. an accelerator specified as "<Super>l" works if the current XKB layout has a different keysym for that keycode like д or م .
Here's what Owen said on IRC: 21:10 <@rtcm> owen: what do you think of just not checking the keysym when matching keybindings? 21:21 <@fmuellner> rtcm: oh, interesting - history suggests that matching was originally done only on keysym 21:21 < owen> rtcm: it's a complicated subject, to put it mildly 21:24 < owen> rtcm: Most of the default key bindings in Mutter, and for the desktop are on non-alphabetic keys 21:24 < owen> With some exceptions like Super-M to toggle the message tray 21:26 < owen> Once you start having bindings that are on punctuation, digits, etc, you can certainly get the case where two bindings conflict on the same key and you need to look at keysym to distinguish the pair 21:27 < owen> but on the other hand (and this is presumably where it came u) - purely looking at looking at keysym gets you into troble with multiple keyboard groups 21:27 < owen> since Super-M should toggle the message tray even when you are in Cyrillic mode 21:27 < owen> In GTK+, we have GtkKeyHash to handle fuzzy matching and resolve the tension. 21:30 < owen> My general idea was that if we made mutter handle all the keybindings rather than splitting them with g-s-d we might be able to use or c-n-p the GtkKeyHash code, but that's ambitious. So maybe just matching on keycode is a fine approximation. Expect *something* to break for *someone*, but the breakage is hopefully less than the fixage Looking at the default keybindings we have right now on org.gnome.desktop.wm.keybindings org.gnome.settings-daemon.plugins.media-keys org.gnome.mutter.keybindings org.gnome.shell.keybindings it seems that we have 2 using punctuation keys: magnifier-zoom-in: <Alt><Super>equal magnifier-zoom-out: <Alt><Super>minus (not counting Above_Tab since that's handled fine with the patch here) and 6 using alphabetic keys: screensaver: <Ctrl><Alt>l (shouldn't this be changed to use Super?) toggle-application-view: <Super>a toggle-message-tray: <Super>m focus-active-notification: <Super>n toggle-recording: <Ctrl><Alt><Shift>r minimize: <Super>h which leads me to think that this patch would be a net win given that those 6 alphabetic shortcuts don't work at all when using a non-latin layout and the magnifier shortcuts still work with it.
Any chance this bug will be fixed in 3.10?
*** Bug 712669 has been marked as a duplicate of this bug. ***
I post here my comment from 712669. It's below. In my GNU/Linux system a have always two keyboard layouts - English and Russian. In previous versions of GNOME (for example, in GNOME 3.4 of Ubuntu 12.04.3) I was able to use shortcuts on both layouts. For example, if I have defined Ctrl+Alt+T (T is english capital T) for launching terminal it launches if I press Ctrl+Alt+T on english layout or if I press Ctrl+Alt+Е (Е is russian Е) on russian layout. In newer versions of GNOME I can't do it. Terminal does not launch on russian layout. Problem exists in Ubuntu 13.10 (see https://bugs.launchpad.net/bugs/1226962), AltLinux p7 (GNOME 3.8) and may be other distros. So, please fix this bug.
I tested Ctrl+Alt+T in other DEs with English and Russian layouts in OpenSuse 13.1. This shortcut works normally in: 1. KDE SC 4.11.2 2. Enlightment 0.17.3 3. KDE 3.5.10 "release 76" So it seems, that you, GNOME guys are doing something wrong. And it is very annoying. There are many multi-layout users. You make their life harder. Thank you very much, guys!
Please, fix his finally, why you hurt so many people with such stupid "features"? This is VERY CRITICAL bug!
Created attachment 270508 [details] [review] keybindings: Don't use the keysym to match keybindings -- Ok, this is the patch for the wayland branch. Interestingly, on this branch we were matching on the keysym even for mutter's own keybindings and not only external ones. I suppose that was a thinko in the conversion to clutter events.
Created attachment 270509 [details] [review] keybindings: Don't use the keysym to match keybindings -- And this is the patch for the master branch.
Comment on attachment 270508 [details] [review] keybindings: Don't use the keysym to match keybindings Pushing with an expanded rationale. Attachment 270508 [details] pushed as 28859c6 - keybindings: Don't use the keysym to match keybindings
Attachment 270509 [details] pushed as 2bf844d - keybindings: Don't use the keysym to match keybindings
Thank you!
Thanks you Rui Matos!
*** Bug 735811 has been marked as a duplicate of this bug. ***