]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/keyboard.c: always try to remove keys from the pressed set on release
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 23 Oct 2023 17:48:52 +0000 (19:48 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 25 Oct 2023 16:30:05 +0000 (18:30 +0200)
Fixes: #1200
Reported-by: @kyak
src/keyboard.c

index df8bce684b928300356a945066cbb9530165bd54..2d6cae7c16c42b19414ad2baf3070baf32533383 100644 (file)
@@ -241,9 +241,16 @@ handle_compositor_keybindings(struct keyboard *keyboard,
                is_layout_switch |= translated.syms[i] == XKB_KEY_ISO_Next_Group;
        }
 
-       if (!is_modifier && !is_layout_switch) {
-               key_state_set_pressed(event->keycode,
-                       event->state == WL_KEYBOARD_KEY_STATE_PRESSED);
+       /*
+        * An earlier press event from a key that causes a layout change event
+        * might have been added already without us knowing that it actually was
+        * a XKB_KEY_ISO_Next_Group sym. Thus we always try to remove the current
+        * key from the set of pressed keys on release.
+        */
+       if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
+               key_state_set_pressed(event->keycode, false);
+       } else if (!is_modifier && !is_layout_switch) {
+               key_state_set_pressed(event->keycode, true);
        }
 
        /*