From ef4a680ae813b23e7b9d1b6dd67413dcad377655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 19 Apr 2025 08:05:15 +0200 Subject: [PATCH] input: reset modifiers in keyboard_leave() Closes #2034 --- CHANGELOG.md | 3 +++ input.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c15e05bf..35669f03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,8 +71,11 @@ * Grapheme shaping was allowed to be "enabled" at runtime, even though disabled at compile time. This caused mis-rendering of certain codepoints ([#2039][2039]). +* Keyboard modifiers not being reset on keyboard leave events + ([#2034][2034]). [2039]: https://codeberg.org/dnkl/foot/issues/2039 +[2034]: https://codeberg.org/dnkl/foot/issues/2034 ### Security diff --git a/input.c b/input.c index 0f2a8446..d7a7975a 100644 --- a/input.c +++ b/input.c @@ -765,9 +765,17 @@ keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, seat->kbd.alt = false; seat->kbd.ctrl = false; seat->kbd.super = false; + if (seat->kbd.xkb_compose_state != NULL) xkb_compose_state_reset(seat->kbd.xkb_compose_state); + if (seat->kbd.xkb_state != NULL && seat->kbd.xkb_keymap != NULL) { + const xkb_layout_index_t layout_count = xkb_keymap_num_layouts(seat->kbd.xkb_keymap); + + for (xkb_layout_index_t i = 0; i < layout_count; i++) + xkb_state_update_mask(seat->kbd.xkb_state, 0, 0, 0, i, i, i); + } + if (old_focused != NULL) { seat->pointer.hidden = false; term_xcursor_update_for_seat(old_focused, seat);