ui: rework -show-cursor option
cover ui: rework -show-cursor option
Gerd Hoffmann (5):
ui: add show-cursor option
ui/gtk: implement show-cursor option
ui/sdl: implement show-cursor option
ui: wire up legacy -show-cursor option
ui: deprecate legacy -show-cursor option
include/sysemu/sysemu.h | 1 - ui/gtk.c | 8 +++++++- ui/sdl2.c | 28 ++++++++++++++++++++-------- vl.c | 6 ++++-- qapi/ui.json | 2 ++ qemu-deprecated.texi | 5 +++++ 6 files changed, 38 insertions(+), 12 deletions(-)
Signature · 1 line
2.18.1
PATCH 1/5 ui: add show-cursor option
When enabled forces showing a the mouse cursor, i.e. do nowallow the guest to hide it. Defaults to off.
--- qapi/ui.json | 2 ++ 1 file changed, 2 insertions(+)
qapi/ui.json +2 -0
@@ -1144,6 +1144,7 @@ # @type: Which DisplayType qemu should use. # @full-screen: Start user interface in fullscreen mode (default: off). # @window-close: Allow to quit qemu with window close button (default: on). +# @show-cursor: Force showing the mouse cursor (default: off). # @gl: Enable OpenGL support (default: off). # # Since: 2.12
@@ -1153,6 +1154,7 @@ 'base' : { 'type' : 'DisplayType', '*full-screen' : 'bool', '*window-close' : 'bool', + '*show-cursor' : 'bool', '*gl' : 'DisplayGLMode' }, 'discriminator' : 'type', 'data' : { 'gtk' : 'DisplayGTK',
Signature · 1 line
2.18.1
Re: [PATCH 1/5] ui: add show-cursor option
Quoted 1 line · Gerd Hoffmann
When enabled forces showing a the mouse cursor, i.e. do
When enabled, this forces showing the mouse...
Quoted 1 line
nowallow the guest to hide it. Defaults to off.
s/nowallow/not allow/
Quoted 11 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- qapi/ui.json | 2 ++ 1 file changed, 2 insertions(+)qapi/ui.json +0
-0
qapi/ui.json line 1150
Quoted 7 lines
qapi/ui.json +1
-0@@ -1144,6 +1144,7 @@ # @type: Which DisplayType qemu should use. # @full-screen: Start user interface in fullscreen mode (default: off). # @window-close: Allow to quit qemu with window close button (default: on). +# @show-cursor: Force showing the mouse cursor (default: off). # @gl: Enable OpenGL support (default: off). # # Since: 2.12
Missing a '(since 5.0)' tag.
Quoted 9 lines
qapi/ui.json +1
-0@@ -1153,6 +1154,7 @@ 'base' : { 'type' : 'DisplayType', '*full-screen' : 'bool', '*window-close' : 'bool', + '*show-cursor' : 'bool', '*gl' : 'DisplayGLMode' }, 'discriminator' : 'type', 'data' : { 'gtk' : 'DisplayGTK',
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH 1/5] ui: add show-cursor option
In reply to Gerd HoffmannQuoted 8 lines · Gerd Hoffmann
When enabled forces showing a the mouse cursor, i.e. do nowallow the guest to hide it. Defaults to off.
Signed-off-by Gerd Hoffmann <[email protected]>---
qapi/ui.json| 2 ++1 file changed, 2 insertions(+)
Jano
PATCH 2/5 ui/gtk: implement show-cursor option
In reply to Gerd Hoffmann--- ui/gtk.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
ui/gtk.c +7 -1
@@ -247,6 +247,7 @@ static void gd_update_cursor(VirtualConsole *vc) {GtkDisplayState *s = vc->s;GdkWindow *window; +bool allow_hide_cursor = true;if (vc->type !=GD_VC_GFX || !qemu_console_is_graphic (vc->gfx.dcl.con)) {
@@ -257,8 +258,13 @@ static void gd_update_cursor(VirtualConsole *vc)return ; } +if (s->opts->has_show_cursor && s->opts->show_cursor) { + allow_hide_cursor = false; + } + window =gtk_widget_get_window (GTK_WIDGET (vc->gfx.drawing_area)); -if (s->full_screen ||qemu_input_is_absolute () || s->ptr_owner == vc) { +if (allow_hide_cursor && + (s->full_screen ||qemu_input_is_absolute () || s->ptr_owner == vc)) {gdk_window_set_cursor (window, s->null_cursor); }else {gdk_window_set_cursor (window,NULL );
Signature · 1 line
2.18.1
Re: [PATCH 2/5] ui/gtk: implement show-cursor option
Quoted 5 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>---
ui/gtk.c| 8 +++++++-1 file changed, 7 insertions(+), 1 deletion(-)
Jano
PATCH 3/5 ui/sdl: implement show-cursor option
In reply to Gerd Hoffmann--- ui/sdl2.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
ui/sdl2.c +20 -8
@@ -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;
Signature · 1 line
2.18.1
Re: [PATCH 3/5] ui/sdl: implement show-cursor option
Quoted 5 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>---
ui/sdl2.c| 28 ++++++++++++++++++++--------1 file changed, 20 insertions(+), 8 deletions(-)
Jano
PATCH 4/5 ui: wire up legacy -show-cursor option
In reply to Gerd Hoffmann--- include/sysemu/sysemu.h | 1 - vl.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
include/sysemu/sysemu.h +0 -1
@@ -42,7 +42,6 @@ extern const char *keyboard_layout;extern int win2k_install_hack;extern int alt_grab;extern int ctrl_grab; -extern int cursor_hide;extern int graphic_rotate;extern int no_quit;extern int no_shutdown;
vl.c +2 -2
@@ -168,7 +168,6 @@ int no_hpet = 0;int fd_bootchk =1 ;static int no_reboot;int no_shutdown =0 ; -int cursor_hide =1 ;int graphic_rotate =0 ;const char *watchdog;QEMUOptionRom option_rom[MAX_OPTION_ROMS ];
@@ -3553,7 +3552,8 @@ int main(int argc, char **argv, char **envp) no_shutdown =1 ;break ;case QEMU_OPTION_show_cursor: - cursor_hide =0 ; + dpy.has_show_cursor = true; + dpy.show_cursor = true;break ;case QEMU_OPTION_uuid:if (qemu_uuid_parse (optarg, &qemu_uuid) <0 ) {
Signature · 1 line
2.18.1
Re: [PATCH 4/5] ui: wire up legacy -show-cursor option
Quoted 12 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>---
include/sysemu/sysemu.h| 1 -vl.c| 4 ++--2 files changed, 2 insertions(+), 3 deletions(-)vl.c +0
-0
vl.c int main(int argc, char **argv, char **envp) · line 3556
Quoted 4 lines
vl.c +0
-1@@ -3553,7 +3552,8 @@ int main(int argc, char **argv, char **envp) no_shutdown =1 ;break ;case QEMU_OPTION_show_cursor: - cursor_hide =0 ;
Since commit 13aefd303cf996c2d183e94082413885bf1d15bf cursor_hide is also used in ui/cocoa.m
Jano
Quoted 9 lines
vl.c +2
-0+ dpy.has_show_cursor = true; + dpy.show_cursor = true;break ;case QEMU_OPTION_uuid:if (qemu_uuid_parse (optarg, &qemu_uuid) <0 ) {Signature · 1 line
2.18.1
PATCH 5/5 ui: deprecate legacy -show-cursor option
In reply to Gerd Hoffmann--- vl.c | 2 ++ qemu-deprecated.texi | 5 +++++ 2 files changed, 7 insertions(+)
vl.c +2 -0
@@ -3552,6 +3552,8 @@ int main(int argc, char **argv, char **envp) no_shutdown =1 ;break ;case QEMU_OPTION_show_cursor: +warn_report ("The -show-cursor option is deprecated, " +"use -display {sdl,gtk},show-cursor=on instead" ); dpy.has_show_cursor = true; dpy.show_cursor = true;break ;
qemu-deprecated.texi +5 -0
@@ -148,6 +148,11 @@ QEMU 5.0 introduced an alternative syntax to specify the size of the translation block cache, @option{-accel tcg,tb-size=}. The new syntax deprecates the previously available @option{-tb-size} option. +@subsection -show-cursor option (since 5.0) + +Use @option{-display sdl,show-cursor=on} or + @option{-display gtk,show-cursor=on} instead. + @section QEMU Machine Protocol (QMP) commands @subsection change (since 2.5.0)
Signature · 1 line
2.18.1
Re: [PATCH 5/5] ui: deprecate legacy -show-cursor option
Quoted 6 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>---
vl.c| 2 ++
qemu-deprecated.texi | 5 +++++2 files changed, 7 insertions(+)
libvirt does not use -show-cursor
Jano