Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl key registered, but not working. #2787

Closed
Linouth opened this issue Jun 23, 2020 · 7 comments
Closed

Ctrl key registered, but not working. #2787

Linouth opened this issue Jun 23, 2020 · 7 comments
Labels

Comments

@Linouth
Copy link

Linouth commented Jun 23, 2020

I have been using kitty on my laptop for quite some time now and it is great! But I just installed it on my desktop and here the control key does not seem to work correctly. Key combinations such as Ctrl-C, Ctrl-L, Ctrl-D in vim or kitty commands such as Ctrl-Shift-C do not work at all.
Both machines are running the exact same WM (i3) with the same zsh and kitty configs, but it also happens with --config NONE. All Ctrl-key combinations work just fine on alacritty and xterm.

Enviroment details
OS: Arch Linux
WM: i3

Video of the issue
https://siasky.net/_Ai03spdNenFsVBQkQUrm_ObhnSBMMKbC_RrdbkPLcEcGA
You can see that when I press Ctrl-C the terminal does not jump to a new line, and on Ctrl-L it does not clear the screen.

Output of kitty --debug-config:

kitty 0.18.0 created by Kovid Goyal
Linux mArch 5.7.2-arch1-1 #1 SMP PREEMPT Wed, 10 Jun 2020 20:36:24 +0000 x86_64
Arch Linux \r (\l)
LSB_VERSION=1.4
DISTRIB_ID=Arch
DISTRIB_RELEASE=rolling
DISTRIB_DESCRIPTION="Arch Linux"
Loaded config files: /home/marten/.config/kitty/kitty.conf
Running under: X11

Config options different from defaults:
active_border_color   Color(red=189, green=147, blue=249)
background            Color(red=40, green=42, blue=54)
color1                Color(red=255, green=85, blue=85)
color10               Color(red=90, green=247, blue=142)
color11               Color(red=244, green=249, blue=157)
color12               Color(red=202, green=169, blue=250)
color13               Color(red=255, green=146, blue=208)
color14               Color(red=154, green=237, blue=254)
color15               Color(red=230, green=230, blue=230)
color2                Color(red=80, green=250, blue=123)
color3                Color(red=241, green=250, blue=140)
color4                Color(red=189, green=147, blue=249)
color5                Color(red=255, green=121, blue=198)
color6                Color(red=139, green=233, blue=253)
color7                Color(red=191, green=191, blue=191)
color8                Color(red=77, green=77, blue=77)
color9                Color(red=255, green=110, blue=103)
enable_audio_bell     False
font_family           Hack
font_size             10.0
foreground            Color(red=248, green=248, blue=242)
inactive_border_color Color(red=77, green=77, blue=77)
selection_background  Color(red=68, green=71, blue=90)
selection_foreground  None
window_border_width   2.0
window_padding_width  FloatEdges(left=20.0, top=20.0, right=20.0, bottom=20.0)
Added shortcuts:
	 control+alt+enter KeyAction(func='new_window_with_cwd', args=())

Output of kitty --debug-keyboard as seen in the video

Press xkb_keycode: 0x1a clean_sym: e composed_sym: e text: e mods: none glfw_key: 69 (E) xkb_key: 101 (e)
on_key_input: glfw key: 69 native_code: 0x65 action: PRESS mods: 0x0 text: 'e' state: 0 sent text to child
Release xkb_keycode: 0x1a clean_sym: e mods: none glfw_key: 69 (E) xkb_key: 101 (e)
on_key_input: glfw key: 69 native_code: 0x65 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Press xkb_keycode: 0x36 clean_sym: c composed_sym: c text: c mods: none glfw_key: 67 (C) xkb_key: 99 (c)
on_key_input: glfw key: 67 native_code: 0x63 action: PRESS mods: 0x0 text: 'c' state: 0 sent text to child
Press xkb_keycode: 0x2b clean_sym: h composed_sym: h text: h mods: none glfw_key: 72 (H) xkb_key: 104 (h)
on_key_input: glfw key: 72 native_code: 0x68 action: PRESS mods: 0x0 text: 'h' state: 0 sent text to child
Press xkb_keycode: 0x20 clean_sym: o composed_sym: o text: o mods: none glfw_key: 79 (O) xkb_key: 111 (o)
on_key_input: glfw key: 79 native_code: 0x6f action: PRESS mods: 0x0 text: 'o' state: 0 sent text to child
Release xkb_keycode: 0x36 clean_sym: c mods: none glfw_key: 67 (C) xkb_key: 99 (c)
on_key_input: glfw key: 67 native_code: 0x63 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Release xkb_keycode: 0x2b clean_sym: h mods: none glfw_key: 72 (H) xkb_key: 104 (h)
on_key_input: glfw key: 72 native_code: 0x68 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Press xkb_keycode: 0x41 clean_sym: space composed_sym: space text:   mods: none glfw_key: 32 (SPACE) xkb_key: 32 (space)
on_key_input: glfw key: 32 native_code: 0x20 action: PRESS mods: 0x0 text: ' ' state: 0 sent text to child
Release xkb_keycode: 0x20 clean_sym: o mods: none glfw_key: 79 (O) xkb_key: 111 (o)
on_key_input: glfw key: 79 native_code: 0x6f action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Release xkb_keycode: 0x41 clean_sym: space mods: none glfw_key: 32 (SPACE) xkb_key: 32 (space)
on_key_input: glfw key: 32 native_code: 0x20 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Press xkb_keycode: 0x1c clean_sym: t composed_sym: t text: t mods: none glfw_key: 84 (T) xkb_key: 116 (t)
on_key_input: glfw key: 84 native_code: 0x74 action: PRESS mods: 0x0 text: 't' state: 0 sent text to child
Press xkb_keycode: 0x1a clean_sym: e composed_sym: e text: e mods: none glfw_key: 69 (E) xkb_key: 101 (e)
on_key_input: glfw key: 69 native_code: 0x65 action: PRESS mods: 0x0 text: 'e' state: 0 sent text to child
Release xkb_keycode: 0x1c clean_sym: t mods: none glfw_key: 84 (T) xkb_key: 116 (t)
on_key_input: glfw key: 84 native_code: 0x74 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Press xkb_keycode: 0x27 clean_sym: s composed_sym: s text: s mods: none glfw_key: 83 (S) xkb_key: 115 (s)
on_key_input: glfw key: 83 native_code: 0x73 action: PRESS mods: 0x0 text: 's' state: 0 sent text to child
Press xkb_keycode: 0x1c clean_sym: t composed_sym: t text: t mods: none glfw_key: 84 (T) xkb_key: 116 (t)
on_key_input: glfw key: 84 native_code: 0x74 action: PRESS mods: 0x0 text: 't' state: 0 sent text to child
Release xkb_keycode: 0x1a clean_sym: e mods: none glfw_key: 69 (E) xkb_key: 101 (e)
on_key_input: glfw key: 69 native_code: 0x65 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Release xkb_keycode: 0x27 clean_sym: s mods: none glfw_key: 83 (S) xkb_key: 115 (s)
on_key_input: glfw key: 83 native_code: 0x73 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Press xkb_keycode: 0x24 clean_sym: Return composed_sym: Return mods: none glfw_key: 257 (ENTER) xkb_key: 65293 (Return)
on_key_input: glfw key: 257 native_code: 0xff0d action: PRESS mods: 0x0 text: '' state: 0 sent key to child
Release xkb_keycode: 0x1c clean_sym: t mods: none glfw_key: 84 (T) xkb_key: 116 (t)
on_key_input: glfw key: 84 native_code: 0x74 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Release xkb_keycode: 0x24 clean_sym: Return mods: none glfw_key: 257 (ENTER) xkb_key: 65293 (Return)
on_key_input: glfw key: 257 native_code: 0xff0d action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Press xkb_keycode: 0x25 clean_sym: Control_L composed_sym: Control_L mods: none glfw_key: 341 (LEFT CONTROL) xkb_key: 65507 (Control_L)
on_key_input: glfw key: 341 native_code: 0xffe3 action: PRESS mods: 0x0 text: '' state: 0 sent key to child
Press xkb_keycode: 0x36 clean_sym: c composed_sym: c mods: none glfw_key: 67 (C) xkb_key: 99 (c)
on_key_input: glfw key: 67 native_code: 0x63 action: PRESS mods: 0x0 text: '' state: 0 sent key to child
Release xkb_keycode: 0x36 clean_sym: c mods: none glfw_key: 67 (C) xkb_key: 99 (c)
on_key_input: glfw key: 67 native_code: 0x63 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Press xkb_keycode: 0x36 clean_sym: c composed_sym: c mods: none glfw_key: 67 (C) xkb_key: 99 (c)
on_key_input: glfw key: 67 native_code: 0x63 action: PRESS mods: 0x0 text: '' state: 0 sent key to child
Release xkb_keycode: 0x36 clean_sym: c mods: none glfw_key: 67 (C) xkb_key: 99 (c)
on_key_input: glfw key: 67 native_code: 0x63 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Release xkb_keycode: 0x25 clean_sym: Control_L mods: none glfw_key: 341 (LEFT CONTROL) xkb_key: 65507 (Control_L)
on_key_input: glfw key: 341 native_code: 0xffe3 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Press xkb_keycode: 0x25 clean_sym: Control_L composed_sym: Control_L mods: none glfw_key: 341 (LEFT CONTROL) xkb_key: 65507 (Control_L)
on_key_input: glfw key: 341 native_code: 0xffe3 action: PRESS mods: 0x0 text: '' state: 0 sent key to child
Press xkb_keycode: 0x2e clean_sym: l composed_sym: l mods: none glfw_key: 76 (L) xkb_key: 108 (l)
on_key_input: glfw key: 76 native_code: 0x6c action: PRESS mods: 0x0 text: '' state: 0 sent key to child
Release xkb_keycode: 0x2e clean_sym: l mods: none glfw_key: 76 (L) xkb_key: 108 (l)
on_key_input: glfw key: 76 native_code: 0x6c action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Press xkb_keycode: 0x2e clean_sym: l composed_sym: l mods: none glfw_key: 76 (L) xkb_key: 108 (l)
on_key_input: glfw key: 76 native_code: 0x6c action: PRESS mods: 0x0 text: '' state: 0 sent key to child
Release xkb_keycode: 0x2e clean_sym: l mods: none glfw_key: 76 (L) xkb_key: 108 (l)
on_key_input: glfw key: 76 native_code: 0x6c action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Release xkb_keycode: 0x25 clean_sym: Control_L mods: none glfw_key: 341 (LEFT CONTROL) xkb_key: 65507 (Control_L)
on_key_input: glfw key: 341 native_code: 0xffe3 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events
Press xkb_keycode: 0x40 clean_sym: Alt_L composed_sym: Alt_L mods: none glfw_key: 342 (LEFT ALT) xkb_key: 65513 (Alt_L)
on_key_input: glfw key: 342 native_code: 0xffe9 action: PRESS mods: 0x0 text: '' state: 0 sent key to child
on_key_input: glfw key: 342 native_code: 0xffe9 action: RELEASE mods: 0x0 text: '' state: 0 ignoring as keyboard mode does not allow release events

What is also interesting is that showkey -a does not print anything on a ctrl-key combination, except for the following keys: (But as you can see, the caret is missing)
showkey

@Linouth Linouth added the bug label Jun 23, 2020
@kovidgoyal
Copy link
Owner

According to that debug keyboard output libxkbcommon is not registering the
modifiers, see the line mods: 0x0 where it would normally read mods: ctrl

What that is on your system, I have no clue. Is there something unusual
in the keyboard handling setup of your desktop? In any case, if you wish
to debug further, look at the code, its glfw_xkb_handle_key_event in
xkb_glfw.c

@Linouth
Copy link
Author

Linouth commented Jun 23, 2020

Alright, I have poked a bit in the code and have found something interesting.
glfw_xkb_update_modifiers does actually read the modifier keypress, and it sets the flag in xkb->states.modifiers. However, once I press another key it seems to be reset to 0.

The only place where the modifiers flag is set to 0, other than the update function, is in glfw_xkb_compile_keymap. If I comment out that line, the modifiers actually work!

xkb->states.modifiers = 0;

The glfw_xkb_compile_keymap function is called on any modifier keypress/release, but also when I have a modifier pressed and press another key. This is then resetting the modifiers flag to 0. I have a feeling that this function is not supposed to run in that second case, and that might be the reason it breaks.

Now obviously I have no idea if just commenting out that line breaks anything but it seems to work alright.

I have two normal keyboards connected, but otherwise there is nothing unusual about my system.
Also I am running X11, but I have Wayland installed as well. I would be surprised if this causes an issue but still wanted to point that out.

@kovidgoyal
Copy link
Owner

This will be because of c7c14f1 the question is why is your system generating multiple new keyboard events. Are you switching between keyboards a lot?

@Linouth
Copy link
Author

Linouth commented Jun 23, 2020

Okay I am confused. It seems to be an issue with one of my keyboards. That board keeps triggering an XkbNewKeyboardNotify event every time I press any modifier key. This triggers glfw_xkb_compile_keymap the next time a key is pressed or released, which sets the modifiers flag to 0.

The keyboard in question is an Anne Pro (first gen). This board has some issues pre-os boot and does not function in Grub or the firmware settings, which is why I have another keyboard connected.

@Linouth
Copy link
Author

Linouth commented Jun 23, 2020

Yeah you are right, patching that out and breaking before the fallthrough seems to work.
No I have no idea why that happens. Even with just my Anne pro connected, it keeps sending the events.

@kovidgoyal
Copy link
Owner

Seems like a broken keyboard. I'll leave this open for now in case this
issue is common in which case I will consider reverting the patch, but
this is a bug in the keyboard/keyboard driver it really shouldnt be
sending new keyboard events all the time.

@Linouth
Copy link
Author

Linouth commented Jun 23, 2020

Yeah, that is fair. I will patch the code locally then.
Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants