From fc49e7279d71489571a9934a2fee50be3890a888 Mon Sep 17 00:00:00 2001 From: Jindrich Makovicka Date: Sun, 12 Nov 2017 20:30:26 +0100 Subject: [PATCH 1/5] sdl2: Do not quit the emulator when an auxilliary window is closed Signed-off-by: Jindrich Makovicka Message-Id: <20171112193032.9724-3-makovick@gmail.com> Signed-off-by: Gerd Hoffmann --- ui/sdl2.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ui/sdl2.c b/ui/sdl2.c index 53dd447fd2..05729af971 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -566,9 +566,14 @@ static void handle_windowevent(SDL_Event *ev) update_displaychangelistener(&scon->dcl, 500); break; case SDL_WINDOWEVENT_CLOSE: - if (!no_quit) { - no_shutdown = 0; - qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI); + if (qemu_console_is_graphic(scon->dcl.con)) { + if (!no_quit) { + no_shutdown = 0; + qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI); + } + } else { + SDL_HideWindow(scon->real_window); + scon->hidden = true; } break; case SDL_WINDOWEVENT_SHOWN: From 253347e100a6cd142fc88e26c4b4297410e75ddf Mon Sep 17 00:00:00 2001 From: Jindrich Makovicka Date: Sun, 12 Nov 2017 20:30:27 +0100 Subject: [PATCH 2/5] sdl2: Use the same pointer show/hide logic for absolute and relative mode Also use a proper enum parameter for SDL_ShowCursor Signed-off-by: Jindrich Makovicka Message-Id: <20171112193032.9724-4-makovick@gmail.com> Signed-off-by: Gerd Hoffmann --- ui/sdl2.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/ui/sdl2.c b/ui/sdl2.c index 05729af971..d0f16f60f4 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -169,10 +169,10 @@ static void sdl_hide_cursor(void) return; } - if (qemu_input_is_absolute()) { - SDL_ShowCursor(1); - SDL_SetCursor(sdl_cursor_hidden); - } else { + SDL_ShowCursor(SDL_DISABLE); + SDL_SetCursor(sdl_cursor_hidden); + + if (!qemu_input_is_absolute()) { SDL_SetRelativeMouseMode(SDL_TRUE); } } @@ -185,14 +185,16 @@ static void sdl_show_cursor(void) if (!qemu_input_is_absolute()) { SDL_SetRelativeMouseMode(SDL_FALSE); - SDL_ShowCursor(1); - if (guest_cursor && - (gui_grab || qemu_input_is_absolute() || absolute_enabled)) { - SDL_SetCursor(guest_sprite); - } else { - SDL_SetCursor(sdl_cursor_normal); - } } + + if (guest_cursor && + (gui_grab || qemu_input_is_absolute() || absolute_enabled)) { + SDL_SetCursor(guest_sprite); + } else { + SDL_SetCursor(sdl_cursor_normal); + } + + SDL_ShowCursor(SDL_ENABLE); } static void sdl_grab_start(struct sdl2_console *scon) From cd6d78b71843df2cb0a7228b935cfb9833b65c65 Mon Sep 17 00:00:00 2001 From: Jindrich Makovicka Date: Sun, 12 Nov 2017 20:30:30 +0100 Subject: [PATCH 3/5] sdl2: Fix dead keyboard after fullsceen Signed-off-by: Jindrich Makovicka Message-Id: <20171112193032.9724-7-makovick@gmail.com> Signed-off-by: Gerd Hoffmann --- ui/sdl2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/sdl2.c b/ui/sdl2.c index d0f16f60f4..cf05214f97 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -442,6 +442,7 @@ static void handle_keyup(SDL_Event *ev) sdl2_reset_keys(scon); return; } + sdl2_reset_keys(scon); gui_keysym = 0; } if (!gui_keysym) { From 24952847ad50f1b120287fdc4469b78108eef33c Mon Sep 17 00:00:00 2001 From: Jindrich Makovicka Date: Sun, 12 Nov 2017 20:30:31 +0100 Subject: [PATCH 4/5] sdl2: Do not leave grab when fullscreen Prevents displaying of a doubled mouse pointer when moving the pointer to the screen edges when fullscreen. Signed-off-by: Jindrich Makovicka Message-Id: <20171112193032.9724-8-makovick@gmail.com> Signed-off-by: Gerd Hoffmann --- ui/sdl2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/sdl2.c b/ui/sdl2.c index cf05214f97..8360054094 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -471,8 +471,9 @@ static void handle_mousemotion(SDL_Event *ev) SDL_GetWindowSize(scon->real_window, &scr_w, &scr_h); max_x = scr_w - 1; max_y = scr_h - 1; - if (gui_grab && (ev->motion.x == 0 || ev->motion.y == 0 || - ev->motion.x == max_x || ev->motion.y == max_y)) { + if (gui_grab && !gui_fullscreen + && (ev->motion.x == 0 || ev->motion.y == 0 || + ev->motion.x == max_x || ev->motion.y == max_y)) { sdl_grab_end(scon); } if (!gui_grab && From bcf43cdc178ffbd06d0533b6c54e92640817c9c7 Mon Sep 17 00:00:00 2001 From: Jindrich Makovicka Date: Sun, 12 Nov 2017 20:30:25 +0100 Subject: [PATCH 5/5] sdl2: Fix broken display updating after the window is hidden With SDL 2.0.6, calling SDL_ShowWindow during SDL_WINDOWEVENT_HIDDEN blocks all subsequent display updates. Instead of trying to override the change, just update the scon->hidden flag. Signed-off-by: Jindrich Makovicka Message-Id: <20171112193032.9724-2-makovick@gmail.com> This is a partial revert of d3f3a0f453ea590be529079ae214c200bb5ecc1a, which in turn is a workaround for a SDL bug. The bug is fixed in 2.0.6, see https://bugzilla.libsdl.org/show_bug.cgi?id=3410 Signed-off-by: Gerd Hoffmann --- ui/sdl2.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ui/sdl2.c b/ui/sdl2.c index 8360054094..8718cf36b5 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -581,14 +581,10 @@ static void handle_windowevent(SDL_Event *ev) } break; case SDL_WINDOWEVENT_SHOWN: - if (scon->hidden) { - SDL_HideWindow(scon->real_window); - } + scon->hidden = false; break; case SDL_WINDOWEVENT_HIDDEN: - if (!scon->hidden) { - SDL_ShowWindow(scon->real_window); - } + scon->hidden = true; break; } }