-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Phantom key presses when focusing an egui/winit window #4513
Labels
Comments
Sounds like an easy fix then! Wanna make a PR? |
Sure, will do. |
hut
added a commit
to hut/egui
that referenced
this issue
May 20, 2024
emilk
pushed a commit
that referenced
this issue
May 21, 2024
Thanks so much for resolving this. It's such a subtle bug, but so annoying. I'm using a tiling window manager with lots of alt+letter keys for focus switching, and all those unintended key presses are driving me crazy. Very relieved, thanks. <3 |
hacknus
pushed a commit
to hacknus/egui
that referenced
this issue
Oct 30, 2024
This PR discards "synthetic" winit keypresses, as discussed in the issue emilk#4513. * Closes emilk#4513
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, when running egui in X11 on Linux with the winit backend, phantom key presses are registered when the window gains focus. Examples:
In either example, I would expect no key to be registered. After all, no other (non-broken) application will register/type keys simply by changing focus into the application window.
This error happens because winit sends "fake" KeyboardInput events with a field "is_synthetic" when the window focus is gained. Key presses with "
is_synthetic == true
" should not be interpreted as real key presses and should be filtered out, according to the maintainers of winit.egui currently does not do special handling of KeyboardInput events with "is_synthetic == true", see
egui/crates/egui-winit/src/lib.rs
Line 371 in 8321f64
The proper handling would be to discard the event if "
keyboardinput.event.state == ElementState::Pressed && keyboardinput.is_synthetic
" is true.See also:
is_synthetic == true
", which is another way to handle this.Thanks for looking into this. It probably causes a lot of confusion/frustration for X11 users that heavily customize their window manager key bindings.
The text was updated successfully, but these errors were encountered: