[Spice-devel] [PATCH spice-gtk 2/2] Draw server-side pointer when the session as the grab

Marc-André Lureau marcandre.lureau at gmail.com
Mon Nov 3 04:56:31 PST 2014


Even when the pointer is grabbed by a widget, it may be drawn on
another. We need to track the grab status on the session.

This solves the following bug:
https://bugs.freedesktop.org/show_bug.cgi?id=38024
---
 gtk/spice-widget-cairo.c | 4 +++-
 gtk/spice-widget.c       | 8 +++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gtk/spice-widget-cairo.c b/gtk/spice-widget-cairo.c
index 05d708f..96af076 100644
--- a/gtk/spice-widget-cairo.c
+++ b/gtk/spice-widget-cairo.c
@@ -20,6 +20,7 @@
 #include "gtk-compat.h"
 #include "spice-widget.h"
 #include "spice-widget-priv.h"
+#include "spice-gtk-session-priv.h"
 
 
 G_GNUC_INTERNAL
@@ -118,7 +119,8 @@ void spicex_draw_event(SpiceDisplay *display, cairo_t *cr)
 
         if (d->mouse_mode == SPICE_MOUSE_MODE_SERVER &&
             d->mouse_guest_x != -1 && d->mouse_guest_y != -1 &&
-            !d->show_cursor && d->mouse_grab_active) {
+            !d->show_cursor &&
+            spice_gtk_session_get_pointer_grabbed(d->gtk_session)) {
             GdkPixbuf *image = d->mouse_pixbuf;
             if (image != NULL) {
                 gdk_cairo_set_source_pixbuf(cr, image,
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 2f51e6e..32db5b6 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -321,6 +321,9 @@ static void spice_display_set_property(GObject      *object,
         g_warn_if_fail(d->session == NULL);
         d->session = g_value_dup_object(value);
         d->gtk_session = spice_gtk_session_get(d->session);
+        spice_g_signal_connect_object(d->gtk_session, "notify::pointer-grabbed",
+                                      G_CALLBACK(cursor_invalidate), object,
+                                      G_CONNECT_SWAPPED);
         break;
     case PROP_CHANNEL_ID:
         d->channel_id = g_value_get_int(value);
@@ -900,8 +903,8 @@ static GdkGrabStatus do_pointer_grab(SpiceDisplay *display)
     } else {
         d->mouse_grab_active = true;
         g_signal_emit(display, signals[SPICE_DISPLAY_MOUSE_GRAB], 0, true);
+        spice_gtk_session_set_pointer_grabbed(d->gtk_session, true);
         set_mouse_accel(display, FALSE);
-        gtk_widget_queue_draw(GTK_WIDGET(display));
     }
 
 end:
@@ -1021,9 +1024,8 @@ static void try_mouse_ungrab(SpiceDisplay *display)
                              gtk_widget_get_screen(GTK_WIDGET(display)),
                              x, y);
 
-    gtk_widget_queue_draw(GTK_WIDGET(display));
-
     g_signal_emit(display, signals[SPICE_DISPLAY_MOUSE_GRAB], 0, false);
+    spice_gtk_session_set_pointer_grabbed(d->gtk_session, false);
 }
 
 static void update_mouse_grab(SpiceDisplay *display)
-- 
1.9.3



More information about the Spice-devel mailing list