From: Dave Airlie <airl...@redhat.com> If the guest asks for no cursor, switch gtk to using the null cursor.
Signed-off-by: Dave Airlie <airl...@redhat.com> --- ui/gtk.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 2abf289..f60e66f 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -158,6 +158,8 @@ typedef struct GtkDisplayState bool external_pause_update; bool modifier_pressed[ARRAY_SIZE(modifier_keycode)]; + + GdkCursor *current_cursor; } GtkDisplayState; static GtkDisplayState *global_state; @@ -338,6 +340,11 @@ static void gd_mouse_set(DisplayChangeListener *dcl, GdkDeviceManager *mgr; gint x_root, y_root; + if (!visible) + gdk_window_set_cursor(gtk_widget_get_window(s->drawing_area), s->null_cursor); + else + gdk_window_set_cursor(gtk_widget_get_window(s->drawing_area), s->current_cursor); + if (kbd_mouse_is_absolute()) return; @@ -369,21 +376,23 @@ static void gd_cursor_define(DisplayChangeListener *dcl, { GtkDisplayState *s = container_of(dcl, GtkDisplayState, dcl); GdkPixbuf *pixbuf; - GdkCursor *cursor; + + if (s->current_cursor) { +#if !GTK_CHECK_VERSION(3, 0, 0) + gdk_cursor_unref(s->current_cursor); +#else + g_object_unref(s->current_cursor); +#endif + s->current_cursor = NULL; + } pixbuf = gdk_pixbuf_new_from_data((guchar *)(c->data), GDK_COLORSPACE_RGB, true, 8, c->width, c->height, c->width * 4, NULL, NULL); - cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(s->drawing_area), + s->current_cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(s->drawing_area), pixbuf, c->hot_x, c->hot_y); - gdk_window_set_cursor(gtk_widget_get_window(s->drawing_area), cursor); g_object_unref(pixbuf); -#if !GTK_CHECK_VERSION(3, 0, 0) - gdk_cursor_unref(cursor); -#else - g_object_unref(cursor); -#endif } static void gd_switch(DisplayChangeListener *dcl, -- 1.8.3.1