[Spice-commits] 3 commits - gtk/spice-gtk-session.c gtk/spice-gtk-session-priv.h gtk/spice-widget.c gtk/spice-widget-cairo.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Tue Nov 4 05:12:36 PST 2014


 gtk/spice-gtk-session-priv.h |    2 ++
 gtk/spice-gtk-session.c      |   39 +++++++++++++++++++++++++++++++++++++++
 gtk/spice-widget-cairo.c     |    4 +++-
 gtk/spice-widget.c           |    8 +++++---
 4 files changed, 49 insertions(+), 4 deletions(-)

New commits:
commit 8f64e766f2ddf9128da4efe3f107a5c8c2716116
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Mon Nov 3 13:51:09 2014 +0100

    Draw server-side pointer when the session has the grab
    
    If there are several SpiceDisplay widgets, only one will have the grab,
    but the pointer may need to be drawn on another of the displays.  We
    thus need to track the grab status on SpiceSession, not just
    per-display.
    
    This solves the following bug:
    https://bugs.freedesktop.org/show_bug.cgi?id=38024

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 62a98dc..ae11073 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);
@@ -896,8 +899,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:
@@ -1017,9 +1020,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)
commit 1032b94fd3c8597562fd029730b1f5590a3f8a72
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Mon Nov 3 13:50:43 2014 +0100

    gtk-session: add pointer-grabbed property
    
    Returns TRUE if the pointer is currently grabbed by this session.

diff --git a/gtk/spice-gtk-session-priv.h b/gtk/spice-gtk-session-priv.h
index 48482b6..91304b2 100644
--- a/gtk/spice-gtk-session-priv.h
+++ b/gtk/spice-gtk-session-priv.h
@@ -26,6 +26,8 @@ void spice_gtk_session_request_auto_usbredir(SpiceGtkSession *self,
                                              gboolean state);
 gboolean spice_gtk_session_get_read_only(SpiceGtkSession *self);
 void spice_gtk_session_sync_keyboard_modifiers(SpiceGtkSession *self);
+void spice_gtk_session_set_pointer_grabbed(SpiceGtkSession *self, gboolean grabbed);
+gboolean spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self);
 
 G_END_DECLS
 
diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 85872c4..52ad597 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -63,6 +63,7 @@ struct _SpiceGtkSessionPrivate {
     /* auto-usbredir related */
     gboolean                auto_usbredir_enable;
     int                     auto_usbredir_reqs;
+    gboolean                pointer_grabbed;
 };
 
 /**
@@ -115,6 +116,7 @@ enum {
     PROP_SESSION,
     PROP_AUTO_CLIPBOARD,
     PROP_AUTO_USBREDIR,
+    PROP_POINTER_GRABBED,
 };
 
 static guint32 get_keyboard_lock_modifiers(void)
@@ -311,6 +313,9 @@ static void spice_gtk_session_get_property(GObject    *gobject,
     case PROP_AUTO_USBREDIR:
         g_value_set_boolean(value, s->auto_usbredir_enable);
         break;
+    case PROP_POINTER_GRABBED:
+        g_value_set_boolean(value, s->pointer_grabbed);
+        break;
     default:
 	G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
 	break;
@@ -430,6 +435,22 @@ static void spice_gtk_session_class_init(SpiceGtkSessionClass *klass)
                               G_PARAM_CONSTRUCT |
                               G_PARAM_STATIC_STRINGS));
 
+    /**
+     * SpiceGtkSession:pointer-grabbed:
+     *
+     * Returns %TRUE if the pointer is currently grabbed by this session.
+     *
+     * Since: 0.27
+     **/
+    g_object_class_install_property
+        (gobject_class, PROP_POINTER_GRABBED,
+         g_param_spec_boolean("pointer-grabbed",
+                              "Pointer grabbed",
+                              "Whether the pointer is grabbed",
+                              FALSE,
+                              G_PARAM_READABLE |
+                              G_PARAM_STATIC_STRINGS));
+
     g_type_class_add_private(klass, sizeof(SpiceGtkSessionPrivate));
 }
 
@@ -1157,3 +1178,20 @@ void spice_gtk_session_sync_keyboard_modifiers(SpiceGtkSession *self)
     }
     g_list_free(channels);
 }
+
+G_GNUC_INTERNAL
+void spice_gtk_session_set_pointer_grabbed(SpiceGtkSession *self, gboolean grabbed)
+{
+    g_return_if_fail(SPICE_IS_GTK_SESSION(self));
+
+    self->priv->pointer_grabbed = grabbed;
+    g_object_notify(G_OBJECT(self), "pointer-grabbed");
+}
+
+G_GNUC_INTERNAL
+gboolean spice_gtk_session_get_pointer_grabbed(SpiceGtkSession *self)
+{
+    g_return_val_if_fail(SPICE_IS_GTK_SESSION(self), FALSE);
+
+    return self->priv->pointer_grabbed;
+}
commit d80eb6a76f857af56be8b71c4560169109ee783d
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Mon Nov 3 13:49:30 2014 +0100

    Add missing G_GNUC_INTERNAL
    
    Trivial fix

diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 10bd762..85872c4 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -1144,6 +1144,7 @@ void spice_gtk_session_paste_from_guest(SpiceGtkSession *self)
     s->clip_hasdata[selection] = FALSE;
 }
 
+G_GNUC_INTERNAL
 void spice_gtk_session_sync_keyboard_modifiers(SpiceGtkSession *self)
 {
     GList *l = NULL, *channels = spice_session_get_channels(self->priv->session);


More information about the Spice-commits mailing list