[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 3/6] ui/sdl: implement show-cursor option
From: |
Gerd Hoffmann |
Subject: |
[PATCH v2 3/6] ui/sdl: implement show-cursor option |
Date: |
Thu, 6 Feb 2020 12:29:05 +0100 |
Signed-off-by: Gerd Hoffmann <address@hidden>
Reviewed-by: Ján Tomko <address@hidden>
---
ui/sdl2.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 9030f1c42efb..e18555b10a42 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -161,9 +161,15 @@ static void sdl_update_caption(struct sdl2_console *scon)
}
}
-static void sdl_hide_cursor(void)
+static void sdl_hide_cursor(struct sdl2_console *scon)
{
- if (!cursor_hide) {
+ bool allow_hide_cursor = true;
+
+ if (scon->opts->has_show_cursor && scon->opts->show_cursor) {
+ allow_hide_cursor = false;
+ }
+
+ if (!allow_hide_cursor) {
return;
}
@@ -175,9 +181,15 @@ static void sdl_hide_cursor(void)
}
}
-static void sdl_show_cursor(void)
+static void sdl_show_cursor(struct sdl2_console *scon)
{
- if (!cursor_hide) {
+ bool allow_hide_cursor = true;
+
+ if (scon->opts->has_show_cursor && scon->opts->show_cursor) {
+ allow_hide_cursor = false;
+ }
+
+ if (!allow_hide_cursor) {
return;
}
@@ -216,7 +228,7 @@ static void sdl_grab_start(struct sdl2_console *scon)
SDL_WarpMouseInWindow(scon->real_window, guest_x, guest_y);
}
} else {
- sdl_hide_cursor();
+ sdl_hide_cursor(scon);
}
SDL_SetWindowGrab(scon->real_window, SDL_TRUE);
gui_grab = 1;
@@ -227,7 +239,7 @@ static void sdl_grab_end(struct sdl2_console *scon)
{
SDL_SetWindowGrab(scon->real_window, SDL_FALSE);
gui_grab = 0;
- sdl_show_cursor();
+ sdl_show_cursor(scon);
sdl_update_caption(scon);
}
@@ -658,7 +670,7 @@ static void sdl_mouse_warp(DisplayChangeListener *dcl,
if (on) {
if (!guest_cursor) {
- sdl_show_cursor();
+ sdl_show_cursor(scon);
}
if (gui_grab || qemu_input_is_absolute() || absolute_enabled) {
SDL_SetCursor(guest_sprite);
@@ -667,7 +679,7 @@ static void sdl_mouse_warp(DisplayChangeListener *dcl,
}
}
} else if (gui_grab) {
- sdl_hide_cursor();
+ sdl_hide_cursor(scon);
}
guest_cursor = on;
guest_x = x, guest_y = y;
--
2.18.1
- [PATCH v2 0/6] ui: rework -show-cursor option, Gerd Hoffmann, 2020/02/06
- [PATCH v2 6/6] ui: deprecate legacy -show-cursor option, Gerd Hoffmann, 2020/02/06
- [PATCH v2 4/6] ui/cocoa: implement show-cursor option, Gerd Hoffmann, 2020/02/06
- [PATCH v2 1/6] ui: add show-cursor option, Gerd Hoffmann, 2020/02/06
- [PATCH v2 5/6] ui: wire up legacy -show-cursor option, Gerd Hoffmann, 2020/02/06
- [PATCH v2 2/6] ui/gtk: implement show-cursor option, Gerd Hoffmann, 2020/02/06
- [PATCH v2 3/6] ui/sdl: implement show-cursor option,
Gerd Hoffmann <=
- Re: [PATCH v2 0/6] ui: rework -show-cursor option, Peter Maydell, 2020/02/06