]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
ui/sdl2: release all modifiers
authorVolker Rümelin <vr_qemu@t-online.de>
Mon, 9 Sep 2024 06:15:51 +0000 (08:15 +0200)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Fri, 13 Sep 2024 18:12:16 +0000 (20:12 +0200)
Each virtual console in the SDL2 frontend has a key state map.
When switching windows with GUI keys we have to release all
pressed modifier keys in the currently active window, because
after the switch the now inactive window no longer receives the
key release events.

To reproduce the issue open a text editor in the SDL UI and then
press Ctrl-Alt-2 to open a Compat Monitor Console. Close the
console with the mouse. Try to enter text in the text editor and
notice that the modifier keys Ctrl and Alt are stuck and need to
be pressed once to be released.

Tested-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Tested-by: Bernhard Beschow <shentey@gmail.com>
Message-ID: <20240909061552.6122-2-vr_qemu@t-online.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
include/ui/sdl2.h
ui/sdl2-input.c
ui/sdl2.c

index e3acc7c82a7052ed93ed5d9f3241552ce68eeaa7..6907115809e906dbc9ed57c6b70124131b43fba1 100644 (file)
@@ -60,6 +60,7 @@ void sdl2_poll_events(struct sdl2_console *scon);
 
 void sdl2_process_key(struct sdl2_console *scon,
                       SDL_KeyboardEvent *ev);
+void sdl2_release_modifiers(struct sdl2_console *scon);
 
 void sdl2_2d_update(DisplayChangeListener *dcl,
                     int x, int y, int w, int h);
index b02a89ee7cd825e42c6dbb9c244ad2441753c7ea..2286df4223dc4b541db05acb2910ce54c866974f 100644 (file)
@@ -58,3 +58,8 @@ void sdl2_process_key(struct sdl2_console *scon,
         }
     }
 }
+
+void sdl2_release_modifiers(struct sdl2_console *scon)
+{
+    qkbd_state_lift_all_keys(scon->kbd);
+}
index 251ce97796309e4f52743840b8d8263348f6dd53..71a0d471d12237567ce4a2831120ab798b06b954 100644 (file)
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -418,6 +418,7 @@ static void handle_keydown(SDL_Event *ev)
                         SDL_ShowWindow(sdl2_console[win].real_window);
                     }
                 }
+                sdl2_release_modifiers(scon);
                 gui_keysym = 1;
             }
             break;