-
Notifications
You must be signed in to change notification settings - Fork 170
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
Missing key release events on winit backend results in permanently pressed modifiers #1353
Comments
Okay, so i don't know how i missed this at first: xkbcommon is actually counting the number of keys it thinks has that physical key pressed. It needs to receive enough release events to reset the counter to 0 for it to count as unpressed. As such, you can work around this as a user without any changes to the code with the follow process:
I don't know how i missed this when i first reported this issue. I even thought that it might be doing exactly this, but somehow concluded that it doesn't, and that the bugged is irreversible and permanent. My testing was not rigorous enough it seems. This isn't a bug in xkbcommon like it kind of looked like? Note that the reason for my workaround in niri being implemented in that way is because this happened in xkbcommon, for which i didn't investigate its source code. I treated it as a black box, since it's a native library. I didn't see the true nature of the issue as observed by xkbcommon, so my niri workaround relies on just preventing the bad state from ever being sent to xkbcommon, which is a valid workaround, but not a very reliable one. It seems that this stems from the smithay/src/backend/winit/mod.rs Lines 467 to 472 in f364c73
This is, in general, a violation of the
That's the codeblock shown above
This part is handled correctly
This part is handled entirely wrong. Smithay doesn't set the key to logically down
This part maps to the key count as such:
Note that we do NOT receive events for any count But wait! That last part isn't entirely true. Not when we think of the whole application as a wayland client, in general. But that's the stuff winit tells us. Wait what? Yeah! The So, the new, refined model is that:
So, woo? How can we use this in the Smithay winit backend? Well, we can't. Because, the winit crate does not tell us anything about the new state upon keyboard enter. In fact, it completely ignores all parameters to that event, besides the surface (to figure out which window has focus, i guess, and it does stuff with that). winit doesn't expose this information. you can't currently make a client that handles keyboard input correcttly in winit because winit literally doesn't give you the information except when a single key is pressed/released. so this isn't even really so much Smithay's fault. given the winit API, i genuinely don't think what Smithay does looks unreasonable at all. |
Yeah that pretty much sums up our problems with winit that lead to the X11 backend being created in the first place (with the idea of implementing a wayland backend as well further down the line). Later we got aware of plans to make it possible to gain access to more internal types of winit or even implementing our own So the state of the nested backends we have right now is stuck in a limbo of "barely working" to "good-enough-for-now" until we decide to go through with either solution and somebody actually takes the time to implement all that. |
When running in the winit backend, we don't always get release events from the outer compositor/window manager.
You can reproduce this issue reliably like so:
Now, xkbcommon will be in an annoying state where it reports that modifier as being permanently pressed.
These faulty modifiers are observed by Smithay here:
smithay/src/input/keyboard/modifiers_state.rs
Lines 30 to 41 in 8287457
I implemented a workaround on compositor side:
The text was updated successfully, but these errors were encountered: