From: Olivier Fourdan <ofour...@redhat.com>

The Spice Gtk widget relies on pointer grabs to receive all pointer
events even after the pointer has left the window.

While that works on X11, on Wayland there is no active pointer grab,
so once the pointer has left the SPICE widget on Wayland, the events
are routed to the window with the pointer focus instead of ours.

To avoid the problem, on Wayland, we simply ungrab the pointer once it
leaves the window.

Thanks-to: Peter Hutterer <peter.hutte...@who-t.net>
Signed-off-by: Olivier Fourdan <ofour...@redhat.com>
https://gitlab.freedesktop.org/spice/spice-gtk/issues/83
---
 src/spice-widget.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/spice-widget.c b/src/spice-widget.c
index fd0c935..d924731 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -1854,8 +1854,21 @@ static gboolean leave_event(GtkWidget *widget, 
GdkEventCrossing *crossing G_GNUC
 
     DISPLAY_DEBUG(display, "%s", __FUNCTION__);
 
-    if (d->mouse_grab_active)
+    if (d->mouse_grab_active) {
+#ifdef GDK_WINDOWING_WAYLAND
+        /* On Wayland, there is no active pointer grab, so once the pointer
+         * has left the window, the events are routed to the window with
+         * pointer focus instead of ours, in which case we should just
+         * ungrab to avoid nasty side effects. */
+        if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())) {
+            GdkWindow *window = gtk_widget_get_window(widget);
+
+            if (window == crossing->window)
+                try_mouse_ungrab(display);
+        }
+#endif
         return true;
+    }
 
     d->mouse_have_pointer = false;
     spice_gtk_session_set_mouse_has_pointer(d->gtk_session, false);
-- 
2.20.1

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to