X11: Don't emit keypress events for modifiers (#10271)

This fixes certain shortcuts/motions on X11 like in vim mode "v i )",
where previously zed would interpret it as "v i SHIFT )" due to the x11
backend emitting key press events for modifier keys even though other
platforms like Wayland don't. This also adds support for
ModifiersChanged events to X11

Release Notes:

- Fixed vim motions like "v i )" not working on X11
([#10199](https://github.com/zed-industries/zed/issues/10199)).
This commit is contained in:
Kamal Ahmad 2024-04-10 06:46:23 +05:00 committed by GitHub
parent 6ac343123d
commit 4151ba13a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 63 additions and 16 deletions

View file

@ -589,20 +589,7 @@ impl Dispatch<wl_keyboard::WlKeyboard, ()> for WaylandClient {
let keymap_state = state.keymap_state.as_mut().unwrap();
keymap_state.update_mask(mods_depressed, mods_latched, mods_locked, 0, 0, group);
let shift =
keymap_state.mod_name_is_active(xkb::MOD_NAME_SHIFT, xkb::STATE_MODS_EFFECTIVE);
let alt =
keymap_state.mod_name_is_active(xkb::MOD_NAME_ALT, xkb::STATE_MODS_EFFECTIVE);
let control =
keymap_state.mod_name_is_active(xkb::MOD_NAME_CTRL, xkb::STATE_MODS_EFFECTIVE);
let command =
keymap_state.mod_name_is_active(xkb::MOD_NAME_LOGO, xkb::STATE_MODS_EFFECTIVE);
state.modifiers.shift = shift;
state.modifiers.alt = alt;
state.modifiers.control = control;
state.modifiers.platform = command;
state.modifiers = Modifiers::from_xkb(keymap_state);
let input = PlatformInput::ModifiersChanged(ModifiersChangedEvent {
modifiers: state.modifiers,