[Spice-commits] src/spice-widget.c

Christophe Fergau teuf at kemper.freedesktop.org
Fri Aug 26 18:57:30 UTC 2016


 src/spice-widget.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

New commits:
commit 951c21d01712cd309239a94fb883e0fda1bf6a42
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Mon Aug 8 17:19:29 2016 +0200

    mouse: Fix pointer grabbing in server mode
    
    Trying to click on spice-gtk window while in server mode should result
    in a pointer grab. This is currently failing, with the cursor wrapping
    to the top left corner of the window instead without being grabbed.
    
    This is caused by our use of gtk_event_box_set_above_child(),
    when clicking on the SpiceWidget, the grab is implicitly taken by
    the window which is above the event box (which is an internal
    GtkEventBox input-only GdkWindow). Then when we call gdk_pointer_grab()
    on the GtkEventBox::window, we get a grab-broken event indicating the
    grab was transferred from the internal input-only window to
    GtkEventBox::window (see gtk+ bug
    https://bugzilla.gnome.org/show_bug.cgi?id=769635#c2 for a detailed
    explanation).
    
    This commit ignores grab-broken events when the GdkWindow who got the
    grab corresponds to the one we called gdk_pointer_grab() on.
    An alternative would be to call gdk_pointer_grab() on the GdkWindow
    which received the button-press-event, but the call chain between
    button_event() and the eventual gdk_pointer_grab() call, so it would be
    not so elegant to pass the correct GdkWindow all the way.

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 67e66b7..9c8f7d1 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -472,8 +472,19 @@ static GdkCursor* get_blank_cursor(void)
 static gboolean grab_broken(SpiceDisplay *self, GdkEventGrabBroken *event,
                             gpointer user_data G_GNUC_UNUSED)
 {
+    GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(self));
     SPICE_DEBUG("%s (implicit: %d, keyboard: %d)", __FUNCTION__,
                 event->implicit, event->keyboard);
+    SPICE_DEBUG("%s (SpiceDisplay::GdkWindow %p, event->grab_window: %p)",
+                __FUNCTION__, window, event->grab_window);
+    if (window == event->grab_window) {
+        /* ignore grab-broken event moving the grab to GtkEventBox::window
+         * (from GtkEventBox::event_window) as we initially called
+         * gdk_pointer_grab() on GtkEventBox::window, see
+         * https://bugzilla.gnome.org/show_bug.cgi?id=769635
+         */
+        return false;
+    }
 
     if (event->keyboard) {
         try_keyboard_ungrab(self);


More information about the Spice-commits mailing list