KeyRelease for Alt key broken after adding keyboard layout
Submitted by Raphaël Quinet
Assigned to xkb..@..bat.ru
Description
This is a copy of a bug that I originally reported against gnome-keyboard-properties, but I was told to report it here instead: http://bugzilla.gnome.org/show_bug.cgi?id=346029 Sorry for taking so long to repost it here.
Short summary:
- Adding a new keyboard layout in the Keyboard Preferences (g-k-properties) automatically activates the option "Both Alt keys together change group" without notifying the user.
- An unwanted side-effect of this option is that it breaks the "Alt" keys. The KeyPress events are sent correctly, but the KeyRelease events for Alt are mapped to the wrong key. As a result, many applications do not detect that Alt has been released.
Similar problems occur if the options "Both Shift..." or "Both Ctrl keys together..." are selected. However, these options have to be activated explicitely so they are probably not affecting many users.
System information:
- Laptop (HP/Compaq nc8000) running current Debian testing ("etch")
- GNOME 2.14.2
- X.Org 7.0
- The problem occurs with the built-in keyboard (US layout) as well as any external keyboard.
- Keyboard model in g-k-p: Generic 104-key PC.
- Selected layouts in g-k-p: U.S. English, Belgium, Sweden.
Steps to reproduce:
- If possible, start with a new user account or a clean session.
- Run "xev" or a similar X event monitoring application and verify that pressing and releasing the left Alt key generates KeyPress and KeyRelease events associated with the Alt_L key.
- In "Layout Options", "Group Shift/Lock behavior", check the option "Both Alt keys together change group" (this is activated automatically after adding a new keyboard layout).
- Run "xev" again and see that KeyPress still reports the Alt_L key, but KeyRelease reports another key (in my case, ISO_Prev_Group).
- This affects several applications that will be unable to detect that Alt has been released: GIMP (http://bugzilla.gnome.org/show_bug.cgi?id=345726), Inkscape, ...
Aggravating factor: the option "Both Alt keys together..." is silently activated automatically after adding a second keyboard layout. Removing the additional keyboard layout(s) does not solve the issue because the option is not unchecked.
It was very difficult for me to find the source of this problem because I never looked at the "Layout Options" tab after adding the second and third keyboard layouts and I did not see (for several weeks) that some option had changed there. When I tried to track down this problem, I saw that the bug was still there even after removing the additional keyboard layouts (and thinking incorrectly that I went back to the original state), so I wasted some hours investigating other potential sources for this problem. I am glad that I eventually found it by creating new user accounts, adding panel applets and changing options until the bug appeared again for these clean accounts.
Here is some additional details about what I get WITHOUT the option "Both Alt keys together change group":
xmodmap -pke | grep Alt keycode 64 = Alt_L Meta_L keycode 113 = Alt_R Meta_R ISO_Level3_Shift NoSymbol ISO_Level3_Shift keycode 125 = NoSymbol Alt_L
xev [pressing and releasing Alt] KeyPress event, serial 29, synthetic NO, window 0x2e00001, root 0x76, subw 0x0, time 365926274, (162,59), root:(171,454), state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False
KeyRelease event, serial 29, synthetic NO, window 0x2e00001, root 0x76, subw 0x0, time 365926863, (162,59), root:(171,454), state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES, XLookupString gives 0 bytes:
And here is what I get later, WITH the option activated:
xmodmap -pke | grep Alt keycode 64 = Alt_L ISO_Prev_Group ISO_Prev_Group NoSymbol ISO_Prev_Group keycode 125 = NoSymbol Alt_L
xev KeyPress event, serial 29, synthetic NO, window 0x2e00001, root 0x76, subw 0x0, time 366201299, (162,54), root:(171,449), state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False
KeyRelease event, serial 29, synthetic NO, window 0x2e00001, root 0x76, subw 0x0, time 366201775, (162,54), root:(171,449), state 0x8, keycode 64 (keysym 0xfe0a, ISO_Prev_Group), same_screen YES, XLookupString gives 0 bytes:
Note that this also breaks the right Alt key, but fortunately I am not using it as much as the left Alt key.