From a668d91e28d5a3042a8ce0d087474883b046869a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 9 Mar 2009 16:36:07 +1000 Subject: [PATCH] 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. --- dix/events.c | 22 ++++++++++++++++++++-- dix/grabs.c | 2 +- include/inputstr.h | 2 ++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/dix/events.c b/dix/events.c index 52729cad6..d4eea2c44 100644 --- a/dix/events.c +++ b/dix/events.c @@ -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 */ diff --git a/dix/grabs.c b/dix/grabs.c index 164e200ce..156574efe 100644 --- a/dix/grabs.c +++ b/dix/grabs.c @@ -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); diff --git a/include/inputstr.h b/include/inputstr.h index 678c171c5..59fb29bf0 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -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 {