dix: store the xi2mask on grabs and pass it around as needed.

This enables passive and implicit passive grabs for XI2 events, except that we
don't have the protocol spec yet to request them.
This commit is contained in:
Peter Hutterer 2009-03-09 16:36:07 +10:00
parent 32f338263f
commit a668d91e28
3 changed files with 23 additions and 3 deletions

View File

@ -2040,7 +2040,8 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
* Note that since core events are delivered first, an implicit grab may
* be activated on a core grab, stopping the XI events.
*/
if ((type == DeviceButtonPress || type == ButtonPress)
if ((type == DeviceButtonPress || type == ButtonPress ||
((XI2_EVENT(pEvents) && ((xGenericEvent*)pEvents)->evtype == XI_ButtonPress)))
&& deliveries
&& (!grab))
{
@ -2059,10 +2060,14 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
tempGrab.cursor = NullCursor;
tempGrab.coreGrab = (type == ButtonPress);
/* get the XI device mask */
/* get the XI and XI2 device mask */
inputMasks = wOtherInputMasks(pWin);
tempGrab.deviceMask = (inputMasks) ? inputMasks->inputEvents[pDev->id]: 0;
if (inputMasks)
memcpy(tempGrab.xi2mask, inputMasks->xi2mask,
sizeof(tempGrab.xi2mask));
(*pDev->deviceGrab.ActivateGrab)(pDev, &tempGrab,
currentTime, TRUE | ImplicitGrabMask);
}
@ -3695,6 +3700,19 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
}
}
if (!deliveries)
{
int evtype = ((xGenericEvent*)xi2)->evtype;
mask = grab->xi2mask[AllDevices][evtype/8] |
grab->xi2mask[AllMasterDevices][evtype/8] |
grab->xi2mask[thisDev->id][evtype/8];
/* try XI2 event */
FixUpEventFromWindow(thisDev, xi2, grab->window, None, TRUE);
/* XXX: XACE */
deliveries = TryClientEvents(rClient(grab), thisDev, xi2, 1, mask,
GetEventFilter(thisDev, xi2), grab);
}
if (!deliveries)
{
/* try XI event */

View File

@ -82,7 +82,7 @@ CreateGrab(
{
GrabPtr grab;
grab = xalloc(sizeof(GrabRec));
grab = xcalloc(1, sizeof(GrabRec));
if (!grab)
return (GrabPtr)NULL;
grab->resource = FakeClientID(client);

View File

@ -181,6 +181,8 @@ typedef struct _GrabRec {
CursorPtr cursor; /* always NULL for keyboards */
Mask eventMask;
Mask deviceMask;
/* XI2 event masks. One per device, each bit is a mask of (1 << type) */
unsigned char xi2mask[EMASKSIZE][XI2MASKSIZE];
} GrabRec;
typedef struct _KeyClassRec {