dix: Each device needs to differ between a core grab and an XI grab,

otherwise a Xi grab may overwrite or release a core grab.
        Replace grab and associates with coreGrab and deviceGrab structures,
        adjust rest of dix/Xi/etc to compile.

xfree86: Don't check for core devices, we'll have the virtual ones anyway.
         If we check, the first mouse device is duplicated and sends
         double events.
This commit is contained in:
Peter Hutterer 2007-03-08 17:17:23 +10:30
parent 537bc2ead4
commit ceca5670fe
17 changed files with 325 additions and 232 deletions

View File

@ -822,10 +822,13 @@ CALLBACK(SecurityCheckDeviceAccess)
untrusted_got_event = FALSE; untrusted_got_event = FALSE;
found_event_window = FALSE; found_event_window = FALSE;
if (dev->grab) /* We can just use coreGrab as a comment a few lines above clearly states
"device security other than keyboard is not implemented yet". The core
kbd should never have a device grab set. */
if (dev->coreGrab.grab)
{ {
untrusted_got_event = untrusted_got_event =
(TRUSTLEVEL(rClient(dev->grab)) != XSecurityClientTrusted); (TRUSTLEVEL(rClient(dev->coreGrab.grab)) != XSecurityClientTrusted);
} }
else else
{ {

View File

@ -111,22 +111,22 @@ ProcXAllowDeviceEvents(register ClientPtr client)
switch (stuff->mode) { switch (stuff->mode) {
case ReplayThisDevice: case ReplayThisDevice:
AllowSome(client, time, thisdev, NOT_GRABBED); AllowSome(client, time, thisdev, NOT_GRABBED, FALSE);
break; break;
case SyncThisDevice: case SyncThisDevice:
AllowSome(client, time, thisdev, FREEZE_NEXT_EVENT); AllowSome(client, time, thisdev, FREEZE_NEXT_EVENT, FALSE);
break; break;
case AsyncThisDevice: case AsyncThisDevice:
AllowSome(client, time, thisdev, THAWED); AllowSome(client, time, thisdev, THAWED, FALSE);
break; break;
case AsyncOtherDevices: case AsyncOtherDevices:
AllowSome(client, time, thisdev, THAW_OTHERS); AllowSome(client, time, thisdev, THAW_OTHERS, FALSE);
break; break;
case SyncAll: case SyncAll:
AllowSome(client, time, thisdev, FREEZE_BOTH_NEXT_EVENT); AllowSome(client, time, thisdev, FREEZE_BOTH_NEXT_EVENT, FALSE);
break; break;
case AsyncAll: case AsyncAll:
AllowSome(client, time, thisdev, THAWED_BOTH); AllowSome(client, time, thisdev, THAWED_BOTH, FALSE);
break; break;
default: default:
SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0, BadValue); SendErrorToClient(client, IReqCode, X_AllowDeviceEvents, 0, BadValue);

View File

@ -138,7 +138,7 @@ ProcXChangeDeviceControl(ClientPtr client)
ret = BadMatch; ret = BadMatch;
goto out; goto out;
} }
if ((dev->grab) && !SameClient(dev->grab, client)) { if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client)) {
rep.status = AlreadyGrabbed; rep.status = AlreadyGrabbed;
ret = Success; ret = Success;
goto out; goto out;

View File

@ -109,8 +109,8 @@ ProcXCloseDevice(register ClientPtr client)
return Success; return Success;
} }
if (d->grab && SameClient(d->grab, client)) if (d->deviceGrab.grab && SameClient(d->deviceGrab.grab, client))
(*d->DeactivateGrab) (d); /* release active grab */ (*d->deviceGrab.DeactivateGrab) (d); /* release active grab */
/* Remove event selections from all windows for events from this device /* Remove event selections from all windows for events from this device
* and selected by this client. * and selected by this client.

View File

@ -99,8 +99,17 @@ RegisterOtherDevice(DeviceIntPtr device)
{ {
device->public.processInputProc = ProcessOtherEvent; device->public.processInputProc = ProcessOtherEvent;
device->public.realInputProc = ProcessOtherEvent; device->public.realInputProc = ProcessOtherEvent;
(device)->ActivateGrab = ActivateKeyboardGrab; (device)->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
(device)->DeactivateGrab = DeactivateKeyboardGrab; (device)->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
if (IsPointerDevice(device))
{
(device)->coreGrab.ActivateGrab = ActivatePointerGrab;
(device)->coreGrab.DeactivateGrab = DeactivatePointerGrab;
} else
{
(device)->coreGrab.ActivateGrab = ActivateKeyboardGrab;
(device)->coreGrab.DeactivateGrab = DeactivateKeyboardGrab;
}
} }
/*ARGSUSED*/ void /*ARGSUSED*/ void
@ -110,7 +119,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count)
int i; int i;
CARD16 modifiers; CARD16 modifiers;
CARD16 mask; CARD16 mask;
GrabPtr grab = other->grab; GrabPtr grab = other->deviceGrab.grab;
Bool deactivateDeviceGrab = FALSE; Bool deactivateDeviceGrab = FALSE;
int key = 0, bit = 0, rootX, rootY; int key = 0, bit = 0, rootX, rootY;
ButtonClassPtr b = other->button; ButtonClassPtr b = other->button;
@ -203,7 +212,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count)
} }
} }
if (!grab && CheckDeviceGrabs(other, xE, 0, count)) { if (!grab && CheckDeviceGrabs(other, xE, 0, count)) {
other->activatingKey = key; other->deviceGrab.activatingKey = key;
return; return;
} }
} else if (xE->u.u.type == DeviceKeyRelease) { } else if (xE->u.u.type == DeviceKeyRelease) {
@ -229,9 +238,9 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count)
} }
} }
if (other->fromPassiveGrab && if (other->deviceGrab.fromPassiveGrab &&
!other->grab->coreGrab && !other->deviceGrab.grab->coreGrab &&
(key == other->activatingKey)) (key == other->deviceGrab.activatingKey))
deactivateDeviceGrab = TRUE; deactivateDeviceGrab = TRUE;
} else if (xE->u.u.type == DeviceButtonPress) { } else if (xE->u.u.type == DeviceButtonPress) {
if (!b) if (!b)
@ -270,8 +279,8 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count)
b->state &= ~((Button1Mask >> 1) << xE->u.u.detail); b->state &= ~((Button1Mask >> 1) << xE->u.u.detail);
SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify); SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify);
if (!b->state if (!b->state
&& other->fromPassiveGrab && other->deviceGrab.fromPassiveGrab
&& !other->grab->coreGrab) && !other->deviceGrab.grab->coreGrab)
deactivateDeviceGrab = TRUE; deactivateDeviceGrab = TRUE;
} else if (xE->u.u.type == ProximityIn) } else if (xE->u.u.type == ProximityIn)
other->valuator->mode &= ~OutOfProximity; other->valuator->mode &= ~OutOfProximity;
@ -287,7 +296,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count)
other, count); other, count);
if (deactivateDeviceGrab == TRUE) if (deactivateDeviceGrab == TRUE)
(*other->DeactivateGrab) (other); (*other->deviceGrab.DeactivateGrab) (other);
} }
_X_EXPORT int _X_EXPORT int
@ -663,7 +672,7 @@ SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
if (dev->valuator) if (dev->valuator)
if ((dev->valuator->motionHintWindow == pWin) && if ((dev->valuator->motionHintWindow == pWin) &&
(mask & DevicePointerMotionHintMask) && (mask & DevicePointerMotionHintMask) &&
!(check & DevicePointerMotionHintMask) && !dev->grab) !(check & DevicePointerMotionHintMask) && !dev->deviceGrab.grab)
dev->valuator->motionHintWindow = NullWindow; dev->valuator->motionHintWindow = NullWindow;
RecalculateDeviceDeliverableEvents(pWin); RecalculateDeviceDeliverableEvents(pWin);
return Success; return Success;
@ -1034,8 +1043,8 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev)
* any input focus changes. * any input focus changes.
* Deactivating a device grab should cause focus events. */ * Deactivating a device grab should cause focus events. */
if (dev->grab && (dev->grab->window == pWin)) if (dev->deviceGrab.grab && (dev->deviceGrab.grab->window == pWin))
(*dev->DeactivateGrab) (dev); (*dev->deviceGrab.DeactivateGrab) (dev);
/* If the focus window is a root window (ie. has no parent) /* If the focus window is a root window (ie. has no parent)
* then don't delete the focus from it. */ * then don't delete the focus from it. */
@ -1045,7 +1054,7 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev)
/* If a grab is in progress, then alter the mode of focus events. */ /* If a grab is in progress, then alter the mode of focus events. */
if (dev->grab) if (dev->deviceGrab.grab)
focusEventMode = NotifyWhileGrabbed; focusEventMode = NotifyWhileGrabbed;
switch (dev->focus->revert) { switch (dev->focus->revert) {
@ -1139,7 +1148,7 @@ CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type,
tempGrab.pointerMode = GrabModeAsync; tempGrab.pointerMode = GrabModeAsync;
tempGrab.confineTo = NullWindow; tempGrab.confineTo = NullWindow;
tempGrab.cursor = NullCursor; tempGrab.cursor = NullCursor;
(*dev->ActivateGrab) (dev, &tempGrab, currentTime, TRUE); (*dev->deviceGrab.ActivateGrab) (dev, &tempGrab, currentTime, TRUE);
} }
} }
@ -1162,7 +1171,7 @@ void
MaybeStopDeviceHint(register DeviceIntPtr dev, ClientPtr client) MaybeStopDeviceHint(register DeviceIntPtr dev, ClientPtr client)
{ {
WindowPtr pWin; WindowPtr pWin;
GrabPtr grab = dev->grab; GrabPtr grab = dev->deviceGrab.grab;
pWin = dev->valuator->motionHintWindow; pWin = dev->valuator->motionHintWindow;

View File

@ -125,7 +125,7 @@ ProcXSetDeviceValuators(register ClientPtr client)
return Success; return Success;
} }
if ((dev->grab) && !SameClient(dev->grab, client)) if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client))
rep.status = AlreadyGrabbed; rep.status = AlreadyGrabbed;
else else
rep.status = SetDeviceValuators(client, dev, (int *)&stuff[1], rep.status = SetDeviceValuators(client, dev, (int *)&stuff[1],

View File

@ -113,7 +113,7 @@ ProcXSetDeviceMode(register ClientPtr client)
SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, BadMatch); SendErrorToClient(client, IReqCode, X_SetDeviceMode, 0, BadMatch);
return Success; return Success;
} }
if ((dev->grab) && !SameClient(dev->grab, client)) if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client))
rep.status = AlreadyGrabbed; rep.status = AlreadyGrabbed;
else else
rep.status = SetDeviceMode(client, dev, stuff->mode); rep.status = SetDeviceMode(client, dev, stuff->mode);

View File

@ -106,12 +106,12 @@ ProcXUngrabDevice(register ClientPtr client)
SendErrorToClient(client, IReqCode, X_UngrabDevice, 0, BadDevice); SendErrorToClient(client, IReqCode, X_UngrabDevice, 0, BadDevice);
return Success; return Success;
} }
grab = dev->grab; grab = dev->deviceGrab.grab;
time = ClientTimeToServerTime(stuff->time); time = ClientTimeToServerTime(stuff->time);
if ((CompareTimeStamps(time, currentTime) != LATER) && if ((CompareTimeStamps(time, currentTime) != LATER) &&
(CompareTimeStamps(time, dev->grabTime) != EARLIER) && (CompareTimeStamps(time, dev->deviceGrab.grabTime) != EARLIER) &&
(grab) && SameClient(grab, client)) (grab) && SameClient(grab, client))
(*dev->DeactivateGrab) (dev); (*dev->deviceGrab.DeactivateGrab) (dev);
return Success; return Success;
} }

View File

@ -104,14 +104,27 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart)
dev->public.enqueueInputProc = EnqueueEvent; dev->public.enqueueInputProc = EnqueueEvent;
dev->deviceProc = deviceProc; dev->deviceProc = deviceProc;
dev->startup = autoStart; dev->startup = autoStart;
dev->sync.frozen = FALSE;
dev->sync.other = NullGrab; /* core grab defaults */
dev->sync.state = NOT_GRABBED; dev->coreGrab.sync.frozen = FALSE;
dev->sync.event = (xEvent *) NULL; dev->coreGrab.sync.other = NullGrab;
dev->sync.evcount = 0; dev->coreGrab.sync.state = NOT_GRABBED;
dev->grab = NullGrab; dev->coreGrab.sync.event = (xEvent *) NULL;
dev->grabTime = currentTime; dev->coreGrab.sync.evcount = 0;
dev->fromPassiveGrab = FALSE; dev->coreGrab.grab = NullGrab;
dev->coreGrab.grabTime = currentTime;
dev->coreGrab.fromPassiveGrab = FALSE;
/* device grab defaults */
dev->deviceGrab.sync.frozen = FALSE;
dev->deviceGrab.sync.other = NullGrab;
dev->deviceGrab.sync.state = NOT_GRABBED;
dev->deviceGrab.sync.event = (xEvent *) NULL;
dev->deviceGrab.sync.evcount = 0;
dev->deviceGrab.grab = NullGrab;
dev->deviceGrab.grabTime = currentTime;
dev->deviceGrab.fromPassiveGrab = FALSE;
dev->key = (KeyClassPtr)NULL; dev->key = (KeyClassPtr)NULL;
dev->valuator = (ValuatorClassPtr)NULL; dev->valuator = (ValuatorClassPtr)NULL;
dev->button = (ButtonClassPtr)NULL; dev->button = (ButtonClassPtr)NULL;
@ -339,8 +352,8 @@ InitCoreDevices()
dev->public.processInputProc = ProcessKeyboardEvent; dev->public.processInputProc = ProcessKeyboardEvent;
dev->public.realInputProc = ProcessKeyboardEvent; dev->public.realInputProc = ProcessKeyboardEvent;
#endif #endif
dev->ActivateGrab = ActivateKeyboardGrab; dev->coreGrab.ActivateGrab = ActivateKeyboardGrab;
dev->DeactivateGrab = DeactivateKeyboardGrab; dev->coreGrab.DeactivateGrab = DeactivateKeyboardGrab;
dev->coreEvents = FALSE; dev->coreEvents = FALSE;
dev->spriteOwner = FALSE; dev->spriteOwner = FALSE;
if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex)) if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex))
@ -372,8 +385,8 @@ InitCoreDevices()
dev->public.processInputProc = ProcessPointerEvent; dev->public.processInputProc = ProcessPointerEvent;
dev->public.realInputProc = ProcessPointerEvent; dev->public.realInputProc = ProcessPointerEvent;
#endif #endif
dev->ActivateGrab = ActivatePointerGrab; dev->coreGrab.ActivateGrab = ActivatePointerGrab;
dev->DeactivateGrab = DeactivatePointerGrab; dev->coreGrab.DeactivateGrab = DeactivatePointerGrab;
dev->coreEvents = FALSE; dev->coreEvents = FALSE;
if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex)) if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex))
FatalError("Couldn't allocate pointer devPrivates\n"); FatalError("Couldn't allocate pointer devPrivates\n");
@ -535,7 +548,8 @@ CloseDevice(register DeviceIntPtr dev)
PickPointer(clients[j]); PickPointer(clients[j]);
} }
xfree(dev->sync.event); xfree(dev->coreGrab.sync.event);
xfree(dev->deviceGrab.sync.event);
xfree(dev); xfree(dev);
} }
@ -1872,7 +1886,7 @@ ProcGetPointerControl(ClientPtr client)
void void
MaybeStopHint(register DeviceIntPtr dev, ClientPtr client) MaybeStopHint(register DeviceIntPtr dev, ClientPtr client)
{ {
GrabPtr grab = dev->grab; GrabPtr grab = dev->coreGrab.grab;
if ((grab && SameClient(grab, client) && if ((grab && SameClient(grab, client) &&
((grab->eventMask & PointerMotionHintMask) || ((grab->eventMask & PointerMotionHintMask) ||

View File

@ -478,7 +478,7 @@ XineramaCheckVirtualMotion(
pSprite->hot.pScreen = qe->pScreen; /* should always be Screen 0 */ pSprite->hot.pScreen = qe->pScreen; /* should always be Screen 0 */
pSprite->hot.x = qe->event->u.keyButtonPointer.rootX; pSprite->hot.x = qe->event->u.keyButtonPointer.rootX;
pSprite->hot.y = qe->event->u.keyButtonPointer.rootY; pSprite->hot.y = qe->event->u.keyButtonPointer.rootY;
pWin = pDev->grab ? pDev->grab->confineTo : pWin = pDev->coreGrab.grab ? pDev->coreGrab.grab->confineTo :
NullWindow; NullWindow;
} }
if (pWin) if (pWin)
@ -801,7 +801,7 @@ CheckVirtualMotion(
pSprite->hot.pScreen = qe->pScreen; pSprite->hot.pScreen = qe->pScreen;
pSprite->hot.x = qe->event->u.keyButtonPointer.rootX; pSprite->hot.x = qe->event->u.keyButtonPointer.rootX;
pSprite->hot.y = qe->event->u.keyButtonPointer.rootY; pSprite->hot.y = qe->event->u.keyButtonPointer.rootY;
pWin = pDev->grab ? pDev->grab->confineTo : NullWindow; pWin = pDev->coreGrab.grab ? pDev->coreGrab.grab->confineTo : NullWindow;
} }
if (pWin) if (pWin)
{ {
@ -916,7 +916,7 @@ static void
PostNewCursor(DeviceIntPtr pDev) PostNewCursor(DeviceIntPtr pDev)
{ {
register WindowPtr win; register WindowPtr win;
register GrabPtr grab = pDev->grab; register GrabPtr grab = pDev->coreGrab.grab;
SpritePtr pSprite = pDev->pSprite; SpritePtr pSprite = pDev->pSprite;
CursorPtr pCursor; CursorPtr pCursor;
@ -1108,7 +1108,7 @@ PlayReleasedEvents(void)
prev = &syncEvents.pending; prev = &syncEvents.pending;
while ( (qe = *prev) ) while ( (qe = *prev) )
{ {
if (!qe->device->sync.frozen) if (!qe->device->coreGrab.sync.frozen)
{ {
*prev = qe->next; *prev = qe->next;
pDev = qe->device; pDev = qe->device;
@ -1134,7 +1134,7 @@ PlayReleasedEvents(void)
(*qe->device->public.processInputProc)(qe->event, qe->device, (*qe->device->public.processInputProc)(qe->event, qe->device,
qe->evcount); qe->evcount);
xfree(qe); xfree(qe);
for (dev = inputInfo.devices; dev && dev->sync.frozen; dev = dev->next) for (dev = inputInfo.devices; dev && dev->coreGrab.sync.frozen; dev = dev->next)
; ;
if (!dev) if (!dev)
break; break;
@ -1150,7 +1150,7 @@ PlayReleasedEvents(void)
static void static void
FreezeThaw(register DeviceIntPtr dev, Bool frozen) FreezeThaw(register DeviceIntPtr dev, Bool frozen)
{ {
dev->sync.frozen = frozen; dev->coreGrab.sync.frozen = frozen;
if (frozen) if (frozen)
dev->public.processInputProc = dev->public.enqueueInputProc; dev->public.processInputProc = dev->public.enqueueInputProc;
else else
@ -1169,14 +1169,15 @@ ComputeFreezes()
register DeviceIntPtr dev; register DeviceIntPtr dev;
for (dev = inputInfo.devices; dev; dev = dev->next) for (dev = inputInfo.devices; dev; dev = dev->next)
FreezeThaw(dev, dev->sync.other || (dev->sync.state >= FROZEN)); FreezeThaw(dev, dev->coreGrab.sync.other ||
(dev->coreGrab.sync.state >= FROZEN));
if (syncEvents.playingEvents || (!replayDev && !syncEvents.pending)) if (syncEvents.playingEvents || (!replayDev && !syncEvents.pending))
return; return;
syncEvents.playingEvents = TRUE; syncEvents.playingEvents = TRUE;
if (replayDev) if (replayDev)
{ {
xE = replayDev->sync.event; xE = replayDev->coreGrab.sync.event;
count = replayDev->sync.evcount; count = replayDev->coreGrab.sync.evcount;
syncEvents.replayDev = (DeviceIntPtr)NULL; syncEvents.replayDev = (DeviceIntPtr)NULL;
w = XYToWindow( XE_KBPTR.rootX, XE_KBPTR.rootY); w = XYToWindow( XE_KBPTR.rootX, XE_KBPTR.rootY);
@ -1203,7 +1204,7 @@ ComputeFreezes()
playmore: playmore:
for (dev = inputInfo.devices; dev; dev = dev->next) for (dev = inputInfo.devices; dev; dev = dev->next)
{ {
if (!dev->sync.frozen) if (!dev->coreGrab.sync.frozen)
{ {
PlayReleasedEvents(); PlayReleasedEvents();
break; break;
@ -1216,7 +1217,7 @@ playmore:
{ {
/* the following may have been skipped during replay, /* the following may have been skipped during replay,
so do it now */ so do it now */
if ((grab = dev->grab) && grab->confineTo) if ((grab = dev->coreGrab.grab) && grab->confineTo)
{ {
if (grab->confineTo->drawable.pScreen != if (grab->confineTo->drawable.pScreen !=
dev->pSprite->hotPhys.pScreen) dev->pSprite->hotPhys.pScreen)
@ -1243,7 +1244,9 @@ ScreenRestructured (ScreenPtr pScreen)
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
{ {
if ((grab = pDev->grab) && grab->confineTo) /* GrabDevice doesn't have a confineTo field, so we don't need to
* worry about it. */
if ((grab = pDev->coreGrab.grab) && grab->confineTo)
{ {
if (grab->confineTo->drawable.pScreen if (grab->confineTo->drawable.pScreen
!= pDev->pSprite->hotPhys.pScreen) != pDev->pSprite->hotPhys.pScreen)
@ -1261,31 +1264,31 @@ ScreenRestructured (ScreenPtr pScreen)
void void
CheckGrabForSyncs(register DeviceIntPtr thisDev, Bool thisMode, Bool otherMode) CheckGrabForSyncs(register DeviceIntPtr thisDev, Bool thisMode, Bool otherMode)
{ {
register GrabPtr grab = thisDev->grab; register GrabPtr grab = thisDev->coreGrab.grab;
register DeviceIntPtr dev; register DeviceIntPtr dev;
if (thisMode == GrabModeSync) if (thisMode == GrabModeSync)
thisDev->sync.state = FROZEN_NO_EVENT; thisDev->coreGrab.sync.state = FROZEN_NO_EVENT;
else else
{ /* free both if same client owns both */ { /* free both if same client owns both */
thisDev->sync.state = THAWED; thisDev->coreGrab.sync.state = THAWED;
if (thisDev->sync.other && if (thisDev->coreGrab.sync.other &&
(CLIENT_BITS(thisDev->sync.other->resource) == (CLIENT_BITS(thisDev->coreGrab.sync.other->resource) ==
CLIENT_BITS(grab->resource))) CLIENT_BITS(grab->resource)))
thisDev->sync.other = NullGrab; thisDev->coreGrab.sync.other = NullGrab;
} }
for (dev = inputInfo.devices; dev; dev = dev->next) for (dev = inputInfo.devices; dev; dev = dev->next)
{ {
if (dev != thisDev) if (dev != thisDev)
{ {
if (otherMode == GrabModeSync) if (otherMode == GrabModeSync)
dev->sync.other = grab; dev->coreGrab.sync.other = grab;
else else
{ /* free both if same client owns both */ { /* free both if same client owns both */
if (dev->sync.other && if (dev->coreGrab.sync.other &&
(CLIENT_BITS(dev->sync.other->resource) == (CLIENT_BITS(dev->coreGrab.sync.other->resource) ==
CLIENT_BITS(grab->resource))) CLIENT_BITS(grab->resource)))
dev->sync.other = NullGrab; dev->coreGrab.sync.other = NullGrab;
} }
} }
} }
@ -1296,7 +1299,8 @@ void
ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab, ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab,
TimeStamp time, Bool autoGrab) TimeStamp time, Bool autoGrab)
{ {
WindowPtr oldWin = (mouse->grab) ? mouse->grab->window WindowPtr oldWin = (mouse->coreGrab.grab) ?
mouse->coreGrab.grab->window
: mouse->pSprite->win; : mouse->pSprite->win;
if (grab->confineTo) if (grab->confineTo)
@ -1309,14 +1313,14 @@ ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab,
DoEnterLeaveEvents(mouse, oldWin, grab->window, NotifyGrab); DoEnterLeaveEvents(mouse, oldWin, grab->window, NotifyGrab);
mouse->valuator->motionHintWindow = NullWindow; mouse->valuator->motionHintWindow = NullWindow;
if (syncEvents.playingEvents) if (syncEvents.playingEvents)
mouse->grabTime = syncEvents.time; mouse->coreGrab.grabTime = syncEvents.time;
else else
mouse->grabTime = time; mouse->coreGrab.grabTime = time;
if (grab->cursor) if (grab->cursor)
grab->cursor->refcnt++; grab->cursor->refcnt++;
mouse->activeGrab = *grab; mouse->coreGrab.activeGrab = *grab;
mouse->grab = &mouse->activeGrab; mouse->coreGrab.grab = &mouse->coreGrab.activeGrab;
mouse->fromPassiveGrab = autoGrab; mouse->coreGrab.fromPassiveGrab = autoGrab;
PostNewCursor(mouse); PostNewCursor(mouse);
CheckGrabForSyncs(mouse,(Bool)grab->pointerMode, (Bool)grab->keyboardMode); CheckGrabForSyncs(mouse,(Bool)grab->pointerMode, (Bool)grab->keyboardMode);
} }
@ -1324,17 +1328,17 @@ ActivatePointerGrab(register DeviceIntPtr mouse, register GrabPtr grab,
void void
DeactivatePointerGrab(register DeviceIntPtr mouse) DeactivatePointerGrab(register DeviceIntPtr mouse)
{ {
register GrabPtr grab = mouse->grab; register GrabPtr grab = mouse->coreGrab.grab;
register DeviceIntPtr dev; register DeviceIntPtr dev;
mouse->valuator->motionHintWindow = NullWindow; mouse->valuator->motionHintWindow = NullWindow;
mouse->grab = NullGrab; mouse->coreGrab.grab = NullGrab;
mouse->sync.state = NOT_GRABBED; mouse->coreGrab.sync.state = NOT_GRABBED;
mouse->fromPassiveGrab = FALSE; mouse->coreGrab.fromPassiveGrab = FALSE;
for (dev = inputInfo.devices; dev; dev = dev->next) for (dev = inputInfo.devices; dev; dev = dev->next)
{ {
if (dev->sync.other == grab) if (dev->coreGrab.sync.other == grab)
dev->sync.other = NullGrab; dev->coreGrab.sync.other = NullGrab;
} }
DoEnterLeaveEvents(mouse, grab->window, DoEnterLeaveEvents(mouse, grab->window,
mouse->pSprite->win, NotifyUngrab); mouse->pSprite->win, NotifyUngrab);
@ -1351,8 +1355,8 @@ ActivateKeyboardGrab(register DeviceIntPtr keybd, GrabPtr grab, TimeStamp time,
{ {
WindowPtr oldWin; WindowPtr oldWin;
if (keybd->grab) if (keybd->coreGrab.grab)
oldWin = keybd->grab->window; oldWin = keybd->coreGrab.grab->window;
else if (keybd->focus) else if (keybd->focus)
oldWin = keybd->focus->win; oldWin = keybd->focus->win;
else else
@ -1363,19 +1367,19 @@ ActivateKeyboardGrab(register DeviceIntPtr keybd, GrabPtr grab, TimeStamp time,
keybd->valuator->motionHintWindow = NullWindow; keybd->valuator->motionHintWindow = NullWindow;
DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab); DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab);
if (syncEvents.playingEvents) if (syncEvents.playingEvents)
keybd->grabTime = syncEvents.time; keybd->coreGrab.grabTime = syncEvents.time;
else else
keybd->grabTime = time; keybd->coreGrab.grabTime = time;
keybd->activeGrab = *grab; keybd->coreGrab.activeGrab = *grab;
keybd->grab = &keybd->activeGrab; keybd->coreGrab.grab = &keybd->coreGrab.activeGrab;
keybd->fromPassiveGrab = passive; keybd->coreGrab.fromPassiveGrab = passive;
CheckGrabForSyncs(keybd, (Bool)grab->keyboardMode, (Bool)grab->pointerMode); CheckGrabForSyncs(keybd, (Bool)grab->keyboardMode, (Bool)grab->pointerMode);
} }
void void
DeactivateKeyboardGrab(register DeviceIntPtr keybd) DeactivateKeyboardGrab(register DeviceIntPtr keybd)
{ {
register GrabPtr grab = keybd->grab; register GrabPtr grab = keybd->coreGrab.grab;
register DeviceIntPtr dev; register DeviceIntPtr dev;
register WindowPtr focusWin = keybd->focus ? keybd->focus->win register WindowPtr focusWin = keybd->focus ? keybd->focus->win
: keybd->pSprite->win; : keybd->pSprite->win;
@ -1384,49 +1388,61 @@ DeactivateKeyboardGrab(register DeviceIntPtr keybd)
focusWin = inputInfo.keyboard->focus->win; focusWin = inputInfo.keyboard->focus->win;
if (keybd->valuator) if (keybd->valuator)
keybd->valuator->motionHintWindow = NullWindow; keybd->valuator->motionHintWindow = NullWindow;
keybd->grab = NullGrab; keybd->coreGrab.grab = NullGrab;
keybd->sync.state = NOT_GRABBED; keybd->coreGrab.sync.state = NOT_GRABBED;
keybd->fromPassiveGrab = FALSE; keybd->coreGrab.fromPassiveGrab = FALSE;
for (dev = inputInfo.devices; dev; dev = dev->next) for (dev = inputInfo.devices; dev; dev = dev->next)
{ {
if (dev->sync.other == grab) if (dev->coreGrab.sync.other == grab)
dev->sync.other = NullGrab; dev->coreGrab.sync.other = NullGrab;
} }
DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab); DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab);
ComputeFreezes(); ComputeFreezes();
} }
/*
* Core flag decides whether to work on the coreGrab or deviceGrab sync
* fields.
*/
void void
AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState) AllowSome(ClientPtr client,
TimeStamp time,
DeviceIntPtr thisDev,
int newState,
Bool core)
{ {
Bool thisGrabbed, otherGrabbed, othersFrozen, thisSynced; Bool thisGrabbed, otherGrabbed, othersFrozen, thisSynced;
TimeStamp grabTime; TimeStamp grabTime;
register DeviceIntPtr dev; register DeviceIntPtr dev;
GrabInfoPtr devgrabinfo,
grabinfo = (core) ? &thisDev->coreGrab : &thisDev->deviceGrab;
thisGrabbed = thisDev->grab && SameClient(thisDev->grab, client); thisGrabbed = grabinfo->grab && SameClient(grabinfo->grab, client);
thisSynced = FALSE; thisSynced = FALSE;
otherGrabbed = FALSE; otherGrabbed = FALSE;
othersFrozen = TRUE; othersFrozen = TRUE;
grabTime = thisDev->grabTime; grabTime = grabinfo->grabTime;
for (dev = inputInfo.devices; dev; dev = dev->next) for (dev = inputInfo.devices; dev; dev = dev->next)
{ {
devgrabinfo = (core) ? &dev->coreGrab : &dev->deviceGrab;
if (dev == thisDev) if (dev == thisDev)
continue; continue;
if (dev->grab && SameClient(dev->grab, client)) if (devgrabinfo->grab && SameClient(devgrabinfo->grab, client))
{ {
if (!(thisGrabbed || otherGrabbed) || if (!(thisGrabbed || otherGrabbed) ||
(CompareTimeStamps(dev->grabTime, grabTime) == LATER)) (CompareTimeStamps(devgrabinfo->grabTime, grabTime) == LATER))
grabTime = dev->grabTime; grabTime = devgrabinfo->grabTime;
otherGrabbed = TRUE; otherGrabbed = TRUE;
if (thisDev->sync.other == dev->grab) if (grabinfo->sync.other == devgrabinfo->grab)
thisSynced = TRUE; thisSynced = TRUE;
if (dev->sync.state < FROZEN) if (devgrabinfo->sync.state < FROZEN)
othersFrozen = FALSE; othersFrozen = FALSE;
} }
else if (!dev->sync.other || !SameClient(dev->sync.other, client)) else if (!devgrabinfo->sync.other || !SameClient(devgrabinfo->sync.other, client))
othersFrozen = FALSE; othersFrozen = FALSE;
} }
if (!((thisGrabbed && thisDev->sync.state >= FROZEN) || thisSynced)) if (!((thisGrabbed && grabinfo->sync.state >= FROZEN) || thisSynced))
return; return;
if ((CompareTimeStamps(time, currentTime) == LATER) || if ((CompareTimeStamps(time, currentTime) == LATER) ||
(CompareTimeStamps(time, grabTime) == EARLIER)) (CompareTimeStamps(time, grabTime) == EARLIER))
@ -1435,17 +1451,17 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState)
{ {
case THAWED: /* Async */ case THAWED: /* Async */
if (thisGrabbed) if (thisGrabbed)
thisDev->sync.state = THAWED; grabinfo->sync.state = THAWED;
if (thisSynced) if (thisSynced)
thisDev->sync.other = NullGrab; grabinfo->sync.other = NullGrab;
ComputeFreezes(); ComputeFreezes();
break; break;
case FREEZE_NEXT_EVENT: /* Sync */ case FREEZE_NEXT_EVENT: /* Sync */
if (thisGrabbed) if (thisGrabbed)
{ {
thisDev->sync.state = FREEZE_NEXT_EVENT; grabinfo->sync.state = FREEZE_NEXT_EVENT;
if (thisSynced) if (thisSynced)
thisDev->sync.other = NullGrab; grabinfo->sync.other = NullGrab;
ComputeFreezes(); ComputeFreezes();
} }
break; break;
@ -1454,10 +1470,13 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState)
{ {
for (dev = inputInfo.devices; dev; dev = dev->next) for (dev = inputInfo.devices; dev; dev = dev->next)
{ {
if (dev->grab && SameClient(dev->grab, client)) devgrabinfo = (core) ? &dev->coreGrab : &dev->deviceGrab;
dev->sync.state = THAWED; if (devgrabinfo->grab
if (dev->sync.other && SameClient(dev->sync.other, client)) && SameClient(devgrabinfo->grab, client))
dev->sync.other = NullGrab; devgrabinfo->sync.state = THAWED;
if (devgrabinfo->sync.other &&
SameClient(devgrabinfo->sync.other, client))
devgrabinfo->sync.other = NullGrab;
} }
ComputeFreezes(); ComputeFreezes();
} }
@ -1467,22 +1486,25 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState)
{ {
for (dev = inputInfo.devices; dev; dev = dev->next) for (dev = inputInfo.devices; dev; dev = dev->next)
{ {
if (dev->grab && SameClient(dev->grab, client)) devgrabinfo = (core) ? &dev->coreGrab : &dev->deviceGrab;
dev->sync.state = FREEZE_BOTH_NEXT_EVENT; if (devgrabinfo->grab
if (dev->sync.other && SameClient(dev->sync.other, client)) && SameClient(devgrabinfo->grab, client))
dev->sync.other = NullGrab; devgrabinfo->sync.state = FREEZE_BOTH_NEXT_EVENT;
if (devgrabinfo->sync.other
&& SameClient(devgrabinfo->sync.other, client))
devgrabinfo->sync.other = NullGrab;
} }
ComputeFreezes(); ComputeFreezes();
} }
break; break;
case NOT_GRABBED: /* Replay */ case NOT_GRABBED: /* Replay */
if (thisGrabbed && thisDev->sync.state == FROZEN_WITH_EVENT) if (thisGrabbed && grabinfo->sync.state == FROZEN_WITH_EVENT)
{ {
if (thisSynced) if (thisSynced)
thisDev->sync.other = NullGrab; grabinfo->sync.other = NullGrab;
syncEvents.replayDev = thisDev; syncEvents.replayDev = thisDev;
syncEvents.replayWin = thisDev->grab->window; syncEvents.replayWin = grabinfo->grab->window;
(*thisDev->DeactivateGrab)(thisDev); (*grabinfo->DeactivateGrab)(thisDev);
syncEvents.replayDev = (DeviceIntPtr)NULL; syncEvents.replayDev = (DeviceIntPtr)NULL;
} }
break; break;
@ -1493,10 +1515,13 @@ AllowSome(ClientPtr client, TimeStamp time, DeviceIntPtr thisDev, int newState)
{ {
if (dev == thisDev) if (dev == thisDev)
continue; continue;
if (dev->grab && SameClient(dev->grab, client)) devgrabinfo = (core) ? &dev->coreGrab : &dev->deviceGrab;
dev->sync.state = THAWED; if (devgrabinfo->grab
if (dev->sync.other && SameClient(dev->sync.other, client)) && SameClient(devgrabinfo->grab, client))
dev->sync.other = NullGrab; devgrabinfo->sync.state = THAWED;
if (devgrabinfo->sync.other
&& SameClient(devgrabinfo->sync.other, client))
devgrabinfo->sync.other = NullGrab;
} }
ComputeFreezes(); ComputeFreezes();
} }
@ -1517,28 +1542,28 @@ ProcAllowEvents(register ClientPtr client)
switch (stuff->mode) switch (stuff->mode)
{ {
case ReplayPointer: case ReplayPointer:
AllowSome(client, time, mouse, NOT_GRABBED); AllowSome(client, time, mouse, NOT_GRABBED, True);
break; break;
case SyncPointer: case SyncPointer:
AllowSome(client, time, mouse, FREEZE_NEXT_EVENT); AllowSome(client, time, mouse, FREEZE_NEXT_EVENT, True);
break; break;
case AsyncPointer: case AsyncPointer:
AllowSome(client, time, mouse, THAWED); AllowSome(client, time, mouse, THAWED, True);
break; break;
case ReplayKeyboard: case ReplayKeyboard:
AllowSome(client, time, keybd, NOT_GRABBED); AllowSome(client, time, keybd, NOT_GRABBED, True);
break; break;
case SyncKeyboard: case SyncKeyboard:
AllowSome(client, time, keybd, FREEZE_NEXT_EVENT); AllowSome(client, time, keybd, FREEZE_NEXT_EVENT, True);
break; break;
case AsyncKeyboard: case AsyncKeyboard:
AllowSome(client, time, keybd, THAWED); AllowSome(client, time, keybd, THAWED, True);
break; break;
case SyncBoth: case SyncBoth:
AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT); AllowSome(client, time, keybd, FREEZE_BOTH_NEXT_EVENT, True);
break; break;
case AsyncBoth: case AsyncBoth:
AllowSome(client, time, keybd, THAWED_BOTH); AllowSome(client, time, keybd, THAWED_BOTH, True);
break; break;
default: default:
client->errorValue = stuff->mode; client->errorValue = stuff->mode;
@ -1560,9 +1585,15 @@ ReleaseActiveGrabs(ClientPtr client)
done = TRUE; done = TRUE;
for (dev = inputInfo.devices; dev; dev = dev->next) for (dev = inputInfo.devices; dev; dev = dev->next)
{ {
if (dev->grab && SameClient(dev->grab, client)) if (dev->coreGrab.grab && SameClient(dev->coreGrab.grab, client))
{ {
(*dev->DeactivateGrab)(dev); (*dev->coreGrab.DeactivateGrab)(dev);
done = FALSE;
}
if (dev->deviceGrab.grab && SameClient(dev->deviceGrab.grab, client))
{
(*dev->deviceGrab.DeactivateGrab)(dev);
done = FALSE; done = FALSE;
} }
} }
@ -1730,7 +1761,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, register WindowPtr pWin, xEvent
tempGrab.confineTo = NullWindow; tempGrab.confineTo = NullWindow;
tempGrab.cursor = NullCursor; tempGrab.cursor = NullCursor;
tempGrab.coreGrab = True; tempGrab.coreGrab = True;
(*inputInfo.pointer->ActivateGrab)(pDev, &tempGrab, (*inputInfo.pointer->coreGrab.ActivateGrab)(pDev, &tempGrab,
currentTime, TRUE); currentTime, TRUE);
} }
else if ((type == MotionNotify) && deliveries) else if ((type == MotionNotify) && deliveries)
@ -2175,7 +2206,7 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
REGION_TRANSLATE(pSprite->screen, &pSprite->Reg2, xoff, yoff); REGION_TRANSLATE(pSprite->screen, &pSprite->Reg2, xoff, yoff);
/* FIXME: if we call ConfineCursorToWindow, must we do anything else? */ /* FIXME: if we call ConfineCursorToWindow, must we do anything else? */
if ((grab = pDev->grab) && grab->confineTo) { if ((grab = pDev->coreGrab.grab) && grab->confineTo) {
if (grab->confineTo->drawable.pScreen if (grab->confineTo->drawable.pScreen
!= pSprite->hotPhys.pScreen) != pSprite->hotPhys.pScreen)
pSprite->hotPhys.x = pSprite->hotPhys.y = 0; pSprite->hotPhys.x = pSprite->hotPhys.y = 0;
@ -2576,6 +2607,7 @@ CheckPassiveGrabsOnWindow(
{ {
register GrabPtr grab = wPassiveGrabs(pWin); register GrabPtr grab = wPassiveGrabs(pWin);
GrabRec tempGrab; GrabRec tempGrab;
GrabInfoPtr grabinfo;
register xEvent *dxE; register xEvent *dxE;
if (!grab) if (!grab)
@ -2629,7 +2661,9 @@ CheckPassiveGrabsOnWindow(
tempGrab.modifiersDetail.exact&(~0x1f00); tempGrab.modifiersDetail.exact&(~0x1f00);
} }
#endif #endif
(*device->ActivateGrab)(device, grab, currentTime, TRUE); grabinfo = (xE->u.u.type & EXTENSION_EVENT_BASE) ?
&device->deviceGrab : &device->coreGrab;
(*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
FixUpEventFromWindow(device, xE, grab->window, None, TRUE); FixUpEventFromWindow(device, xE, grab->window, None, TRUE);
@ -2637,20 +2671,20 @@ CheckPassiveGrabsOnWindow(
filters[xE->u.u.type], filters[xE->u.u.type],
filters[xE->u.u.type], grab); filters[xE->u.u.type], grab);
if (device->sync.state == FROZEN_NO_EVENT) if (grabinfo->sync.state == FROZEN_NO_EVENT)
{ {
if (device->sync.evcount < count) if (grabinfo->sync.evcount < count)
{ {
Must_have_memory = TRUE; /* XXX */ Must_have_memory = TRUE; /* XXX */
device->sync.event = (xEvent *)xrealloc(device->sync.event, grabinfo->sync.event = (xEvent *)xrealloc(grabinfo->sync.event,
count* count*
sizeof(xEvent)); sizeof(xEvent));
Must_have_memory = FALSE; /* XXX */ Must_have_memory = FALSE; /* XXX */
} }
device->sync.evcount = count; grabinfo->sync.evcount = count;
for (dxE = device->sync.event; --count >= 0; dxE++, xE++) for (dxE = grabinfo->sync.event; --count >= 0; dxE++, xE++)
*dxE = *xE; *dxE = *xE;
device->sync.state = FROZEN_WITH_EVENT; grabinfo->sync.state = FROZEN_WITH_EVENT;
} }
return TRUE; return TRUE;
} }
@ -2747,12 +2781,20 @@ void
DeliverGrabbedEvent(register xEvent *xE, register DeviceIntPtr thisDev, DeliverGrabbedEvent(register xEvent *xE, register DeviceIntPtr thisDev,
Bool deactivateGrab, int count) Bool deactivateGrab, int count)
{ {
register GrabPtr grab = thisDev->grab; register GrabPtr grab;
GrabInfoPtr grabinfo;
int deliveries = 0; int deliveries = 0;
register DeviceIntPtr dev; register DeviceIntPtr dev;
register xEvent *dxE; register xEvent *dxE;
SpritePtr pSprite = thisDev->pSprite; SpritePtr pSprite = thisDev->pSprite;
if (xE->u.u.type & EXTENSION_EVENT_BASE)
grabinfo = &thisDev->deviceGrab;
else
grabinfo = &thisDev->coreGrab;
grab = grabinfo->grab;
if (grab->ownerEvents) if (grab->ownerEvents)
{ {
WindowPtr focus; WindowPtr focus;
@ -2798,7 +2840,7 @@ DeliverGrabbedEvent(register xEvent *xE, register DeviceIntPtr thisDev,
&& xE->u.u.type != DeviceMotionNotify && xE->u.u.type != DeviceMotionNotify
#endif #endif
)) ))
switch (thisDev->sync.state) switch (grabinfo->sync.state)
{ {
case FREEZE_BOTH_NEXT_EVENT: case FREEZE_BOTH_NEXT_EVENT:
for (dev = inputInfo.devices; dev; dev = dev->next) for (dev = inputInfo.devices; dev; dev = dev->next)
@ -2806,26 +2848,26 @@ DeliverGrabbedEvent(register xEvent *xE, register DeviceIntPtr thisDev,
if (dev == thisDev) if (dev == thisDev)
continue; continue;
FreezeThaw(dev, TRUE); FreezeThaw(dev, TRUE);
if ((dev->sync.state == FREEZE_BOTH_NEXT_EVENT) && if ((grabinfo->sync.state == FREEZE_BOTH_NEXT_EVENT) &&
(CLIENT_BITS(dev->grab->resource) == (CLIENT_BITS(grab->resource) ==
CLIENT_BITS(thisDev->grab->resource))) CLIENT_BITS(grab->resource)))
dev->sync.state = FROZEN_NO_EVENT; grabinfo->sync.state = FROZEN_NO_EVENT;
else else
dev->sync.other = thisDev->grab; grabinfo->sync.other = grab;
} }
/* fall through */ /* fall through */
case FREEZE_NEXT_EVENT: case FREEZE_NEXT_EVENT:
thisDev->sync.state = FROZEN_WITH_EVENT; grabinfo->sync.state = FROZEN_WITH_EVENT;
FreezeThaw(thisDev, TRUE); FreezeThaw(thisDev, TRUE);
if (thisDev->sync.evcount < count) if (grabinfo->sync.evcount < count)
{ {
Must_have_memory = TRUE; /* XXX */ Must_have_memory = TRUE; /* XXX */
thisDev->sync.event = (xEvent *)xrealloc(thisDev->sync.event, grabinfo->sync.event = (xEvent *)xrealloc(grabinfo->sync.event,
count*sizeof(xEvent)); count*sizeof(xEvent));
Must_have_memory = FALSE; /* XXX */ Must_have_memory = FALSE; /* XXX */
} }
thisDev->sync.evcount = count; grabinfo->sync.evcount = count;
for (dxE = thisDev->sync.event; --count >= 0; dxE++, xE++) for (dxE = grabinfo->sync.event; --count >= 0; dxE++, xE++)
*dxE = *xE; *dxE = *xE;
break; break;
} }
@ -2843,9 +2885,11 @@ ProcessKeyboardEvent (register xEvent *xE, register DeviceIntPtr keybd, int coun
register int i; register int i;
register CARD8 modifiers; register CARD8 modifiers;
register CARD16 mask; register CARD16 mask;
GrabPtr grab = keybd->grab; register GrabPtr grab;
GrabInfoPtr grabinfo;
Bool deactivateGrab = FALSE; Bool deactivateGrab = FALSE;
register KeyClassPtr keyc = keybd->key; register KeyClassPtr keyc = keybd->key;
#ifdef XEVIE #ifdef XEVIE
static Window rootWin = 0; static Window rootWin = 0;
@ -2886,6 +2930,13 @@ drawable.id:0;
} }
#endif #endif
if (xE->u.u.type & EXTENSION_EVENT_BASE)
grabinfo = &keybd->deviceGrab;
else
grabinfo = &keybd->coreGrab;
grab = grabinfo->grab;
if (!syncEvents.playingEvents) if (!syncEvents.playingEvents)
{ {
NoticeTime(xE); NoticeTime(xE);
@ -2954,7 +3005,7 @@ drawable.id:0;
} }
if (!grab && CheckDeviceGrabs(keybd, xE, 0, count)) if (!grab && CheckDeviceGrabs(keybd, xE, 0, count))
{ {
keybd->activatingKey = key; grabinfo->activatingKey = key;
return; return;
} }
break; break;
@ -2975,7 +3026,7 @@ drawable.id:0;
modifiers &= ~mask; modifiers &= ~mask;
} }
} }
if (keybd->fromPassiveGrab && (key == keybd->activatingKey)) if (grabinfo->fromPassiveGrab && (key == grabinfo->activatingKey))
deactivateGrab = TRUE; deactivateGrab = TRUE;
break; break;
default: default:
@ -2986,7 +3037,7 @@ drawable.id:0;
else else
DeliverFocusedEvent(keybd, xE, keybd->pSprite->win, count); DeliverFocusedEvent(keybd, xE, keybd->pSprite->win, count);
if (deactivateGrab) if (deactivateGrab)
(*keybd->DeactivateGrab)(keybd); (*grabinfo->DeactivateGrab)(keybd);
XaceHook(XACE_KEY_AVAIL, xE, keybd, count); XaceHook(XACE_KEY_AVAIL, xE, keybd, count);
} }
@ -3033,7 +3084,7 @@ CoreProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int c
ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count) ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count)
#endif #endif
{ {
register GrabPtr grab = mouse->grab; GrabPtr grab = mouse->coreGrab.grab;
Bool deactivateGrab = FALSE; Bool deactivateGrab = FALSE;
register ButtonClassPtr butc = mouse->button; register ButtonClassPtr butc = mouse->button;
SpritePtr pSprite = mouse->pSprite; SpritePtr pSprite = mouse->pSprite;
@ -3120,7 +3171,7 @@ ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count
if (xE->u.u.detail <= 5) if (xE->u.u.detail <= 5)
butc->state &= ~((Button1Mask >> 1) << xE->u.u.detail); butc->state &= ~((Button1Mask >> 1) << xE->u.u.detail);
filters[MotionNotify] = Motion_Filter(butc); filters[MotionNotify] = Motion_Filter(butc);
if (!butc->state && mouse->fromPassiveGrab) if (!butc->state && mouse->coreGrab.fromPassiveGrab)
deactivateGrab = TRUE; deactivateGrab = TRUE;
break; break;
default: default:
@ -3135,7 +3186,7 @@ ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count
DeliverDeviceEvents(pSprite->win, xE, NullGrab, NullWindow, DeliverDeviceEvents(pSprite->win, xE, NullGrab, NullWindow,
mouse, count); mouse, count);
if (deactivateGrab) if (deactivateGrab)
(*mouse->DeactivateGrab)(mouse); (*mouse->coreGrab.DeactivateGrab)(mouse);
} }
#define AtMostOneClient \ #define AtMostOneClient \
@ -3277,7 +3328,7 @@ maskSet:
if ((inputInfo.pointer->valuator->motionHintWindow == pWin) && if ((inputInfo.pointer->valuator->motionHintWindow == pWin) &&
(mask & PointerMotionHintMask) && (mask & PointerMotionHintMask) &&
!(check & PointerMotionHintMask) && !(check & PointerMotionHintMask) &&
!inputInfo.pointer->grab) !inputInfo.pointer->coreGrab.grab) /* VCP shouldn't have deviceGrab */
inputInfo.pointer->valuator->motionHintWindow = NullWindow; inputInfo.pointer->valuator->motionHintWindow = NullWindow;
RecalculateDeliverableEvents(pWin); RecalculateDeliverableEvents(pWin);
return Success; return Success;
@ -3362,7 +3413,8 @@ EnterLeaveEvent(
register DeviceIntPtr keybd = inputInfo.keyboard; register DeviceIntPtr keybd = inputInfo.keyboard;
WindowPtr focus; WindowPtr focus;
register DeviceIntPtr mouse = pDev; register DeviceIntPtr mouse = pDev;
register GrabPtr grab = mouse->grab; GrabPtr grab = mouse->coreGrab.grab;
GrabPtr devgrab = mouse->deviceGrab.grab;
Mask mask; Mask mask;
deviceEnterNotify *devEnterLeave; deviceEnterNotify *devEnterLeave;
@ -3430,9 +3482,9 @@ EnterLeaveEvent(
if (inputMasks && if (inputMasks &&
(filters[devEnterLeave->type] & inputMasks->deliverableEvents[mskidx])) (filters[devEnterLeave->type] & inputMasks->deliverableEvents[mskidx]))
{ {
if (grab) if (devgrab)
(void)TryClientEvents(rClient(grab), (xEvent*)devEnterLeave, 1, (void)TryClientEvents(rClient(devgrab), (xEvent*)devEnterLeave, 1,
mask, filters[devEnterLeave->type], grab); mask, filters[devEnterLeave->type], devgrab);
else else
(void)DeliverEventsToWindow(pDev, pWin, (xEvent*)devEnterLeave, (void)DeliverEventsToWindow(pDev, pWin, (xEvent*)devEnterLeave,
1, filters[devEnterLeave->type], 1, filters[devEnterLeave->type],
@ -3776,7 +3828,7 @@ SetInputFocus(
if ((CompareTimeStamps(time, currentTime) == LATER) || if ((CompareTimeStamps(time, currentTime) == LATER) ||
(CompareTimeStamps(time, focus->time) == EARLIER)) (CompareTimeStamps(time, focus->time) == EARLIER))
return Success; return Success;
mode = (dev->grab) ? NotifyWhileGrabbed : NotifyNormal; mode = (dev->coreGrab.grab) ? NotifyWhileGrabbed : NotifyNormal;
if (focus->win == FollowKeyboardWin) if (focus->win == FollowKeyboardWin)
DoFocusEvents(dev, inputInfo.keyboard->focus->win, focusWin, mode); DoFocusEvents(dev, inputInfo.keyboard->focus->win, focusWin, mode);
else else
@ -3912,7 +3964,7 @@ ProcGrabPointer(ClientPtr client)
rep.type = X_Reply; rep.type = X_Reply;
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
rep.length = 0; rep.length = 0;
grab = device->grab; grab = device->coreGrab.grab;
if ((grab) && !SameClient(grab, client)) if ((grab) && !SameClient(grab, client))
rep.status = AlreadyGrabbed; rep.status = AlreadyGrabbed;
else if ((!pWin->realized) || else if ((!pWin->realized) ||
@ -3920,11 +3972,12 @@ ProcGrabPointer(ClientPtr client)
!(confineTo->realized !(confineTo->realized
&& BorderSizeNotEmpty(device, confineTo)))) && BorderSizeNotEmpty(device, confineTo))))
rep.status = GrabNotViewable; rep.status = GrabNotViewable;
else if (device->sync.frozen && else if (device->coreGrab.sync.frozen &&
device->sync.other && !SameClient(device->sync.other, client)) device->coreGrab.sync.other &&
!SameClient(device->coreGrab.sync.other, client))
rep.status = GrabFrozen; rep.status = GrabFrozen;
else if ((CompareTimeStamps(time, currentTime) == LATER) || else if ((CompareTimeStamps(time, currentTime) == LATER) ||
(CompareTimeStamps(time, device->grabTime) == EARLIER)) (CompareTimeStamps(time, device->coreGrab.grabTime) == EARLIER))
rep.status = GrabInvalidTime; rep.status = GrabInvalidTime;
else else
{ {
@ -3948,7 +4001,7 @@ ProcGrabPointer(ClientPtr client)
tempGrab.pointerMode = stuff->pointerMode; tempGrab.pointerMode = stuff->pointerMode;
tempGrab.device = device; tempGrab.device = device;
tempGrab.coreGrab = True; tempGrab.coreGrab = True;
(*device->ActivateGrab)(device, &tempGrab, time, FALSE); (*device->coreGrab.ActivateGrab)(device, &tempGrab, time, FALSE);
if (oldCursor) if (oldCursor)
FreeCursor (oldCursor, (Cursor)0); FreeCursor (oldCursor, (Cursor)0);
rep.status = GrabSuccess; rep.status = GrabSuccess;
@ -3961,7 +4014,7 @@ int
ProcChangeActivePointerGrab(ClientPtr client) ProcChangeActivePointerGrab(ClientPtr client)
{ {
DeviceIntPtr device = PickPointer(client); DeviceIntPtr device = PickPointer(client);
register GrabPtr grab = device->grab; register GrabPtr grab = device->coreGrab.grab;
CursorPtr newCursor, oldCursor; CursorPtr newCursor, oldCursor;
REQUEST(xChangeActivePointerGrabReq); REQUEST(xChangeActivePointerGrabReq);
TimeStamp time; TimeStamp time;
@ -3990,7 +4043,7 @@ ProcChangeActivePointerGrab(ClientPtr client)
return Success; return Success;
time = ClientTimeToServerTime(stuff->time); time = ClientTimeToServerTime(stuff->time);
if ((CompareTimeStamps(time, currentTime) == LATER) || if ((CompareTimeStamps(time, currentTime) == LATER) ||
(CompareTimeStamps(time, device->grabTime) == EARLIER)) (CompareTimeStamps(time, device->coreGrab.grabTime) == EARLIER))
return Success; return Success;
oldCursor = grab->cursor; oldCursor = grab->cursor;
grab->cursor = newCursor; grab->cursor = newCursor;
@ -4013,12 +4066,12 @@ ProcUngrabPointer(ClientPtr client)
REQUEST_SIZE_MATCH(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq);
UpdateCurrentTime(); UpdateCurrentTime();
grab = device->grab; grab = device->coreGrab.grab;
time = ClientTimeToServerTime(stuff->id); time = ClientTimeToServerTime(stuff->id);
if ((CompareTimeStamps(time, currentTime) != LATER) && if ((CompareTimeStamps(time, currentTime) != LATER) &&
(CompareTimeStamps(time, device->grabTime) != EARLIER) && (CompareTimeStamps(time, device->coreGrab.grabTime) != EARLIER) &&
(grab) && SameClient(grab, client)) (grab) && SameClient(grab, client))
(*device->DeactivateGrab)(device); (*device->coreGrab.DeactivateGrab)(device);
return Success; return Success;
} }
@ -4052,16 +4105,16 @@ GrabDevice(register ClientPtr client, register DeviceIntPtr dev,
if (rc != Success) if (rc != Success)
return rc; return rc;
time = ClientTimeToServerTime(ctime); time = ClientTimeToServerTime(ctime);
grab = dev->grab; grab = dev->coreGrab.grab;
if (grab && !SameClient(grab, client)) if (grab && !SameClient(grab, client))
*status = AlreadyGrabbed; *status = AlreadyGrabbed;
else if (!pWin->realized) else if (!pWin->realized)
*status = GrabNotViewable; *status = GrabNotViewable;
else if ((CompareTimeStamps(time, currentTime) == LATER) || else if ((CompareTimeStamps(time, currentTime) == LATER) ||
(CompareTimeStamps(time, dev->grabTime) == EARLIER)) (CompareTimeStamps(time, dev->coreGrab.grabTime) == EARLIER))
*status = GrabInvalidTime; *status = GrabInvalidTime;
else if (dev->sync.frozen && else if (dev->coreGrab.sync.frozen &&
dev->sync.other && !SameClient(dev->sync.other, client)) dev->coreGrab.sync.other && !SameClient(dev->coreGrab.sync.other, client))
*status = GrabFrozen; *status = GrabFrozen;
else else
{ {
@ -4079,7 +4132,7 @@ GrabDevice(register ClientPtr client, register DeviceIntPtr dev,
tempGrab.device = dev; tempGrab.device = dev;
tempGrab.cursor = NULL; tempGrab.cursor = NULL;
(*dev->ActivateGrab)(dev, &tempGrab, time, FALSE); (*dev->coreGrab.ActivateGrab)(dev, &tempGrab, time, FALSE);
*status = GrabSuccess; *status = GrabSuccess;
} }
return Success; return Success;
@ -4123,12 +4176,12 @@ ProcUngrabKeyboard(ClientPtr client)
REQUEST_SIZE_MATCH(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq);
UpdateCurrentTime(); UpdateCurrentTime();
grab = device->grab; grab = device->coreGrab.grab;
time = ClientTimeToServerTime(stuff->id); time = ClientTimeToServerTime(stuff->id);
if ((CompareTimeStamps(time, currentTime) != LATER) && if ((CompareTimeStamps(time, currentTime) != LATER) &&
(CompareTimeStamps(time, device->grabTime) != EARLIER) && (CompareTimeStamps(time, device->coreGrab.grabTime) != EARLIER) &&
(grab) && SameClient(grab, client)) (grab) && SameClient(grab, client))
(*device->DeactivateGrab)(device); (*device->coreGrab.DeactivateGrab)(device);
return Success; return Success;
} }
@ -4547,19 +4600,21 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
FocusClassPtr focus = keybd->focus; FocusClassPtr focus = keybd->focus;
OtherClientsPtr oc; OtherClientsPtr oc;
GrabPtr passive; GrabPtr passive;
GrabPtr grab;
/* Deactivate any grabs performed on this window, before making any /* Deactivate any grabs performed on this window, before making any
input focus changes. */ input focus changes. */
grab = mouse->coreGrab.grab;
if (mouse->grab && if (grab &&
((mouse->grab->window == pWin) || (mouse->grab->confineTo == pWin))) ((grab->window == pWin) || (grab->confineTo == pWin)))
(*mouse->DeactivateGrab)(mouse); (*mouse->coreGrab.DeactivateGrab)(mouse);
/* Deactivating a keyboard grab should cause focus events. */ /* Deactivating a keyboard grab should cause focus events. */
if (keybd->grab && (keybd->grab->window == pWin)) grab = keybd->coreGrab.grab;
(*keybd->DeactivateGrab)(keybd); if (grab && (grab->window == pWin))
(*keybd->coreGrab.DeactivateGrab)(keybd);
/* If the focus window is a root window (ie. has no parent) then don't /* If the focus window is a root window (ie. has no parent) then don't
delete the focus from it. */ delete the focus from it. */
@ -4570,7 +4625,7 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
/* If a grab is in progress, then alter the mode of focus events. */ /* If a grab is in progress, then alter the mode of focus events. */
if (keybd->grab) if (keybd->coreGrab.grab)
focusEventMode = NotifyWhileGrabbed; focusEventMode = NotifyWhileGrabbed;
switch (focus->revert) switch (focus->revert)
@ -4644,11 +4699,11 @@ CheckCursorConfinement(WindowPtr pWin)
{ {
if (DevHasCursor(pDev)) if (DevHasCursor(pDev))
{ {
grab = pDev->grab; grab = pDev->coreGrab.grab;
if (grab && (confineTo = grab->confineTo)) if (grab && (confineTo = grab->confineTo))
{ {
if (!BorderSizeNotEmpty(pDev, confineTo)) if (!BorderSizeNotEmpty(pDev, confineTo))
(*inputInfo.pointer->DeactivateGrab)(pDev); (*inputInfo.pointer->coreGrab.DeactivateGrab)(pDev);
else if ((pWin == confineTo) || IsParent(pWin, confineTo)) else if ((pWin == confineTo) || IsParent(pWin, confineTo))
ConfineCursorToWindow(pDev, confineTo, TRUE, TRUE); ConfineCursorToWindow(pDev, confineTo, TRUE, TRUE);
} }

View File

@ -2478,8 +2478,6 @@ xf86HandleConfigFile(Bool autoconfig)
return CONFIG_PARSE_ERROR; return CONFIG_PARSE_ERROR;
} }
checkInput(&xf86ConfigLayout);
/* /*
* Handle some command line options that can override some of the * Handle some command line options that can override some of the
* ServerFlags settings. * ServerFlags settings.

View File

@ -1030,8 +1030,10 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr keybd)
else else
{ {
/* If the keyboard is actively grabbed, deliver a grabbed core event */ /* If the keyboard is actively grabbed, deliver a grabbed core event */
if (keybd->grab && !keybd->fromPassiveGrab) if (keybd->coreGrab.grab && !keybd->coreGrab.fromPassiveGrab)
{ {
/* I've got no clue if that is correct but only working on core
* grabs seems the right thing here. (whot) */
core.u.u.type = coreEquiv; core.u.u.type = coreEquiv;
core.u.u.detail = de->u.u.detail; core.u.u.detail = de->u.u.detail;
core.u.keyButtonPointer.time = de->u.event.time; core.u.keyButtonPointer.time = de->u.event.time;
@ -1109,8 +1111,10 @@ DGAProcessPointerEvent (ScreenPtr pScreen, dgaEvent *de, DeviceIntPtr mouse)
else else
{ {
/* If the pointer is actively grabbed, deliver a grabbed core event */ /* If the pointer is actively grabbed, deliver a grabbed core event */
if (mouse->grab && !mouse->fromPassiveGrab) if (mouse->coreGrab.grab && !mouse->coreGrab.fromPassiveGrab)
{ {
/* I've got no clue if that is correct but only working on core
* grabs seems the right thing here. (whot) */
core.u.u.type = coreEquiv; core.u.u.type = coreEquiv;
core.u.u.detail = de->u.u.detail; core.u.u.detail = de->u.u.detail;
core.u.keyButtonPointer.time = de->u.event.time; core.u.keyButtonPointer.time = de->u.event.time;

View File

@ -290,12 +290,13 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
break; break;
case ACTION_DISABLEGRAB: case ACTION_DISABLEGRAB:
if (!xf86Info.grabInfo.disabled && xf86Info.grabInfo.allowDeactivate) { if (!xf86Info.grabInfo.disabled && xf86Info.grabInfo.allowDeactivate) {
if (inputInfo.pointer && inputInfo.pointer->grab != NULL && if (inputInfo.pointer && inputInfo.pointer->coreGrab.grab != NULL &&
inputInfo.pointer->DeactivateGrab) inputInfo.pointer->coreGrab.DeactivateGrab)
inputInfo.pointer->DeactivateGrab(inputInfo.pointer); inputInfo.pointer->coreGrab.DeactivateGrab(inputInfo.pointer);
if (inputInfo.keyboard && inputInfo.keyboard->grab != NULL && if (inputInfo.keyboard &&
inputInfo.keyboard->DeactivateGrab) inputInfo.keyboard->coreGrab.grab != NULL &&
inputInfo.keyboard->DeactivateGrab(inputInfo.keyboard); inputInfo.keyboard->coreGrab.DeactivateGrab)
inputInfo.keyboard->coreGrab.DeactivateGrab(inputInfo.keyboard);
} }
break; break;
case ACTION_CLOSECLIENT: case ACTION_CLOSECLIENT:
@ -303,10 +304,11 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
ClientPtr pointer, keyboard, server; ClientPtr pointer, keyboard, server;
pointer = keyboard = server = NULL; pointer = keyboard = server = NULL;
if (inputInfo.pointer && inputInfo.pointer->grab != NULL) if (inputInfo.pointer && inputInfo.pointer->coreGrab.grab != NULL)
pointer = clients[CLIENT_ID(inputInfo.pointer->grab->resource)]; pointer = clients[CLIENT_ID(inputInfo.pointer->coreGrab.grab->resource)];
if (inputInfo.keyboard && inputInfo.keyboard->grab != NULL) { if (inputInfo.keyboard && inputInfo.keyboard->coreGrab.grab != NULL)
keyboard = clients[CLIENT_ID(inputInfo.keyboard->grab->resource)]; {
keyboard = clients[CLIENT_ID(inputInfo.keyboard->coreGrab.grab->resource)];
if (keyboard == pointer) if (keyboard == pointer)
keyboard = NULL; keyboard = NULL;
} }

View File

@ -469,7 +469,8 @@ extern void AllowSome(
ClientPtr /* client */, ClientPtr /* client */,
TimeStamp /* time */, TimeStamp /* time */,
DeviceIntPtr /* thisDev */, DeviceIntPtr /* thisDev */,
int /* newState */); int /* newState */,
Bool /* core */);
extern void ReleaseActiveGrabs( extern void ReleaseActiveGrabs(
ClientPtr client); ClientPtr client);

View File

@ -455,7 +455,7 @@ extern DeviceIntPtr GetPairedPointer(DeviceIntPtr kbd);
extern Bool RegisterPairingClient(ClientPtr client); extern Bool RegisterPairingClient(ClientPtr client);
extern Bool UnregisterPairingClient(ClientPtr client); extern Bool UnregisterPairingClient(ClientPtr client);
extern DeviceIntPtr GuessFreePointerDevice(); extern DeviceIntPtr GuessFreePointerDevice(void);
/* Window/device based access control */ /* Window/device based access control */
extern Bool ACRegisterClient(ClientPtr client); extern Bool ACRegisterClient(ClientPtr client);

View File

@ -300,11 +300,31 @@ typedef struct {
#define FROZEN_NO_EVENT 5 #define FROZEN_NO_EVENT 5
#define FROZEN_WITH_EVENT 6 #define FROZEN_WITH_EVENT 6
#define THAW_OTHERS 7 #define THAW_OTHERS 7
typedef struct _GrabInfoRec {
TimeStamp grabTime;
Bool fromPassiveGrab;
GrabRec activeGrab;
GrabPtr grab;
CARD8 activatingKey;
void (*ActivateGrab) (
DeviceIntPtr /*device*/,
GrabPtr /*grab*/,
TimeStamp /*time*/,
Bool /*autoGrab*/);
void (*DeactivateGrab)(
DeviceIntPtr /*device*/);
struct {
Bool frozen;
int state;
GrabPtr other; /* if other grab has this frozen */
xEvent *event; /* saved to be replayed */
int evcount;
} sync;
} GrabInfoRec, *GrabInfoPtr;
typedef struct _DeviceIntRec { typedef struct _DeviceIntRec {
DeviceRec public; DeviceRec public;
DeviceIntPtr next; DeviceIntPtr next;
TimeStamp grabTime;
Bool startup; /* true if needs to be turned on at Bool startup; /* true if needs to be turned on at
server intialization time */ server intialization time */
DeviceProc deviceProc; /* proc(DevicePtr, DEVICE_xx). It is DeviceProc deviceProc; /* proc(DevicePtr, DEVICE_xx). It is
@ -313,27 +333,11 @@ typedef struct _DeviceIntRec {
Bool inited; /* TRUE if INIT returns Success */ Bool inited; /* TRUE if INIT returns Success */
Bool enabled; /* TRUE if ON returns Success */ Bool enabled; /* TRUE if ON returns Success */
Bool coreEvents; /* TRUE if device also sends core */ Bool coreEvents; /* TRUE if device also sends core */
GrabPtr grab; /* the grabber - used by DIX */ GrabInfoRec coreGrab; /* grab on core events */
struct { GrabInfoRec deviceGrab; /* grab on device events */
Bool frozen;
int state;
GrabPtr other; /* if other grab has this frozen */
xEvent *event; /* saved to be replayed */
int evcount;
} sync;
Atom type; Atom type;
char *name; char *name;
CARD8 id; CARD8 id;
CARD8 activatingKey;
Bool fromPassiveGrab;
GrabRec activeGrab;
void (*ActivateGrab) (
DeviceIntPtr /*device*/,
GrabPtr /*grab*/,
TimeStamp /*time*/,
Bool /*autoGrab*/);
void (*DeactivateGrab)(
DeviceIntPtr /*device*/);
KeyClassPtr key; KeyClassPtr key;
ValuatorClassPtr valuator; ValuatorClassPtr valuator;
ButtonClassPtr button; ButtonClassPtr button;

View File

@ -808,6 +808,7 @@ XkbFilterEvents(ClientPtr pClient,int nEvents,xEvent *xE)
int i, button_mask; int i, button_mask;
DeviceIntPtr pXDev = (DeviceIntPtr)LookupKeyboardDevice(); DeviceIntPtr pXDev = (DeviceIntPtr)LookupKeyboardDevice();
XkbSrvInfoPtr xkbi; XkbSrvInfoPtr xkbi;
GrabInfoPtr grabinfo;
xkbi= pXDev->key->xkbInfo; xkbi= pXDev->key->xkbInfo;
if ( pClient->xkbClientFlags & _XkbClientInitialized ) { if ( pClient->xkbClientFlags & _XkbClientInitialized ) {
@ -831,7 +832,9 @@ XkbSrvInfoPtr xkbi;
(_XkbIsReleaseEvent(xE[0].u.u.type)) ) { (_XkbIsReleaseEvent(xE[0].u.u.type)) ) {
return False; return False;
} }
if ((pXDev->grab != NullGrab) && pXDev->fromPassiveGrab && /* just coreGrab is fine, pXDev is inputInfo.keyboard (see above) */
if ((pXDev->coreGrab.grab != NullGrab)
&& pXDev->coreGrab.fromPassiveGrab &&
((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) { ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) {
register unsigned state,flags; register unsigned state,flags;