kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.25k stars 976 forks source link

Altgr-intl does not work #3807

Closed noughtmare closed 3 years ago

noughtmare commented 3 years ago

Describe the bug

The altgr-intl keyboard layout does not work in kitty. It does work in other applications like Firefox and even other terminals like alacritty and urxvt.

To Reproduce Steps to reproduce the behavior:

  1. setxkbmap -layout us -variant altgr-intl
  2. press <AltGr><Shift>' (at the same time and the apostrophe last)
  3. press e
  4. See that e is produced instead of ë.

Environment details

kitty 0.20.3 created by Kovid Goyal
Linux nixos-laptop 5.10.40 #1-NixOS SMP Wed May 26 10:06:57 UTC 2021 x86_64
<<< Welcome to NixOS 21.05.876.60cce7e5e1f (\m) - \l >>>

Run 'nixos-help' for the NixOS manual.
Loaded config files: /home/user/.config/kitty/kitty.conf
Running under: X11

Config options different from defaults:
background           Color(red=253, green=246, blue=227)
bold_font            JetBrains Mono Bold
bold_italic_font     JetBrains Mono Bold Italic
color0               Color(red=7, green=54, blue=66)
color1               Color(red=220, green=50, blue=47)
color10              Color(red=88, green=110, blue=117)
color11              Color(red=101, green=123, blue=131)
color12              Color(red=131, green=148, blue=150)
color13              Color(red=108, green=113, blue=196)
color14              Color(red=147, green=161, blue=161)
color15              Color(red=253, green=246, blue=227)
color2               Color(red=133, green=153, blue=0)
color3               Color(red=181, green=137, blue=0)
color4               Color(red=38, green=139, blue=210)
color5               Color(red=211, green=54, blue=130)
color6               Color(red=42, green=161, blue=152)
color7               Color(red=238, green=232, blue=213)
color8               Color(red=0, green=43, blue=54)
color9               Color(red=203, green=75, blue=22)
editor               vim
enable_audio_bell    False
font_family          JetBrains Mono Regular
foreground           Color(red=88, green=110, blue=117)
italic_font          JetBrains Mono Italic
window_alert_on_bell False

Additional context

I can reproduce it with kitty --config NONE.

trygveaa commented 3 years ago

I can't reproduce. I'm using US altgr-intl and pressing altgr-shift-' and then e produces ë for me (btw altgr-r is an easier way to type this character on this layout).

I'm using version 0.21.2. I didn't test 0.20.3 now, but when I was using this version earlier at least the non-ascii characters I'm regularly using (æ, ø and å) was working fine.

kovidgoyal commented 3 years ago

I cannot reproduce either with those steps, ë is produced as expected, X11, kitty from master.

You can see the detailed keyboard handling debug log with --debug-input

noughtmare commented 3 years ago

Altgr-r does work for me. This is the output with --debug-input:

$ kitty --debug-input
Loading new XKB keymaps
Modifier indices alt: 0x3 super: 0x6 hyper: 0xffffffff meta: 0xffffffff numlock: 0x4 shift: 0x0 capslock: 0x1
Press xkb_keycode: 0x6c clean_sym: ISO_Level3_Shift composed_sym: ISO_Level3_Shift mods: numlock glfw_key: 57453 (ISO_LEVEL3_SHIFT) xkb_key: 65027 (ISO_Level3_Shift) alternate_key: 57449 (RIGHT_ALT)
on_key_input: glfw key: 0xe06d native_code: 0xfe03 action: PRESS mods: numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x32 clean_sym: Shift_L composed_sym: Shift_L active_unknown_mods: Mod5 mods: numlock glfw_key: 57441 (LEFT_SHIFT) xkb_key: 65505 (Shift_L)
on_key_input: glfw key: 0xe061 native_code: 0xffe1 action: PRESS mods: numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Got XkbNewKeyboardNotify event with changes: key codes: 1 geometry: 1 device id: 0
Loading new XKB keymaps
Modifier indices alt: 0x3 super: 0x6 hyper: 0xffffffff meta: 0xffffffff numlock: 0x4 shift: 0x0 capslock: 0x1
Press xkb_keycode: 0x30 clean_sym: apostrophe compose not complete, ignoring.
Release xkb_keycode: 0x30 clean_sym: apostrophe mods: shift+numlock glfw_key: 39 (') xkb_key: 39 (apostrophe)
Got XkbNewKeyboardNotify event with changes: key codes: 1 geometry: 1 device id: 0
Loading new XKB keymaps
Modifier indices alt: 0x3 super: 0x6 hyper: 0xffffffff meta: 0xffffffff numlock: 0x4 shift: 0x0 capslock: 0x1
Release xkb_keycode: 0x6c clean_sym: ISO_Level3_Shift mods: numlock glfw_key: 57453 (ISO_LEVEL3_SHIFT) xkb_key: 65027 (ISO_Level3_Shift) alternate_key: 57449 (RIGHT_ALT)
on_key_input: glfw key: 0xe06d native_code: 0xfe03 action: RELEASE mods: numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Release xkb_keycode: 0x32 clean_sym: Shift_L mods: shift+numlock glfw_key: 57441 (LEFT_SHIFT) xkb_key: 65505 (Shift_L)
on_key_input: glfw key: 0xe061 native_code: 0xffe1 action: RELEASE mods: shift+numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x1a clean_sym: e composed_sym: e text: e mods: numlock glfw_key: 101 (e) xkb_key: 101 (e)
on_key_input: glfw key: 0x65 native_code: 0x65 action: PRESS mods: numlock text: 'e' state: 0 sent text to child
Release xkb_keycode: 0x1a clean_sym: e mods: numlock glfw_key: 101 (e) xkb_key: 101 (e)
on_key_input: glfw key: 0x65 native_code: 0x65 action: RELEASE mods: numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Got XkbNewKeyboardNotify event with changes: key codes: 1 geometry: 1 device id: 0
Loading new XKB keymaps
Modifier indices alt: 0x3 super: 0x6 hyper: 0xffffffff meta: 0xffffffff numlock: 0x4 shift: 0x0 capslock: 0x1
Press xkb_keycode: 0x16 clean_sym: BackSpace composed_sym: BackSpace mods: numlock glfw_key: 57347 (BACKSPACE) xkb_key: 65288 (BackSpace)
on_key_input: glfw key: 0xe003 native_code: 0xff08 action: PRESS mods: numlock text: '' state: 0 sent key to child
Release xkb_keycode: 0x16 clean_sym: BackSpace mods: numlock glfw_key: 57347 (BACKSPACE) xkb_key: 65288 (BackSpace)
on_key_input: glfw key: 0xe003 native_code: 0xff08 action: RELEASE mods: numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Got XkbNewKeyboardNotify event with changes: key codes: 1 geometry: 1 device id: 0
Loading new XKB keymaps
Modifier indices alt: 0x3 super: 0x6 hyper: 0xffffffff meta: 0xffffffff numlock: 0x4 shift: 0x0 capslock: 0x1
Press xkb_keycode: 0x25 clean_sym: Control_L composed_sym: Control_L mods: ctrl+numlock glfw_key: 57442 (LEFT_CONTROL) xkb_key: 65507 (Control_L)
on_key_input: glfw key: 0xe062 native_code: 0xffe3 action: PRESS mods: ctrl+numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x28 clean_sym: d composed_sym: d mods: ctrl+numlock glfw_key: 100 (d) xkb_key: 100 (d)
on_key_input: glfw key: 0x64 native_code: 0x64 action: PRESS mods: ctrl+numlock text: '' state: 0 sent key to child

That is with a backspace and ctrl-d at the end. Does that look normal?

Edit: this is with:

$ kitty --version
kitty 0.21.2 created by Kovid Goyal

Edit2: this is the output of xev with the same keystrokes:

KeyPress event, serial 33, synthetic NO, window 0x6200001,
    root 0x23d, subw 0x0, time 20419383, (1267,271), root:(1268,299),
    state 0x10, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 92
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 33, synthetic NO, window 0x6200001,
    root 0x23d, subw 0x0, time 20421336, (1267,271), root:(1268,299),
    state 0x90, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

MappingNotify event, serial 33, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 33, synthetic NO, window 0x6200001,
    root 0x23d, subw 0x0, time 20424315, (1267,271), root:(1268,299),
    state 0x91, keycode 48 (keysym 0xfe57, dead_diaeresis), same_screen YES,
    XLookupString gives 2 bytes: (c2 a8) "¨"
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: True
noughtmare commented 3 years ago

I also just noticed that this only happens on my external keyboard, not on the keyboard that is built-in to my laptop.

noughtmare commented 3 years ago

I now also found out that the XkbNewKeyboardNotify request is not sent when I try this on my internal laptop keyboard, so I think that that is the issue. For my external keyboard the altgr-intl shortcuts do not work properly when an XkbNewKeyboardNotify code is sent in the middle of them. I can now also reproduce it as follows:

  1. setxkbmap -layout us -variant altgr-intl
  2. press <AltGr><Shift>' (at the same time and the apostrophe last)
  3. plug in second keyboard
  4. press e on the second keyboard
  5. observe that e is produced and not ë.

I admit that this is a strange use-case but it seems to be that my external keyboard is actually automatically doing something like this. Other applications can deal with this properly. So, @kovidgoyal can you please consider reopening this?

Edit: another reproducer for if you have only one keyboard:

  1. setxkbmap -layout us -variant altgr-intl
  2. press <AltGr><Shift>' (at the same time and the apostrophe last)
  3. unplug keyboard
  4. plug keyboard back in
  5. press e
  6. observe that e is produced and not ë.
kovidgoyal commented 3 years ago

dup of #2787