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

Keyboard key is falsely recognized as being pressed #2014

Closed
m-rey opened this issue Sep 30, 2019 · 13 comments
Closed

Keyboard key is falsely recognized as being pressed #2014

m-rey opened this issue Sep 30, 2019 · 13 comments

Comments

@m-rey
Copy link

m-rey commented Sep 30, 2019

steps to reproduce

  1. open two kitty terminals, side by side
  2. move your mouse over the first terminal, focusing it
  3. hold down a keyboard key
  4. while still pressing the key, move the mouse away from first terminal to second terminal, focusing the second terminal
  5. release the key while being in the second terminal. Now no key is currently being pressed
  6. move the mouse back to the first terminal, focusing it
    -> the previously held down key is being printed and thus recognized as pressed, even though no key is being pressed.
@kovidgoyal
Copy link
Owner

I cannot replicate on X11 using those steps with

kitty --config NONE -o focus_follows_mouse=y

@Luflosi
Copy link
Contributor

Luflosi commented Sep 30, 2019

I cannot replicate on macOS with the same command line options.

@m-rey
Copy link
Author

m-rey commented Sep 30, 2019

using swaywm (wayland), kitty 0.14.4 with
kitty --config NONE -o focus_follows_mouse=y

@kovidgoyal
Copy link
Owner

Ah Wayland. Yeah that is a limitation of Wayland's design. In
Wayland there are no key repeat events. So glfw runs a timer to
simulate key repeat. If you release the key on another window then there
is never a release event to stop the timer in the first window. And so
it keeps going. I suppose one could workaround it by also killing the
timer when the window loses focus, but then that means you cannot mouse out
and mouse back with a key pressed and expect the repeat to continue.

@kovidgoyal
Copy link
Owner

@emersion any hints on what the correct way to do this in wayland is, if there even is one?

@agraul
Copy link

agraul commented Sep 30, 2019

@kovidgoyal GNOME Terminal seems to "kill the timer" (or however it does it), it does not continue with the input in either case (lose focus and keep button pressed / lose focus and stop pressing key)

@kovidgoyal
Copy link
Owner

yeah killing the timer on focus loss is the obvious thing to do, but it means that if you keep a key pressed and your mouse happens to stray off the window for a second, boom key repeating stops working. This does not happen on other platforms. So I would hope wayland has some way to actually implement it correctly as is done on all other platforms, but maybe I am being optimistic.

@emersion
Copy link

If you release the key on another window then there
is never a release event to stop the timer in the first window.

Clients should release all keys when the wl_keyboard.leave event is sent.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Sep 30, 2019 via email

@emersion
Copy link

No, it will work, just like on other platforms.

If you have focus_follows_mouse and move the mouse accidentally, it'll change the keyboard focus, just like on X11.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Sep 30, 2019 via email

@emersion
Copy link

The wl_keyboard.enter event contains the set of pressed keys. You can restart the timers there.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Sep 30, 2019 via email

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

No branches or pull requests

5 participants