Skip to content

Commit 616814c

Browse files
Volker RümelinMichael Tokarev
authored andcommitted
ui/sdl2: reenable the SDL2 Windows keyboard hook procedure
Windows only: The libSDL2 Windows message loop needs the libSDL2 Windows low level keyboard hook procedure to grab the left and right Windows keys correctly. Reenable the SDL2 Windows keyboard hook procedure. Since SDL2 2.30.4 the SDL2 keyboard hook procedure also filters out the special left Control key event for every Alt Gr key event on keyboards with an international layout. This means the QEMU low level keyboard hook procedure is no longer needed. Remove the QEMU Windows keyboard hook procedure. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2139 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2323 Signed-off-by: Volker Rümelin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Bonzini <[email protected]> (cherry picked from commit 4dafba7) Signed-off-by: Michael Tokarev <[email protected]> (Mjt: context fix in ui/sdl2.c (includes))
1 parent d47f418 commit 616814c

File tree

2 files changed

+0
-30
lines changed

2 files changed

+0
-30
lines changed

ui/meson.build

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ if gtk.found()
120120
endif
121121

122122
if sdl.found()
123-
if host_os == 'windows'
124-
system_ss.add(files('win32-kbd-hook.c'))
125-
endif
126-
127123
sdl_ss = ss.source_set()
128124
sdl_ss.add(sdl, sdl_image, pixman, glib, files(
129125
'sdl2-2d.c',

ui/sdl2.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "sysemu/runstate.h"
3333
#include "sysemu/runstate-action.h"
3434
#include "sysemu/sysemu.h"
35-
#include "ui/win32-kbd-hook.h"
3635
#include "qemu/log.h"
3736

3837
static int sdl2_num_outputs;
@@ -262,15 +261,13 @@ static void sdl_grab_start(struct sdl2_console *scon)
262261
}
263262
SDL_SetWindowGrab(scon->real_window, SDL_TRUE);
264263
gui_grab = 1;
265-
win32_kbd_set_grab(true);
266264
sdl_update_caption(scon);
267265
}
268266

269267
static void sdl_grab_end(struct sdl2_console *scon)
270268
{
271269
SDL_SetWindowGrab(scon->real_window, SDL_FALSE);
272270
gui_grab = 0;
273-
win32_kbd_set_grab(false);
274271
sdl_show_cursor(scon);
275272
sdl_update_caption(scon);
276273
}
@@ -371,19 +368,6 @@ static int get_mod_state(void)
371368
}
372369
}
373370

374-
static void *sdl2_win32_get_hwnd(struct sdl2_console *scon)
375-
{
376-
#ifdef CONFIG_WIN32
377-
SDL_SysWMinfo info;
378-
379-
SDL_VERSION(&info.version);
380-
if (SDL_GetWindowWMInfo(scon->real_window, &info)) {
381-
return info.info.win.window;
382-
}
383-
#endif
384-
return NULL;
385-
}
386-
387371
static void handle_keydown(SDL_Event *ev)
388372
{
389373
int win;
@@ -608,10 +592,6 @@ static void handle_windowevent(SDL_Event *ev)
608592
sdl2_redraw(scon);
609593
break;
610594
case SDL_WINDOWEVENT_FOCUS_GAINED:
611-
win32_kbd_set_grab(gui_grab);
612-
if (qemu_console_is_graphic(scon->dcl.con)) {
613-
win32_kbd_set_window(sdl2_win32_get_hwnd(scon));
614-
}
615595
/* fall through */
616596
case SDL_WINDOWEVENT_ENTER:
617597
if (!gui_grab && (qemu_input_is_absolute(scon->dcl.con) || absolute_enabled)) {
@@ -627,9 +607,6 @@ static void handle_windowevent(SDL_Event *ev)
627607
scon->ignore_hotkeys = get_mod_state();
628608
break;
629609
case SDL_WINDOWEVENT_FOCUS_LOST:
630-
if (qemu_console_is_graphic(scon->dcl.con)) {
631-
win32_kbd_set_window(NULL);
632-
}
633610
if (gui_grab && !gui_fullscreen) {
634611
sdl_grab_end(scon);
635612
}
@@ -869,10 +846,7 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
869846
#ifdef SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR /* only available since SDL 2.0.8 */
870847
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
871848
#endif
872-
#ifndef CONFIG_WIN32
873-
/* QEMU uses its own low level keyboard hook procedure on Windows */
874849
SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1");
875-
#endif
876850
#ifdef SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED
877851
SDL_SetHint(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED, "0");
878852
#endif

0 commit comments

Comments
 (0)