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

Missing key release events on winit backend results in permanently pressed modifiers #1353

Open
sodiboo opened this issue Mar 6, 2024 · 0 comments

Comments

@sodiboo
Copy link

sodiboo commented Mar 6, 2024

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:

  1. Open niri nested in niri
    • i use niri myself, and tested this on niri. it might work just as well in other compositors
  2. Focus nested niri
  3. Press any modifier key, e.g. "Super" (and do not release)
    • nested niri gets a KeyState::Pressed event
  4. Click with the mouse cursor on another window in the top-level compositor
  5. Release the modifier key
    • nested niri gets no event
  6. Focus nested niri again

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:

impl ModifiersState {
/// Update the modifiers state from an xkb state
pub fn update_with(&mut self, state: &xkb::State) {
self.ctrl = state.mod_name_is_active(&xkb::MOD_NAME_CTRL, xkb::STATE_MODS_EFFECTIVE);
self.alt = state.mod_name_is_active(&xkb::MOD_NAME_ALT, xkb::STATE_MODS_EFFECTIVE);
self.shift = state.mod_name_is_active(&xkb::MOD_NAME_SHIFT, xkb::STATE_MODS_EFFECTIVE);
self.caps_lock = state.mod_name_is_active(&xkb::MOD_NAME_CAPS, xkb::STATE_MODS_EFFECTIVE);
self.logo = state.mod_name_is_active(&xkb::MOD_NAME_LOGO, xkb::STATE_MODS_EFFECTIVE);
self.num_lock = state.mod_name_is_active(&xkb::MOD_NAME_NUM, xkb::STATE_MODS_EFFECTIVE);
self.serialized = serialize_modifiers(state);
}
}

I implemented a workaround on compositor side:

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

1 participant