[PATCH 2/2] dix: Use XINotifyPassiveGrab/Ungrab on button passive grab crossings

Peter Hutterer peter.hutterer at who-t.net
Mon Dec 2 16:57:11 PST 2013


On Tue, Nov 26, 2013 at 02:07:06PM +1000, Peter Hutterer wrote:
> On Mon, Nov 25, 2013 at 06:14:38PM +0100, carlosg at gnome.org wrote:
> > From: Carlos Garnacho <carlosg at gnome.org>
> > 
> > XI2 clients were getting crossing events with XINotifyGrab/Ungrab modes
> > whenever a passive button grab was triggered, even though XI2 provides
> > XINotifyPassiveGrab/Ungrab for these situations. Fix this by setting
> > the right XI2 mode when that happens, DoEnterLeaveEvents will conveniently
> > transform it to the right mode for Core events when those are emitted.
> > 
> > https://bugs.freedesktop.org/show_bug.cgi?id=71762
> > 
> > Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
> > ---
> >  dix/events.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/dix/events.c b/dix/events.c
> > index 9260b45..6c83504 100644
> > --- a/dix/events.c
> > +++ b/dix/events.c
> > @@ -1530,7 +1530,8 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab,
> >                  mouse->spriteInfo->sprite->hotPhys.y = 0;
> >          ConfineCursorToWindow(mouse, grab->confineTo, FALSE, TRUE);
> >      }
> > -    DoEnterLeaveEvents(mouse, mouse->id, oldWin, grab->window, NotifyGrab,
> > +    DoEnterLeaveEvents(mouse, mouse->id, oldWin, grab->window,
> > +                       isPassive ? XINotifyPassiveGrab : XINotifyGrab,
> >                         EVENT_CORE_MASK | EVENT_XI2_MASK);
> >      mouse->valuator->motionHintWindow = NullWindow;
> >      if (syncEvents.playingEvents)
> > @@ -1598,7 +1599,8 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
> >              dev->deviceGrab.sync.other = NullGrab;
> >      }
> >      DoEnterLeaveEvents(mouse, mouse->id, grab->window,
> > -                       mouse->spriteInfo->sprite->win, NotifyUngrab,
> > +                       mouse->spriteInfo->sprite->win,
> > +                       wasPassive ? XINotifyPassiveUngrab : XINotifyUngrab,
> >                         EVENT_CORE_MASK | EVENT_XI2_MASK);
> >      if (grab->confineTo)
> >          ConfineCursorToWindow(mouse, GetCurrentRootWindow(mouse), FALSE, FALSE);
> > -- 
> > 1.8.4.2
> 
> both merged, thanks.

tried writing a test for this and I don't think we can merge this. The specs
explicitly say:

    If an enter or focus in grab activates, additional EnterNotify events
    with mode XIPassiveGrabNotify are generated as if the pointer
    or focus were to suddenly warp from its current position to some
    position in the grab window.  These events are sent to the grabbing
    client only and only if the grab event mask has selected for it. If such
    a passive grab deactivates, addional LeaveNotify events with mode
    XIPassiveUngrabNotify are generated and sent to the grabbing
    client before the grab deactivates.

And the "mode" field in the Enter/Leave events also state this is only valid
for enter/focus_in grabs. I'm trying to remember _why_ but it's a bit hazy,
tbh. I think the main reason was that for button/keyboard grabs you get an
event anyway, but for enter/leave grabs you need an explicit notification
that this triggered a grab (i.e. the XINotifyPassiveGrab enter event is the
equivalent to the ButtonPress you'd get for a button grab).

also, fwiw, the quite simple test I wrote (before reading the specs, of
course :) to test if the events are being sent but failed to receive
enter/leave events on either client, so there's something else broken with
enter/leave events during grabs.

Cheers,
   Peter


More information about the xorg-devel mailing list