Bug 460694 - Pressing Alt-Return (and other key combinations with Alt) enter unexpected characters, too
Summary: Pressing Alt-Return (and other key combinations with Alt) enter unexpected ch...
Status: REPORTED
Alias: None
Product: konsole
Classification: Applications
Component: keyboard (show other bugs)
Version: 22.08.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-19 06:17 UTC by Bodo Eggert
Modified: 2022-12-09 22:49 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bodo Eggert 2022-10-19 06:17:30 UTC
SUMMARY

Pressing Alt-Return (and other key combinations with Alt) enter unexpected characters, too. I tried finding weather the problems is that the programs should expect these characters and ignore them or weather they should not be sent, but by the lack of correct google magic I found no information.

STEPS TO REPRODUCE
1. run hexdump -C (to see the input)
2. Press Alt-Return repeatedly

OBSERVED RESULT

The key generates 18 40 73 1b 0a

EXPECTED RESULT
All programs expect 1b 0a
The extra characters show in the shell or prevent e.g. midnight commander from working properly. 

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20220915
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.5
Kernel Version: 5.19.8-1-default (64-bit)
Graphics Platform: X11
Processors: 4 × Intel® Core™ i5-3320M CPU @ 2.60GHz
Memory: 3.7 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 4000
Manufacturer: Dell Inc.
Product Name: Latitude E6430
System Version: 01

ADDITIONAL INFORMATION

$ echo $TERM
xterm-256color
$ grep meta /etc/inputrc
set meta-flag on
set input-meta on
set output-meta on
set convert-meta off
set enable-meta-key off
Comment 1 ninjalj 2022-12-02 00:43:25 UTC
Per bug #96282 and commit https://invent.kde.org/utilities/konsole/-/commit/5ba344714b8da55dfcc84823abac6f059a288386:

18 40 73 corresponds to the Super Key, which is Qt::MetaModifier, which per https://doc.qt.io/qt-5/qt.html#KeyboardModifier-enum on Windows Keyboards corresponds to the Windows key.

Pressing Alt+Return I get 1B 0A.  Pressing Win+Return I get 18 40 73 0A.  Pressing Win+Alt+Return I get 18 40 73 1B 0A.

What kind of keyboard are you using? Are you using some special keyboard layout? Any customization via xmodmap or similar?
Comment 2 Bodo Eggert 2022-12-09 09:42:46 UTC
TLDR at the bottom, here is some life debugging:

I changed the keys using the KDE menu, German layout, then I did change CAPS to an additional Super.

keycode  21 = apostrophe grave equal plus cedilla cedilla endash
keycode  51 = numbersign acute backslash bar rightsinglequotemark grave U05BB
keycode  78 = dead_greek
keycode  66 = Meta_L

The output of xmodmap is

shift       Shift_L (0x32),  Shift_R (0x3e)
lock      
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_L (0xcc),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3        ISO_Level5_Shift (0xcb)
mod4        Meta_L (0x42),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c)


This should not affect the ALT key but obviously it did. So I NOW added to my .xmodmap:

remove mod1 = Meta_L

which did fix the issue for me but this is not a fix in general. Also I need to run the command every few secons because KDE is fighting to not let me change the keys accordingly.

I just now tested an unconfigured account on OpenSuse Tumbleweed (recently updated) and there is also the same issue with mod1 being both, but it's not confusing konsole.

On the accounts not having the issue, mod4 is only Super_L Hyper_L, NOT Meta_L. There I set the compse key to the Menu key which doesn't exist on my laptop, thete it's AltGr-Ctrl. 

So my educated guess is that both modifiers get merged into one because of that: mod41 = Super_L, Hyper_L, Meta_L ; and any key contained will activate everything.

TLDR:

I map Caps to be Meta_L despite selecting it to be Super (I didn't do that on the other accounts, my script differs)

Alt is mapped to both Alt and Meta (not my doing)

Due to the Win key being Meta Hyper Super, and the Alt key being Alt Meta, Alt also becomes Win.
Comment 3 ninjalj 2022-12-09 22:49:05 UTC
My knowledge of XKB is quite limited. Anyway:

What is the reason for changing CAPS to an additional Super? Is it just to get rid of unwanted CAPS functionality before applying your xmodmap configuration?

Note that capslock(super) (in /usr/share/X11/xkb/symbols/capslock) does:

hidden partial modifier_keys
xkb_symbols "super" {
    key <CAPS> { [ Super_L ] };
    modifier_map Mod4 { <CAPS> };
};

which adds CAPS to mod4 modifier. Instead changing CAPS to e.g. an additional backspace would do:

hidden partial modifier_keys
xkb_symbols "backspace" {
    key <CAPS> { [ BackSpace ] };
};

which doesn't do that.

So, for your use case, it seems that enabling "Make Caps Lock an additional Backspace" instead of "Make Caps Lock an additional Super" would work.

Of course, the "clean" way to do this without xmodmap hackery would be to add an option in /usr/share/X11/xkb/symbols/capslock to make Caps Lock an additional Meta, add it to /usr/share/X11/xkb/rules/evdev and /usr/share/X11/xkb/rules/base (and the corresponding description for GUI programs to use in evdev.xml, evdev.lst, base.xml and base.lst) and maybe send a merge request to https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/