diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-04-12 16:19:45 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-04-19 22:28:08 +1000 |
commit | 09f9a86077f0058ce88ee9b3df5d1ab854eeca43 (patch) | |
tree | b5a4f3e2fa69551c53fbedda8ce315af12ac80d7 | |
parent | 7fbe1b7d63c94b344e8ff9d09c0bb162ca104909 (diff) |
input: replace GrabRec's coreGrab field with grabtype.
Don't allow grabs of different types to override each other.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | Xi/exevents.c | 6 | ||||
-rw-r--r-- | Xi/ungrdev.c | 2 | ||||
-rw-r--r-- | dix/events.c | 33 | ||||
-rw-r--r-- | dix/grabs.c | 7 | ||||
-rw-r--r-- | include/dix.h | 2 | ||||
-rw-r--r-- | include/dixgrabs.h | 1 | ||||
-rw-r--r-- | include/inputstr.h | 8 |
7 files changed, 38 insertions, 21 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index 3be5c46ef..991beca9b 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1415,7 +1415,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, grab = CreateGrab(client->index, dev, pWin, eventMask, (Bool) ownerEvents, (Bool) this_device_mode, (Bool) other_devices_mode, modifier_device, modifiers, - DeviceButtonPress, button, confineTo, cursor); + DeviceButtonPress, GRABTYPE_XI, button, confineTo, cursor); if (!grab) return BadAlloc; return AddPassiveGrabToList(client, grab); @@ -1470,8 +1470,8 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, grab = CreateGrab(client->index, dev, pWin, mask, ownerEvents, this_device_mode, other_devices_mode, - modifier_device, modifiers, DeviceKeyPress, key, - NullWindow, NullCursor); + modifier_device, modifiers, DeviceKeyPress, GRABTYPE_XI, + key, NullWindow, NullCursor); if (!grab) return BadAlloc; return AddPassiveGrabToList(client, grab); diff --git a/Xi/ungrdev.c b/Xi/ungrdev.c index b5b572a8e..a09c3d024 100644 --- a/Xi/ungrdev.c +++ b/Xi/ungrdev.c @@ -104,7 +104,7 @@ ProcXUngrabDevice(ClientPtr client) time = ClientTimeToServerTime(stuff->time); if ((CompareTimeStamps(time, currentTime) != LATER) && (CompareTimeStamps(time, dev->deviceGrab.grabTime) != EARLIER) && - (grab) && SameClient(grab, client) && !grab->coreGrab) + (grab) && SameClient(grab, client) && grab->grabtype == GRABTYPE_XI) (*dev->deviceGrab.DeactivateGrab) (dev); return Success; } diff --git a/dix/events.c b/dix/events.c index 34ea414e8..dfbc49643 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2057,7 +2057,12 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent tempGrab.pointerMode = GrabModeAsync; tempGrab.confineTo = NullWindow; tempGrab.cursor = NullCursor; - tempGrab.coreGrab = (type == ButtonPress); + if (type == ButtonPress) + tempGrab.grabtype = GRABTYPE_CORE; + else if (type == DeviceButtonPress) + tempGrab.grabtype = GRABTYPE_XI; + else + tempGrab.grabtype = GRABTYPE_XI2; /* get the XI and XI2 device mask */ inputMasks = wOtherInputMasks(pWin); @@ -3298,7 +3303,7 @@ CheckPassiveGrabsOnWindow( XkbSrvInfoPtr xkbi = NULL; gdev= grab->modifierDevice; - if (grab->coreGrab) + if (grab->grabtype == GRABTYPE_CORE) { if (IsPointerDevice(device)) gdev = GetPairedDevice(device); @@ -3351,14 +3356,14 @@ CheckPassiveGrabsOnWindow( * device. */ - if (grab->coreGrab) + if (grab->grabtype == GRABTYPE_CORE) { DeviceIntPtr other; BOOL interfering = FALSE; for (other = inputInfo.devices; other; other = other->next) { GrabPtr othergrab = other->deviceGrab.grab; - if (othergrab && othergrab->coreGrab && + if (othergrab && othergrab->grabtype == GRABTYPE_CORE && SameClient(grab, rClient(othergrab)) && ((IsPointerDevice(grab->device) && IsPointerDevice(othergrab->device)) || @@ -3679,7 +3684,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev, sendCore = (thisDev->isMaster && thisDev->coreEvents); /* try core event */ - if (sendCore && grab->coreGrab) + if (sendCore && grab->grabtype == GRABTYPE_CORE) { xEvent core; @@ -4428,7 +4433,7 @@ ProcGrabPointer(ClientPtr client) rc = GrabDevice(client, device, stuff->pointerMode, stuff->keyboardMode, stuff->grabWindow, stuff->ownerEvents, stuff->time, - stuff->eventMask, TRUE, stuff->cursor, + stuff->eventMask, GRABTYPE_CORE, stuff->cursor, stuff->confineTo, &rep.status); if (rc != Success) return rc; @@ -4547,7 +4552,7 @@ int GrabDevice(ClientPtr client, DeviceIntPtr dev, unsigned pointer_mode, unsigned keyboard_mode, Window grabWindow, unsigned ownerEvents, Time ctime, Mask mask, - Bool coreGrab, Cursor curs, Window confineToWin, CARD8 *status) + int grabtype, Cursor curs, Window confineToWin, CARD8 *status) { WindowPtr pWin, confineTo; GrabPtr grab; @@ -4610,6 +4615,8 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev, time = ClientTimeToServerTime(ctime); grab = grabInfo->grab; + if (grab && grab->grabtype != grabtype) + *status = AlreadyGrabbed; if (grab && !SameClient(grab, client)) *status = AlreadyGrabbed; else if ((!pWin->realized) || @@ -4640,7 +4647,7 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev, tempGrab.device = dev; tempGrab.cursor = cursor; tempGrab.confineTo = confineTo; - tempGrab.coreGrab = coreGrab; + tempGrab.grabtype = grabtype; (*grabInfo->ActivateGrab)(dev, &tempGrab, time, FALSE); *status = GrabSuccess; } @@ -4665,7 +4672,7 @@ ProcGrabKeyboard(ClientPtr client) memset(&rep, 0, sizeof(xGrabKeyboardReply)); result = GrabDevice(client, keyboard, stuff->pointerMode, stuff->keyboardMode, stuff->grabWindow, stuff->ownerEvents, - stuff->time, KeyPressMask | KeyReleaseMask, TRUE, None, None, + stuff->time, KeyPressMask | KeyReleaseMask, GRABTYPE_CORE, None, None, &rep.status); if (result != Success) @@ -4698,7 +4705,7 @@ ProcUngrabKeyboard(ClientPtr client) time = ClientTimeToServerTime(stuff->id); if ((CompareTimeStamps(time, currentTime) != LATER) && (CompareTimeStamps(time, device->deviceGrab.grabTime) != EARLIER) && - (grab) && SameClient(grab, client) && grab->coreGrab) + (grab) && SameClient(grab, client) && grab->grabtype == GRABTYPE_CORE) (*device->deviceGrab.DeactivateGrab)(device); return Success; } @@ -5038,7 +5045,7 @@ ProcGrabKey(ClientPtr client) grab = CreateGrab(client->index, keybd, pWin, (Mask)(KeyPressMask | KeyReleaseMask), (Bool)stuff->ownerEvents, (Bool)stuff->keyboardMode, (Bool)stuff->pointerMode, - keybd, stuff->modifiers, KeyPress, stuff->key, + keybd, stuff->modifiers, KeyPress, GRABTYPE_CORE, stuff->key, NullWindow, NullCursor); if (!grab) return BadAlloc; @@ -5130,7 +5137,7 @@ ProcGrabButton(ClientPtr client) grab = CreateGrab(client->index, ptr, pWin, (Mask)stuff->eventMask, (Bool)stuff->ownerEvents, (Bool) stuff->keyboardMode, (Bool)stuff->pointerMode, - modifierDevice, stuff->modifiers, ButtonPress, + modifierDevice, stuff->modifiers, ButtonPress, GRABTYPE_CORE, stuff->button, confineTo, cursor); if (!grab) return BadAlloc; @@ -5564,7 +5571,7 @@ PickPointer(ClientPtr client) for(it = inputInfo.devices; it; it = it->next) { GrabPtr grab = it->deviceGrab.grab; - if (grab && grab->coreGrab && SameClient(grab, client)) + if (grab && grab->grabtype == GRABTYPE_CORE && SameClient(grab, client)) { if (!IsPointerDevice(it)) it = GetPairedDevice(it); diff --git a/dix/grabs.c b/dix/grabs.c index 2d3327c42..cd34f7e51 100644 --- a/dix/grabs.c +++ b/dix/grabs.c @@ -76,6 +76,7 @@ CreateGrab( DeviceIntPtr modDevice, unsigned short modifiers, int type, + int grabtype, KeyCode keybut, /* key or button */ WindowPtr confineTo, CursorPtr cursor) @@ -87,7 +88,6 @@ CreateGrab( return (GrabPtr)NULL; grab->resource = FakeClientID(client); grab->device = device; - grab->coreGrab = (type < LASTEvent); grab->window = window; grab->eventMask = eventMask; grab->deviceMask = 0; @@ -98,6 +98,7 @@ CreateGrab( grab->modifiersDetail.pMask = NULL; grab->modifierDevice = modDevice; grab->type = type; + grab->grabtype = grabtype; grab->detail.exact = keybut; grab->detail.pMask = NULL; grab->confineTo = confineTo; @@ -411,7 +412,8 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) grab = grab->next) { if ((CLIENT_BITS(grab->resource) != CLIENT_BITS(pMinuendGrab->resource)) || - !GrabMatchesSecond(grab, pMinuendGrab, (grab->coreGrab))) + !GrabMatchesSecond(grab, pMinuendGrab, + (grab->grabtype == GRABTYPE_CORE))) continue; if (GrabSupersedesSecond(pMinuendGrab, grab)) { @@ -442,6 +444,7 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) (Bool)grab->pointerMode, grab->modifierDevice, AnyModifier, (int)grab->type, + grab->grabtype, pMinuendGrab->detail.exact, grab->confineTo, grab->cursor); if (!pNewGrab) diff --git a/include/dix.h b/include/dix.h index 14d6843e3..8da218936 100644 --- a/include/dix.h +++ b/include/dix.h @@ -434,7 +434,7 @@ extern int GrabDevice( unsigned /* ownerEvents */, Time /* ctime */, Mask /* mask */, - Bool /* coreGrab */, + int /* grabtype */, Cursor /* curs */, Window /* confineToWin */, CARD8 * /* status */); diff --git a/include/dixgrabs.h b/include/dixgrabs.h index 36ab2b9d7..512723986 100644 --- a/include/dixgrabs.h +++ b/include/dixgrabs.h @@ -37,6 +37,7 @@ extern _X_EXPORT GrabPtr CreateGrab( DeviceIntPtr /* modDevice */, unsigned short /* modifiers */, int /* type */, + int /* grabtype */, KeyCode /* keybut */, WindowPtr /* confineTo */, CursorPtr /* cursor */); diff --git a/include/inputstr.h b/include/inputstr.h index 14941b106..7d666c15d 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -150,6 +150,12 @@ typedef struct _DetailRec { /* Grab details may be bit masks */ Mask *pMask; } DetailRec; +typedef enum { + GRABTYPE_CORE, + GRABTYPE_XI, + GRABTYPE_XI2 +} GrabType; + /** * Central struct for device grabs. * The same struct is used for both core grabs and device grabs, with @@ -171,7 +177,7 @@ typedef struct _GrabRec { unsigned ownerEvents:1; unsigned keyboardMode:1; unsigned pointerMode:1; - unsigned coreGrab:1; /* grab is on core device */ + GrabType grabtype; CARD8 type; /* event type */ DetailRec modifiersDetail; DeviceIntPtr modifierDevice; |