[v3,5/7] ui/gtk: implement show-cursor option
diff mbox series

Message ID 20200207101753.25812-6-kraxel@redhat.com
State New
Headers show
Series
  • ui: rework -show-cursor option
Related show

Commit Message

Gerd Hoffmann Feb. 7, 2020, 10:17 a.m. UTC
When specified just set null_cursor to NULL so we get the default
pointer instead of a blank pointer.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Joshua Watt Feb. 7, 2020, 2:37 p.m. UTC | #1
On 2/7/20 4:17 AM, Gerd Hoffmann wrote:
> When specified just set null_cursor to NULL so we get the default
> pointer instead of a blank pointer.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   ui/gtk.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/ui/gtk.c b/ui/gtk.c
> index d18892d1de61..a685d1ae0848 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -2243,8 +2243,12 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
>       textdomain("qemu");
>   
>       window_display = gtk_widget_get_display(s->window);
> -    s->null_cursor = gdk_cursor_new_for_display(window_display,
> -                                                GDK_BLANK_CURSOR);
> +    if (s->opts->has_show_cursor && s->opts->show_cursor) {
> +        s->null_cursor = NULL; /* default pointer */
> +    } else {
> +        s->null_cursor = gdk_cursor_new_for_display(window_display,
> +                                                    GDK_BLANK_CURSOR);
> +    }

I think it would make more sense to have all the logic related to what 
cursor is used in the same location, instead of split up between here 
and gd_update_cursor(). This would also match the behavior of the SDL 
and cocoa backends a little better.

>   
>       s->mouse_mode_notifier.notify = gd_mouse_mode_change;
>       qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
Gerd Hoffmann Feb. 12, 2020, 11:57 a.m. UTC | #2
> > +    if (s->opts->has_show_cursor && s->opts->show_cursor) {
> > +        s->null_cursor = NULL; /* default pointer */
> > +    } else {
> > +        s->null_cursor = gdk_cursor_new_for_display(window_display,
> > +                                                    GDK_BLANK_CURSOR);
> > +    }
> 
> I think it would make more sense to have all the logic related to what
> cursor is used in the same location, instead of split up between here and
> gd_update_cursor().

Note that it isn't that simple.  There are a few more places in
gd_grab_*() which use s->null_cursor and would need adaption.

cheers,
  Gerd

Patch
diff mbox series

diff --git a/ui/gtk.c b/ui/gtk.c
index d18892d1de61..a685d1ae0848 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2243,8 +2243,12 @@  static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
     textdomain("qemu");
 
     window_display = gtk_widget_get_display(s->window);
-    s->null_cursor = gdk_cursor_new_for_display(window_display,
-                                                GDK_BLANK_CURSOR);
+    if (s->opts->has_show_cursor && s->opts->show_cursor) {
+        s->null_cursor = NULL; /* default pointer */
+    } else {
+        s->null_cursor = gdk_cursor_new_for_display(window_display,
+                                                    GDK_BLANK_CURSOR);
+    }
 
     s->mouse_mode_notifier.notify = gd_mouse_mode_change;
     qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);