[Spice-devel] [spice-gtk] mouse: Fix pointer grabbing in server mode

Frediano Ziglio fziglio at redhat.com
Mon Aug 8 15:48:37 UTC 2016


> 
> Hi,
> 
> On Mon, Aug 08, 2016 at 05:23:53PM +0200, Christophe Fergeau wrote:
> > 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
> > ).
> 
> Looks good, just tested with windows 7 guest and it works fine.
> Acked-by: Victor Toso <victortoso at redhat.com>
> 

I would add a comment in the code with a link to Gdk+ bug so can be
easier detected and removed in the future.

Frediano

> > 
> > 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);



More information about the Spice-devel mailing list