[Spice-devel] [PATCH spice-gtk 1/3] Correctly hide client pointer (in server mode)

Marc-André Lureau marcandre.lureau at gmail.com
Fri Dec 9 06:59:32 PST 2011


The hide cursor event happen when the widget is not yet
realized. Forcing realize may fail if the widget is not yet embedded
for example. Instead, let's update the cursor whenever there is a
draw().

v2: do not call gdk_window_set_cursor() with the same cursor
---
 gtk/spice-widget.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index d6a8602..07fb677 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -556,11 +556,13 @@ static void update_mouse_pointer(SpiceDisplay *display)
 
     switch (d->mouse_mode) {
     case SPICE_MOUSE_MODE_CLIENT:
-        gdk_window_set_cursor(window, d->mouse_cursor);
+        if (gdk_window_get_cursor(window) != d->mouse_cursor)
+            gdk_window_set_cursor(window, d->mouse_cursor);
         break;
     case SPICE_MOUSE_MODE_SERVER:
         if (!d->mouse_grab_active) {
-            gdk_window_set_cursor(window, NULL);
+            if (gdk_window_get_cursor(window) == NULL)
+                gdk_window_set_cursor(window, NULL);
         } else {
             try_mouse_grab(display);
         }
@@ -751,6 +753,7 @@ static gboolean draw_event(GtkWidget *widget, cairo_t *cr)
     }
 
     spicex_draw_event(display, cr);
+    update_mouse_pointer(display);
 
     return true;
 }
@@ -769,6 +772,8 @@ static gboolean expose_event(GtkWidget *widget, GdkEventExpose *expose)
     }
 
     spicex_expose_event(display, expose);
+    update_mouse_pointer(display);
+
     return true;
 }
 #endif
-- 
1.7.7.3



More information about the Spice-devel mailing list