aboutsummaryrefslogtreecommitdiff
path: root/ui/sdl2.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-05-21 14:48:15 +0100
committerPeter Maydell <peter.maydell@linaro.org>2020-05-21 14:48:15 +0100
commitad5a59124c251abd7e725fa3f6a3308c06d6b486 (patch)
tree218e7001a8a1ef88adcc5eafb9bde7fdf53e7829 /ui/sdl2.c
parent8b9112e4aef0651feff82e49d1e58947cceab66a (diff)
parent7b23d121f913709306e678a3289edc813f3a7463 (diff)
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20200520-pull-request' into staging
ui: windows keyboard fixes for gtk & sdl. ui: require GTK 3.22 or newer. # gpg: Signature made Wed 20 May 2020 09:41:48 BST # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/ui-20200520-pull-request: ui: increase min required GTK version to 3.22.0 ui/gtk: use native keyboard scancodes on Windows ui/gtk: don't pass on win keys without keyboard grab ui/sdl2-input: use trace-events to debug key events ui/sdl2: start in full screen with grab enabled ui/sdl2: fix handling of AltGr key on Windows ui/gtk: remove unused variable ignore_keys ui/gtk: remove unused code ui/gkt: release all keys on grab-broken-event ui/gtk: fix handling of AltGr key on Windows ui/win32-kbd-hook: handle AltGr in a hook procedure Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'ui/sdl2.c')
-rw-r--r--ui/sdl2.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 61c7956da3..b23a8f0a8e 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -30,6 +30,7 @@
#include "ui/sdl2.h"
#include "sysemu/runstate.h"
#include "sysemu/sysemu.h"
+#include "ui/win32-kbd-hook.h"
static int sdl2_num_outputs;
static struct sdl2_console *sdl2_console;
@@ -220,6 +221,7 @@ static void sdl_grab_start(struct sdl2_console *scon)
}
SDL_SetWindowGrab(scon->real_window, SDL_TRUE);
gui_grab = 1;
+ win32_kbd_set_grab(true);
sdl_update_caption(scon);
}
@@ -227,6 +229,7 @@ static void sdl_grab_end(struct sdl2_console *scon)
{
SDL_SetWindowGrab(scon->real_window, SDL_FALSE);
gui_grab = 0;
+ win32_kbd_set_grab(false);
sdl_show_cursor(scon);
sdl_update_caption(scon);
}
@@ -325,6 +328,19 @@ static int get_mod_state(void)
}
}
+static void *sdl2_win32_get_hwnd(struct sdl2_console *scon)
+{
+#ifdef CONFIG_WIN32
+ SDL_SysWMinfo info;
+
+ SDL_VERSION(&info.version);
+ if (SDL_GetWindowWMInfo(scon->real_window, &info)) {
+ return info.info.win.window;
+ }
+#endif
+ return NULL;
+}
+
static void handle_keydown(SDL_Event *ev)
{
int win;
@@ -544,6 +560,11 @@ static void handle_windowevent(SDL_Event *ev)
sdl2_redraw(scon);
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
+ win32_kbd_set_grab(gui_grab);
+ if (qemu_console_is_graphic(scon->dcl.con)) {
+ win32_kbd_set_window(sdl2_win32_get_hwnd(scon));
+ }
+ /* fall through */
case SDL_WINDOWEVENT_ENTER:
if (!gui_grab && (qemu_input_is_absolute() || absolute_enabled)) {
absolute_mouse_grab(scon);
@@ -558,6 +579,9 @@ static void handle_windowevent(SDL_Event *ev)
scon->ignore_hotkeys = get_mod_state();
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
+ if (qemu_console_is_graphic(scon->dcl.con)) {
+ win32_kbd_set_window(NULL);
+ }
if (gui_grab && !gui_fullscreen) {
sdl_grab_end(scon);
}
@@ -857,17 +881,16 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
SDL_SetWindowIcon(sdl2_console[0].real_window, icon);
}
- gui_grab = 0;
- if (gui_fullscreen) {
- sdl_grab_start(0);
- }
-
mouse_mode_notifier.notify = sdl_mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&mouse_mode_notifier);
sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0);
sdl_cursor_normal = SDL_GetCursor();
+ if (gui_fullscreen) {
+ sdl_grab_start(&sdl2_console[0]);
+ }
+
atexit(sdl_cleanup);
}