[Spice-devel] [spice-gtk] mouse: Fix pointer grabbing in server mode
Christophe Fergeau
cfergeau at redhat.com
Mon Aug 8 15:23:53 UTC 2016
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 unexpected grab-broken event happening, we call
gdk_pointer_grab() on the SpiceDisplay GdkWindow, and then we receive a
grab-broken event coming from the same window, which the code does not
expect (see gtk+ bug https://bugzilla.gnome.org/show_bug.cgi?id=769635
).
This commit detects such situations, and ignore the spurious grab-broken
event.
---
src/spice-widget.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 7c1c756..4b0acd2 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -462,8 +462,15 @@ 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 unwanted grab-broken event */
+ return false;
+ }
if (event->keyboard) {
try_keyboard_ungrab(self);
--
2.7.4
More information about the Spice-devel
mailing list