Fix mouse pointer grab

remotes/origin/f24
Victor Toso 2016-11-08 08:51:38 +01:00
parent 62fd231a2e
commit 66234dde72
2 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,53 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau@redhat.com>
Date: Mon, 8 Aug 2016 17:19:29 +0200
Subject: [PATCH] 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.
---
src/spice-widget.c | 11 +++++++++++
1 file changed, 11 insertions(+)
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);

View File

@ -2,7 +2,7 @@
Name: spice-gtk Name: spice-gtk
Version: 0.32 Version: 0.32
Release: 4%{?dist} Release: 5%{?dist}
Summary: A GTK+ widget for SPICE clients Summary: A GTK+ widget for SPICE clients
Group: System Environment/Libraries Group: System Environment/Libraries
@ -18,6 +18,7 @@ Patch5: 0005-util-fix-off-by-one-array-access.patch
Patch6: 0006-spice-widget-init-egl-only-after-first-gl_scanout.patch Patch6: 0006-spice-widget-init-egl-only-after-first-gl_scanout.patch
Patch7: 0007-spicy-only-watch-stdin-if-testing-org.spice.spicy-po.patch Patch7: 0007-spicy-only-watch-stdin-if-testing-org.spice.spicy-po.patch
Patch8: 0008-spicy-fix-reset-of-terminal-when-quit.patch Patch8: 0008-spicy-fix-reset-of-terminal-when-quit.patch
Patch9: 0009-mouse-Fix-pointer-grabbing-in-server-mode.patch
BuildRequires: intltool BuildRequires: intltool
BuildRequires: usbredir-devel >= 0.5.2 BuildRequires: usbredir-devel >= 0.5.2
@ -192,6 +193,9 @@ rm -f %{buildroot}%{_libdir}/*.la
%{_bindir}/spicy-stats %{_bindir}/spicy-stats
%changelog %changelog
* Tue Nov 8 2016 Victor Toso <victortoso@redhat.com> - 0.32-5
- Fix mouse pointer grabbing
* Mon Oct 10 2016 Marc-André Lureau <marcandre.lureau@redhat.com> - 0.32-4 * Mon Oct 10 2016 Marc-André Lureau <marcandre.lureau@redhat.com> - 0.32-4
- Fix backgrounding spicy causes it to freeze (rhbz#1382328) - Fix backgrounding spicy causes it to freeze (rhbz#1382328)