After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 678001 - Keybindings are keyboard-layout-dependent
Keybindings are keyboard-layout-dependent
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
: 652359 687502 689268 712669 735811 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-06-13 11:08 UTC by Oleg Andreev
Modified: 2014-09-02 08:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
keygrab: Also match on other group indexes for the keycode (3.54 KB, patch)
2012-11-06 01:06 UTC, Rui Matos
none Details | Review
keybindings: Don't use the keysym to match keybindings (3.31 KB, patch)
2013-03-05 17:44 UTC, Rui Matos
none Details | Review
keybindings: Don't use the keysym to match keybindings (3.49 KB, patch)
2014-02-27 20:05 UTC, Rui Matos
committed Details | Review
keybindings: Don't use the keysym to match keybindings (3.00 KB, patch)
2014-02-27 20:06 UTC, Rui Matos
committed Details | Review

Description Oleg Andreev 2012-06-13 11:08:02 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.
Comment 1 Oleg Andreev 2012-09-15 07:13:48 UTC
FWIW, the bug is still present in GNOME 3.5.91 (tested via LiveCD).
Comment 2 Rui Matos 2012-11-06 00:54:42 UTC
*** Bug 687502 has been marked as a duplicate of this bug. ***
Comment 3 Rui Matos 2012-11-06 01:06:22 UTC
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.
Comment 4 Rui Matos 2012-11-06 01:25:07 UTC
*** Bug 652359 has been marked as a duplicate of this bug. ***
Comment 5 Rui Matos 2012-11-29 12:40:54 UTC
*** Bug 689268 has been marked as a duplicate of this bug. ***
Comment 6 Bastien Nocera 2013-03-05 13:33:22 UTC
Reassigning to gnome-shell, that's where key capture is done now.
Comment 7 Rui Matos 2013-03-05 17:41:40 UTC
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.
Comment 8 Rui Matos 2013-03-05 17:44:01 UTC
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 م .
Comment 9 Rui Matos 2013-03-06 21:51:45 UTC
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.
Comment 10 Anton Sudak 2013-08-23 11:06:08 UTC
Any chance this bug will be fixed in 3.10?
Comment 11 Rui Matos 2013-11-19 13:28:22 UTC
*** Bug 712669 has been marked as a duplicate of this bug. ***
Comment 12 Nrbrtx 2013-11-21 07:49:04 UTC
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.
Comment 13 Nrbrtx 2013-11-21 08:24:53 UTC
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!
Comment 14 Nazar Mokrynskyi 2014-01-30 02:25:08 UTC
Please, fix his finally, why you hurt so many people with such stupid "features"?
This is VERY CRITICAL bug!
Comment 15 Rui Matos 2014-02-27 20:05:58 UTC
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.
Comment 16 Rui Matos 2014-02-27 20:06:40 UTC
Created attachment 270509 [details] [review]
keybindings: Don't use the keysym to match keybindings

--

And this is the patch for the master branch.
Comment 17 Rui Matos 2014-02-27 20:41:12 UTC
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
Comment 18 Rui Matos 2014-02-27 20:42:55 UTC
Attachment 270509 [details] pushed as 2bf844d - keybindings: Don't use the keysym to match keybindings
Comment 19 Oleg Andreev 2014-02-27 20:49:13 UTC
Thank you!
Comment 20 Yosef Or Boczko 2014-02-27 20:51:43 UTC
Thanks you Rui Matos!
Comment 21 Rui Matos 2014-09-02 08:43:47 UTC
*** Bug 735811 has been marked as a duplicate of this bug. ***