Skip to contentSkip to conversation

kbd-state: fix autorepeat handling

PATCH New Gerd Hoffmann 1 participant 1 message May 14, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbd-state: fix autorepeat handling

When allowing multiple down-events in a row (key autorepeat) we can't use change_bit() any more to update the state, because autorepeat events don't change the key state. We have to explicitly use set_bit() and clear_bit() instead.

Fixes 35921860156e kbd-state: don't block auto-repeat events
---
 ui/kbd-state.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
ui/kbd-state.c +5 -1
index f3ab2d7a665d..1668d17ddabc 100644
@@ -59,7 +59,11 @@ void qkbd_state_key_event(QKbdState *kbd, QKeyCode qcode, bool down)
     }
 
     /* update key and modifier state */
-    change_bit(qcode, kbd->keys);
+    if (down) {
+        set_bit(qcode, kbd->keys);
+    } else {
+        clear_bit(qcode, kbd->keys);
+    }
     switch (qcode) {
     case Q_KEY_CODE_SHIFT:
     case Q_KEY_CODE_SHIFT_R:
Signature · 1 line
2.18.1