diff --git a/Xi/exevents.c b/Xi/exevents.c index 98c28851c..2e9e8267f 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -126,6 +126,9 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count) ValuatorClassPtr v = device->valuator; deviceValuator *xV = (deviceValuator *) xE; + if (grab && grab->coreGrab && !device->deviceGrab.fromPassiveGrab) + return; + if (xE->u.u.type != DeviceValuator && xE->u.u.type != GenericEvent) { DeviceIntPtr mouse = NULL, kbd = NULL; GetSpritePosition(device, &rootX, &rootY); diff --git a/dix/events.c b/dix/events.c index 9dddf2c46..ba1463a01 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1839,6 +1839,10 @@ TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask, * Deliver events to a window. At this point, we do not yet know if the event * actually needs to be delivered. May activate a grab if the event is a * button press. + * + * Core events are always delivered to the window owner. If the filter is + * something other than CantBeFiltered, the event is also delivered to other + * clients with the matching mask on the window. * * More than one event may be delivered at a time. This is the case with * DeviceMotionNotifies which may be followed by DeviceValuator events. @@ -1964,6 +1968,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent if ((type == ButtonPress) && deliveries && (!grab)) { GrabRec tempGrab; + OtherInputMasks *inputMasks; tempGrab.device = pDev; tempGrab.resource = client->clientAsMask; @@ -1975,6 +1980,11 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent tempGrab.confineTo = NullWindow; tempGrab.cursor = NullCursor; tempGrab.coreGrab = True; + + /* get the XI device mask */ + inputMasks = wOtherInputMasks(pWin); + tempGrab.deviceMask = (inputMasks) ? inputMasks->inputEvents[pDev->id]: 0; + tempGrab.genericMasks = NULL; (*inputInfo.pointer->deviceGrab.ActivateGrab)(pDev, &tempGrab, currentTime, TRUE); @@ -3221,10 +3231,14 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev, grab); } else { + Mask mask = grab->eventMask; + if (grabinfo->fromPassiveGrab && (xE->u.u.type & + EXTENSION_EVENT_BASE)) + mask = grab->deviceMask; + FixUpEventFromWindow(thisDev, xE, grab->window, None, TRUE); deliveries = TryClientEvents(rClient(grab), xE, count, - (Mask)grab->eventMask, - filters[xE->u.u.type], grab); + mask, filters[xE->u.u.type], grab); } if (deliveries && (xE->u.u.type == MotionNotify #ifdef XINPUT @@ -5716,7 +5730,8 @@ IsInterferingGrab(ClientPtr client, DeviceIntPtr dev, xEvent* event) { if (it != dev) { - if (it->deviceGrab.grab && SameClient(it->deviceGrab.grab, client)) + if (it->deviceGrab.grab && SameClient(it->deviceGrab.grab, client) + && !it->deviceGrab.fromPassiveGrab) { return TRUE; } diff --git a/include/inputstr.h b/include/inputstr.h index a53588461..986232c79 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -117,6 +117,9 @@ typedef struct _GenericMaskRec { * ButtonPressMask). * If the grab is a device grab (GrabDevice), then the eventMask is a * combination of event masks for a given XI event type (see SetEventInfo). + * + * If the grab is a result of a ButtonPress, then eventMask is the core mask + * and deviceMask is set to the XI event mask for the grab. */ typedef struct _GrabRec { GrabPtr next; /* for chain of passive grabs */ @@ -135,6 +138,7 @@ typedef struct _GrabRec { WindowPtr confineTo; /* always NULL for keyboards */ CursorPtr cursor; /* always NULL for keyboards */ Mask eventMask; + Mask deviceMask; GenericMaskPtr genericMasks; /* null terminated list */ } GrabRec;