Bug 459630

Summary: Bindings for keys using xorg Mode_switch do not work
Product: [Frameworks and Libraries] frameworks-kxmlgui Reporter: Emily Ellis <emily>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs-null>
Status: REPORTED ---    
Severity: normal CC: christoph
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: screenshot of garbage produced when binding an unusual key

Description Emily Ellis 2022-09-25 03:58:57 UTC
Created attachment 152400 [details]
screenshot of garbage produced when binding an unusual key

SUMMARY
I have mapped my right alt key to `Mode_switch`, and in the second group it switches to, I have hjkl bound to the arrow keys. These are recognized as arrow keys in every application except Kate and KWrite, including other Qt and KDE applications (I've tried Quassel and Okular). In Kate, Mode_switch + k does nothing.

Additionally, if I try binding new shortcuts to these keys, the binding appears as "[garbage], Up" (as two separate keys, not "[garbage] + Up") and does not do anything when pressed. (Screenshot of garbage attached.)

This appears to be https://bugs.kde.org/show_bug.cgi?id=256653, or at least closely related. That bug was closed in 2013, supposedly not reproducible after moving from Qt 4 to 5.

STEPS TO REPRODUCE
1. $ xkbcomp $DISPLAY keymap.tmp
2. Edit keymap.tmp, e.g.:
@@ -1291,7 +1291,8 @@
     };
     key <AC08> {
         type= "ALPHABETIC",
-        symbols[Group1]= [               k,               K ]
+        symbols[Group1]= [               k,               K ],
+        symbols[Group2]= [              Up,              Up ]
     };
     key <AC09> {
         type= "ALPHABETIC",
@@ -1430,7 +1431,7 @@
         type= "PC_ALT_LEVEL2",
         symbols[Group1]= [           Print,         Sys_Req ]
     };
-    key <RALT> {         [           Alt_R,          Meta_R ] };
+    key <RALT> {         [     Mode_switch ] };
     key <LNFD> {         [        Linefeed ] };
     key <HOME> {         [            Home ] };
     key   <UP> {         [              Up ] };

3. $ xkbcomp keymap.tmp $DISPLAY
4. Try right alt + K in your shell; this should be recognized as the up arrow key.
5. Try right alt + K in a file in Kate; this should move up one line like the up arrow key would, but does not.
6. Settings -> Configure Keyboard Shortcuts; try binding right alt + K to something.

OBSERVED RESULT
The bindings don't work, as described above.

EXPECTED RESULT
They work.

SOFTWARE/OS VERSIONS
Kate 22.08.1
KDE Frameworks 5.98.0
Qt 5.15.6
xorg-server 21.1.4
xkbcomp 1.4.5
All of these are from the Arch Linux packages.

ADDITIONAL INFORMATION
I tried a few other unusual keys, with similar results. Hyper_R and dead_acute do a similar garbled text thing (and dead_acute is ignored for key binding purposes but typing it followed by 'a' does produce รก). F13 works. xev prints the correct key codes for all of these.