Skip to contentSkip to conversation

ui/sdl2: Ignore key repeats for shortcut keys

PATCH Applied Thomas Huth 2 participants 2 messages Jan 10, 2018 – Jan 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui/sdl2: Ignore key repeats for shortcut keys

Holding down a shortcut key currently continuesly triggers the shortcut event, e.g. holding CTRL-ALT-f continuesly switches between windowed and fullscreen mode, or holding CTRL-ALT-u even crashes QEMU with a segfault. This is ugly, we should rather ignore automatic key repeats when handling the keyboard shortcuts.

---
 ui/sdl2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ui/sdl2.c +1 -1
index 8718cf3..18664b4 100644
@@ -349,7 +349,7 @@ static void handle_keydown(SDL_Event *ev)
     }
     gui_key_modifier_pressed = mod_state;
 
-    if (gui_key_modifier_pressed) {
+    if (gui_key_modifier_pressed && !ev->key.repeat) {
         switch (ev->key.keysym.scancode) {
         case SDL_SCANCODE_2:
         case SDL_SCANCODE_3:
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 5 lines · Thomas Huth

Holding down a shortcut key currently continuesly triggers the shortcut event, e.g. holding CTRL-ALT-f continuesly switches between windowed and fullscreen mode, or holding CTRL-ALT-u even crashes QEMU with a segfault. This is ugly, we should rather ignore automatic key repeats when handling the keyboard shortcuts.

Applied to -trivial, thank you!

/mjt