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

Ubuntu 22.04 non-latin layout not work with ctrl+shift kitty_mod #6549

Closed thedrint closed 1 year ago

thedrint commented 1 year ago

Describe the bug When i press Ctrl+Shift+Й (it's C-s-q in russian layout) - Kitty doesn't close tab, but sends sequence of symbols.

To Reproduce Steps to reproduce the behavior:

  1. Run simple test kitty --debug-input --config /dev/null
  2. Press Ctrl+Shift+q in opened kitty window -- it would closes
  3. Re-run test but with non-latin layout enabled (russian for example)
  4. Press same combination (Ctrl-Shift-q) in non-latin layout - kitty wouldn't closes but sends in terminal something like 81;6u

Screenshots English layout while run test

~$ kitty --debug-input --config /dev/null
Loading new XKB keymaps
Modifier indices alt: 0x3 super: 0x6 hyper: 0xffffffff meta: 0xffffffff numlock: 0x4 shift: 0x0 capslock: 0x1
Move x: 31,0 y: 339,0 grabbed: 0
on_focus_change: window id: 0x1 focused: 1
ignoreboth or ignorespace present in bash HISTCONTROL setting, showing running command in window title will not be robust
Press xkb_keycode: 0x25 clean_sym: Control_L composed_sym: Control_L mods: numlock glfw_key: 57442 (LEFT_CONTROL) xkb_key: 65507 (Control_L)
on_key_input: glfw key: 0xe062 native_code: 0xffe3 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 mods: ctrl+numlock glfw_key: 57441 (LEFT_SHIFT) xkb_key: 65505 (Shift_L)
on_key_input: glfw key: 0xe061 native_code: 0xffe1 action: PRESS mods: ctrl+numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x18 clean_sym: q composed_sym: Q mods: ctrl+shift+numlock glfw_key: 113 (q) xkb_key: 113 (q) shifted_key: 81 (Q)
on_key_input: glfw key: 0x71 native_code: 0x71 action: PRESS mods: ctrl+shift+numlock text: '' state: 0 
KeyPress matched action: close_tab
handled as shortcut

Then russian layout:

~$ kitty --debug-input --config /dev/null
Loading new XKB keymaps
Modifier indices alt: 0x3 super: 0x6 hyper: 0xffffffff meta: 0xffffffff numlock: 0x4 shift: 0x0 capslock: 0x1
Move x: 31,0 y: 339,0 grabbed: 0
on_focus_change: window id: 0x1 focused: 1
ignoreboth or ignorespace present in bash HISTCONTROL setting, showing running command in window title will not be robust
Press xkb_keycode: 0x25 clean_sym: Control_L composed_sym: Control_L mods: numlock glfw_key: 57442 (LEFT_CONTROL) xkb_key: 65507 (Control_L)
on_key_input: glfw key: 0xe062 native_code: 0xffe3 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 mods: ctrl+numlock glfw_key: 57441 (LEFT_SHIFT) xkb_key: 65505 (Shift_L)
on_key_input: glfw key: 0xe061 native_code: 0xffe1 action: PRESS mods: ctrl+numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x18 clean_sym: Cyrillic_shorti composed_sym: Cyrillic_SHORTI mods: ctrl+shift+numlock glfw_key: 1081 (й) xkb_key: 1738 (Cyrillic_shorti) shifted_key: 1049 (Й) alternate_key: 113 (q�)
on_key_input: glfw key: 0x439 native_code: 0x6ca action: PRESS mods: ctrl+shift+numlock text: '' state: 0 sent encoded key to child: ^[ [ 1 0 8 1 ; 6 u 
Release xkb_keycode: 0x18 clean_sym: Cyrillic_shorti mods: ctrl+shift+numlock glfw_key: 1081 (й) xkb_key: 1738 (Cyrillic_shorti) shifted_key: 1049 (Й) alternate_key: 113 (q�)
on_key_input: glfw key: 0x439 native_code: 0x6ca action: RELEASE mods: ctrl+shift+numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Release xkb_keycode: 0x32 clean_sym: Shift_L mods: ctrl+shift+numlock glfw_key: 57441 (LEFT_SHIFT) xkb_key: 65505 (Shift_L)
on_key_input: glfw key: 0xe061 native_code: 0xffe1 action: RELEASE mods: ctrl+shift+numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Release xkb_keycode: 0x25 clean_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: RELEASE mods: ctrl+numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x40 clean_sym: Alt_L composed_sym: Alt_L mods: numlock glfw_key: 57443 (LEFT_ALT) xkb_key: 65513 (Alt_L)
on_key_input: glfw key: 0xe063 native_code: 0xffe9 action: PRESS mods: numlock text: '' state: 0 ignoring as keyboard mode does not support encoding this event

Last two strings - I closed kitty window with Alt+F4 Environment details

kitty 0.29.2 (95316fc2dc) created by Kovid Goyal
Linux user 5.15.0-78-generic #85-Ubuntu SMP Fri Jul 7 15:25:09 UTC 2023 x86_64
Ubuntu 22.04.3 LTS user /dev/tty

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
Running under: X11
Frozen: True
Paths:
  kitty: /home/user/.local/kitty.app/bin/kitty
  base dir: /home/user/.local/kitty.app/lib/kitty
  extensions dir: /home/user/.local/kitty.app/lib/kitty-extensions
  system shell: /bin/bash
Loaded config files:
  /dev/null

Config options different from defaults:

Important environment variables seen by the kitty process:
    PATH                                /home/user/.cargo/bin:/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/user/.npm/packages/bin:/home/user/.local/bin:/home/user/go/bin
    LANG                                ru_RU.UTF-8
    VISUAL                              /usr/bin/micro
    EDITOR                              /usr/bin/micro
    SHELL                               /bin/bash
    DISPLAY                             :0
    USER                                user
    XDG_CONFIG_DIRS                     /etc/xdg/xdg-ubuntu-xorg:/etc/xdg
    XDG_MENU_PREFIX                     gnome-
    LC_ADDRESS                          ru_RU.UTF-8
    LC_NAME                             ru_RU.UTF-8
    LC_MONETARY                         ru_RU.UTF-8
    XDG_SESSION_DESKTOP                 ubuntu-xorg
    XDG_SESSION_TYPE                    x11
    LC_PAPER                            ru_RU.UTF-8
    XDG_CURRENT_DESKTOP                 ubuntu:GNOME
    XDG_SESSION_CLASS                   user
    LC_IDENTIFICATION                   ru_RU.UTF-8
    LC_TELEPHONE                        ru_RU.UTF-8
    LC_MEASUREMENT                      ru_RU.UTF-8
    XDG_RUNTIME_DIR                     /run/user/1000
    LC_TIME                             ru_RU.UTF-8
    XDG_DATA_DIRS                       /usr/share/ubuntu-xorg:/usr/share/gnome:/home/user/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
    LC_NUMERIC                          ru_RU.UTF-8

Additional context I've using CAPSLOCK as layout switcher.

kovidgoyal commented 1 year ago

Well, yes, you are not pressing ctrl+shift+q you are pressing ctrl+shift+Й

If you want this key press to quit kitty add the appropriate mapping to kitty.conf

map ctrl+shift+Й whatever

kitty only matches shortcuts based on what the key means in the current keyboard layout.

thedrint commented 1 year ago
map kitty_mod+q close_tab
map kitty_mod+й close_tab

Thank you for advice, it really works when i duplicate in kitty conf mappings with non-latin letters:

Well, yes, you are not pressing ctrl+shift+q you are pressing ctrl+shift+Й

If you want this key press to quit kitty add the appropriate mapping to kitty.conf

map ctrl+shift+Й whatever

kitty only matches shortcuts based on what the key means in the current keyboard layout.

Is there any hack/rule/option/setting to avoid kitty receive those long sequences like 81;6u when pressing combo with non-latin keys? Or I must to add all possible map variants to kitty.conf with no_op?

kovidgoyal commented 1 year ago

No I'm afraid there is no hack for it. You would need to map any problematic key preses to no-op in kitty.conf individually.

Jakeroid commented 8 months ago

Here is mine solution. Actually, the idea is the same to map each shortcut for the non-Latin character, but I made automated script to do that.

https://jakeroid.com/blog/kitty-shortcuts-work-only-with-latin-characters-how-to-fix