Merge branch 'for-peter' of git://people.freedesktop.org/~daniels/xserver into for-keith

This commit is contained in:
Peter Hutterer 2011-01-07 09:35:07 +10:00
commit 8456625d64
9 changed files with 142 additions and 133 deletions

View File

@ -1261,7 +1261,8 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
xi2event->group.effective_group = dev->key->xkbInfo->state.group; xi2event->group.effective_group = dev->key->xkbInfo->state.group;
} }
FixUpEventFromWindow(dev, (xEvent*)xi2event, pWin, None, FALSE); FixUpEventFromWindow(dev->spriteInfo->sprite, (xEvent*)xi2event, pWin,
None, FALSE);
DeliverEventsToWindow(dev, pWin, (xEvent*)xi2event, 1, DeliverEventsToWindow(dev, pWin, (xEvent*)xi2event, 1,
GetEventFilter(dev, (xEvent*)xi2event), NullGrab); GetEventFilter(dev, (xEvent*)xi2event), NullGrab);

View File

@ -757,6 +757,7 @@ static void SDeviceEvent(xXIDeviceEvent *from, xXIDeviceEvent *to)
swapl(&to->mods.latched_mods, n); swapl(&to->mods.latched_mods, n);
swapl(&to->mods.locked_mods, n); swapl(&to->mods.locked_mods, n);
swapl(&to->mods.effective_mods, n); swapl(&to->mods.effective_mods, n);
swapl(&to->flags, n);
ptr = (char*)(&to[1]); ptr = (char*)(&to[1]);
ptr += from->buttons_len * 4; ptr += from->buttons_len * 4;

View File

@ -209,10 +209,6 @@ static void CheckPhysLimits(DeviceIntPtr pDev,
Bool generateEvents, Bool generateEvents,
Bool confineToScreen, Bool confineToScreen,
ScreenPtr pScreen); ScreenPtr pScreen);
static Bool CheckPassiveGrabsOnWindow(WindowPtr pWin,
DeviceIntPtr device,
DeviceEvent *event,
BOOL checkCore);
/** Key repeat hack. Do not use but in TryClientEvents */ /** Key repeat hack. Do not use but in TryClientEvents */
extern BOOL EventIsKeyRepeat(xEvent *event); extern BOOL EventIsKeyRepeat(xEvent *event);
@ -256,7 +252,7 @@ EventSyncInfoRec syncEvents;
/** /**
* The root window the given device is currently on. * The root window the given device is currently on.
*/ */
#define RootWindow(dev) dev->spriteInfo->sprite->spriteTrace[0] #define RootWindow(sprite) sprite->spriteTrace[0]
static xEvent* swapEvent = NULL; static xEvent* swapEvent = NULL;
static int swapEventLen = 0; static int swapEventLen = 0;
@ -332,12 +328,6 @@ IsMaster(DeviceIntPtr dev)
return dev->type == MASTER_POINTER || dev->type == MASTER_KEYBOARD; return dev->type == MASTER_POINTER || dev->type == MASTER_KEYBOARD;
} }
static WindowPtr XYToWindow(
DeviceIntPtr pDev,
int x,
int y
);
/** /**
* Max event opcode. * Max event opcode.
*/ */
@ -445,7 +435,7 @@ GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
(inputMasks->xi2mask[XIAllMasterDevices][evtype/8] && IsMaster(dev))); (inputMasks->xi2mask[XIAllMasterDevices][evtype/8] && IsMaster(dev)));
} }
static Mask Mask
GetEventMask(DeviceIntPtr dev, xEvent *event, InputClients* other) GetEventMask(DeviceIntPtr dev, xEvent *event, InputClients* other)
{ {
/* XI2 filters are only ever 8 bit, so let's return a 8 bit mask */ /* XI2 filters are only ever 8 bit, so let's return a 8 bit mask */
@ -879,7 +869,7 @@ CheckVirtualMotion(
#ifdef PANORAMIX #ifdef PANORAMIX
if (noPanoramiXExtension) /* No typo. Only set the root win if disabled */ if (noPanoramiXExtension) /* No typo. Only set the root win if disabled */
#endif #endif
RootWindow(pDev) = pSprite->hot.pScreen->root; RootWindow(pDev->spriteInfo->sprite) = pSprite->hot.pScreen->root;
} }
static void static void
@ -1012,7 +1002,7 @@ PostNewCursor(DeviceIntPtr pDev)
WindowPtr WindowPtr
GetCurrentRootWindow(DeviceIntPtr dev) GetCurrentRootWindow(DeviceIntPtr dev)
{ {
return RootWindow(dev); return RootWindow(dev->spriteInfo->sprite);
} }
/** /**
@ -1290,7 +1280,8 @@ ComputeFreezes(void)
syncEvents.replayDev = (DeviceIntPtr)NULL; syncEvents.replayDev = (DeviceIntPtr)NULL;
w = XYToWindow(replayDev, event->root_x, event->root_y); w = XYToWindow(replayDev->spriteInfo->sprite,
event->root_x, event->root_y);
if (!CheckDeviceGrabs(replayDev, event, syncEvents.replayWin)) if (!CheckDeviceGrabs(replayDev, event, syncEvents.replayWin))
{ {
if (replayDev->focus && !IsPointerEvent((InternalEvent*)event)) if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
@ -1511,7 +1502,7 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
DoEnterLeaveEvents(mouse, mouse->id, grab->window, DoEnterLeaveEvents(mouse, mouse->id, grab->window,
mouse->spriteInfo->sprite->win, NotifyUngrab); mouse->spriteInfo->sprite->win, NotifyUngrab);
if (grab->confineTo) if (grab->confineTo)
ConfineCursorToWindow(mouse, RootWindow(mouse), FALSE, FALSE); ConfineCursorToWindow(mouse, GetCurrentRootWindow(mouse), FALSE, FALSE);
PostNewCursor(mouse); PostNewCursor(mouse);
if (grab->cursor) if (grab->cursor)
FreeCursor(grab->cursor, (Cursor)0); FreeCursor(grab->cursor, (Cursor)0);
@ -2181,9 +2172,8 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
return 2; return 2;
} }
static Window FindChildForEvent(DeviceIntPtr dev, WindowPtr event) static Window FindChildForEvent(SpritePtr pSprite, WindowPtr event)
{ {
SpritePtr pSprite = dev->spriteInfo->sprite;
WindowPtr w = pSprite->spriteTrace[pSprite->spriteTraceGood-1]; WindowPtr w = pSprite->spriteTrace[pSprite->spriteTraceGood-1];
Window child = None; Window child = None;
@ -2222,16 +2212,14 @@ static Window FindChildForEvent(DeviceIntPtr dev, WindowPtr event)
*/ */
void void
FixUpEventFromWindow( FixUpEventFromWindow(
DeviceIntPtr pDev, SpritePtr pSprite,
xEvent *xE, xEvent *xE,
WindowPtr pWin, WindowPtr pWin,
Window child, Window child,
Bool calcChild) Bool calcChild)
{ {
SpritePtr pSprite = pDev->spriteInfo->sprite;
if (calcChild) if (calcChild)
child = FindChildForEvent(pDev, pWin); child = FindChildForEvent(pSprite, pWin);
if (XI2_EVENT(xE)) if (XI2_EVENT(xE))
{ {
@ -2247,7 +2235,7 @@ FixUpEventFromWindow(
event->evtype == XI_PropertyEvent) event->evtype == XI_PropertyEvent)
return; return;
event->root = RootWindow(pDev)->drawable.id; event->root = RootWindow(pSprite)->drawable.id;
event->event = pWin->drawable.id; event->event = pWin->drawable.id;
if (pSprite->hot.pScreen == pWin->drawable.pScreen) if (pSprite->hot.pScreen == pWin->drawable.pScreen)
{ {
@ -2268,7 +2256,7 @@ FixUpEventFromWindow(
} else } else
{ {
XE_KBPTR.root = RootWindow(pDev)->drawable.id; XE_KBPTR.root = RootWindow(pSprite)->drawable.id;
XE_KBPTR.event = pWin->drawable.id; XE_KBPTR.event = pWin->drawable.id;
if (pSprite->hot.pScreen == pWin->drawable.pScreen) if (pSprite->hot.pScreen == pWin->drawable.pScreen)
{ {
@ -2374,6 +2362,7 @@ int
DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab, DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
WindowPtr stopAt, DeviceIntPtr dev) WindowPtr stopAt, DeviceIntPtr dev)
{ {
SpritePtr pSprite = dev->spriteInfo->sprite;
Window child = None; Window child = None;
Mask filter; Mask filter;
int deliveries = 0; int deliveries = 0;
@ -2396,7 +2385,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
{ {
/* XXX: XACE */ /* XXX: XACE */
filter = GetEventFilter(dev, xi2); filter = GetEventFilter(dev, xi2);
FixUpEventFromWindow(dev, xi2, pWin, child, FALSE); FixUpEventFromWindow(pSprite, xi2, pWin, child, FALSE);
deliveries = DeliverEventsToWindow(dev, pWin, xi2, 1, deliveries = DeliverEventsToWindow(dev, pWin, xi2, 1,
filter, grab); filter, grab);
free(xi2); free(xi2);
@ -2414,7 +2403,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
if (rc == Success) { if (rc == Success) {
if (XaceHook(XACE_SEND_ACCESS, NULL, dev, pWin, xE, count) == Success) { if (XaceHook(XACE_SEND_ACCESS, NULL, dev, pWin, xE, count) == Success) {
filter = GetEventFilter(dev, xE); filter = GetEventFilter(dev, xE);
FixUpEventFromWindow(dev, xE, pWin, child, FALSE); FixUpEventFromWindow(pSprite, xE, pWin, child, FALSE);
deliveries = DeliverEventsToWindow(dev, pWin, xE, count, deliveries = DeliverEventsToWindow(dev, pWin, xE, count,
filter, grab); filter, grab);
if (deliveries > 0) if (deliveries > 0)
@ -2432,7 +2421,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
if (rc == Success) { if (rc == Success) {
if (XaceHook(XACE_SEND_ACCESS, NULL, dev, pWin, &core, 1) == Success) { if (XaceHook(XACE_SEND_ACCESS, NULL, dev, pWin, &core, 1) == Success) {
filter = GetEventFilter(dev, &core); filter = GetEventFilter(dev, &core);
FixUpEventFromWindow(dev, &core, pWin, child, FALSE); FixUpEventFromWindow(pSprite, &core, pWin, child, FALSE);
deliveries = DeliverEventsToWindow(dev, pWin, &core, 1, deliveries = DeliverEventsToWindow(dev, pWin, &core, 1,
filter, grab); filter, grab);
if (deliveries > 0) if (deliveries > 0)
@ -2555,16 +2544,14 @@ PointInBorderSize(WindowPtr pWin, int x, int y)
* *
* @returns the window at the given coordinates. * @returns the window at the given coordinates.
*/ */
static WindowPtr WindowPtr
XYToWindow(DeviceIntPtr pDev, int x, int y) XYToWindow(SpritePtr pSprite, int x, int y)
{ {
WindowPtr pWin; WindowPtr pWin;
BoxRec box; BoxRec box;
SpritePtr pSprite;
pSprite = pDev->spriteInfo->sprite;
pSprite->spriteTraceGood = 1; /* root window still there */ pSprite->spriteTraceGood = 1; /* root window still there */
pWin = RootWindow(pDev)->firstChild; pWin = RootWindow(pSprite)->firstChild;
while (pWin) while (pWin)
{ {
if ((pWin->mapped) && if ((pWin->mapped) &&
@ -2642,7 +2629,7 @@ ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
event.deviceid = dev->id; event.deviceid = dev->id;
event.sourceid = dev->id; event.sourceid = dev->id;
event.detail.button = 0; event.detail.button = 0;
rc = CheckPassiveGrabsOnWindow(win, dev, &event, FALSE); rc = (CheckPassiveGrabsOnWindow(win, dev, &event, FALSE, TRUE) != NULL);
if (rc) if (rc)
DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab); DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
return rc; return rc;
@ -2679,10 +2666,9 @@ ActivateEnterGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
event.deviceid = dev->id; event.deviceid = dev->id;
event.sourceid = dev->id; event.sourceid = dev->id;
event.detail.button = 0; event.detail.button = 0;
rc = CheckPassiveGrabsOnWindow(win, dev, &event, FALSE); rc = (CheckPassiveGrabsOnWindow(win, dev, &event, FALSE, TRUE) != NULL);
if (rc) if (rc)
DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveGrab); DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveGrab);
return rc; return rc;
} }
@ -2737,7 +2723,8 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
if (pSprite->hot.pScreen != pSprite->hotPhys.pScreen) if (pSprite->hot.pScreen != pSprite->hotPhys.pScreen)
{ {
pSprite->hot.pScreen = pSprite->hotPhys.pScreen; pSprite->hot.pScreen = pSprite->hotPhys.pScreen;
RootWindow(pDev) = pSprite->hot.pScreen->root; RootWindow(pDev->spriteInfo->sprite) =
pSprite->hot.pScreen->root;
} }
} }
@ -2776,7 +2763,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
ev->root_y = pSprite->hot.y; ev->root_y = pSprite->hot.y;
} }
newSpriteWin = XYToWindow(pDev, pSprite->hot.x, pSprite->hot.y); newSpriteWin = XYToWindow(pSprite, pSprite->hot.x, pSprite->hot.y);
if (newSpriteWin != prevSpriteWin) if (newSpriteWin != prevSpriteWin)
{ {
@ -2942,7 +2929,7 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
FatalError("Failed to allocate spriteTrace"); FatalError("Failed to allocate spriteTrace");
pSprite->spriteTraceSize = 32; pSprite->spriteTraceSize = 32;
RootWindow(pDev) = pWin; RootWindow(pDev->spriteInfo->sprite) = pWin;
pSprite->spriteTraceGood = 1; pSprite->spriteTraceGood = 1;
pSprite->pEnqueueScreen = pScreen; pSprite->pEnqueueScreen = pScreen;
@ -3352,21 +3339,25 @@ BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin)
/** /**
* "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a * "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
* passive grab set on the window to be activated. * passive grab set on the window to be activated.
* If a passive grab is activated, the event will be delivered to the client. * If activate is true and a passive grab is found, it will be activated,
* and the event will be delivered to the client.
* *
* @param pWin The window that may be subject to a passive grab. * @param pWin The window that may be subject to a passive grab.
* @param device Device that caused the event. * @param device Device that caused the event.
* @param event The current device event. * @param event The current device event.
* @param checkCore Check for core grabs too. * @param checkCore Check for core grabs too.
* @param activate If a grab is found, activate it and deliver the event.
*/ */
static Bool GrabPtr
CheckPassiveGrabsOnWindow( CheckPassiveGrabsOnWindow(
WindowPtr pWin, WindowPtr pWin,
DeviceIntPtr device, DeviceIntPtr device,
DeviceEvent *event, DeviceEvent *event,
BOOL checkCore) BOOL checkCore,
BOOL activate)
{ {
SpritePtr pSprite = device->spriteInfo->sprite;
GrabPtr grab = wPassiveGrabs(pWin); GrabPtr grab = wPassiveGrabs(pWin);
GrabRec tempGrab; GrabRec tempGrab;
GrabInfoPtr grabinfo; GrabInfoPtr grabinfo;
@ -3376,7 +3367,7 @@ CheckPassiveGrabsOnWindow(
int match = 0; int match = 0;
if (!grab) if (!grab)
return FALSE; return NULL;
/* Fill out the grab details, but leave the type for later before /* Fill out the grab details, but leave the type for later before
* comparing */ * comparing */
tempGrab.window = pWin; tempGrab.window = pWin;
@ -3422,9 +3413,9 @@ CheckPassiveGrabsOnWindow(
tempGrab.detail.exact = event->detail.key; tempGrab.detail.exact = event->detail.key;
if (!match) if (!match)
{ {
tempGrab.type = GetXIType((InternalEvent*)event);
tempGrab.grabtype = GRABTYPE_XI; tempGrab.grabtype = GRABTYPE_XI;
if (GrabMatchesSecond(&tempGrab, grab, FALSE)) if ((tempGrab.type = GetXIType((InternalEvent*)event)) &&
(GrabMatchesSecond(&tempGrab, grab, FALSE)))
match = XI_MATCH; match = XI_MATCH;
} }
@ -3490,6 +3481,8 @@ CheckPassiveGrabsOnWindow(
continue; continue;
} }
if (!activate)
return grab;
if (match & CORE_MATCH) if (match & CORE_MATCH)
{ {
@ -3530,7 +3523,7 @@ CheckPassiveGrabsOnWindow(
if (xE) if (xE)
{ {
FixUpEventFromWindow(device, xE, grab->window, None, TRUE); FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
TryClientEvents(rClient(grab), device, xE, count, TryClientEvents(rClient(grab), device, xE, count,
GetEventFilter(device, xE), GetEventFilter(device, xE),
@ -3547,10 +3540,10 @@ CheckPassiveGrabsOnWindow(
if (match & (XI_MATCH | XI2_MATCH)) if (match & (XI_MATCH | XI2_MATCH))
free(xE); /* on core match xE == &core */ free(xE); /* on core match xE == &core */
return TRUE; return grab;
} }
} }
return FALSE; return NULL;
#undef CORE_MATCH #undef CORE_MATCH
#undef XI_MATCH #undef XI_MATCH
#undef XI2_MATCH #undef XI2_MATCH
@ -3616,7 +3609,7 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
for (; i < focus->traceGood; i++) for (; i < focus->traceGood; i++)
{ {
pWin = focus->trace[i]; pWin = focus->trace[i];
if (CheckPassiveGrabsOnWindow(pWin, device, event, sendCore)) if (CheckPassiveGrabsOnWindow(pWin, device, event, sendCore, TRUE))
return TRUE; return TRUE;
} }
@ -3629,7 +3622,7 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
for (; i < device->spriteInfo->sprite->spriteTraceGood; i++) for (; i < device->spriteInfo->sprite->spriteTraceGood; i++)
{ {
pWin = device->spriteInfo->sprite->spriteTrace[i]; pWin = device->spriteInfo->sprite->spriteTrace[i];
if (CheckPassiveGrabsOnWindow(pWin, device, event, sendCore)) if (CheckPassiveGrabsOnWindow(pWin, device, event, sendCore, TRUE))
return TRUE; return TRUE;
} }
@ -3682,7 +3675,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
{ {
/* XXX: XACE */ /* XXX: XACE */
int filter = GetEventFilter(keybd, xi2); int filter = GetEventFilter(keybd, xi2);
FixUpEventFromWindow(ptr, xi2, focus, None, FALSE); FixUpEventFromWindow(ptr->spriteInfo->sprite, xi2, focus, None, FALSE);
deliveries = DeliverEventsToWindow(keybd, focus, xi2, 1, deliveries = DeliverEventsToWindow(keybd, focus, xi2, 1,
filter, NullGrab); filter, NullGrab);
if (deliveries > 0) if (deliveries > 0)
@ -3695,7 +3688,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
if (rc == Success && if (rc == Success &&
XaceHook(XACE_SEND_ACCESS, NULL, keybd, focus, xE, count) == Success) XaceHook(XACE_SEND_ACCESS, NULL, keybd, focus, xE, count) == Success)
{ {
FixUpEventFromWindow(ptr, xE, focus, None, FALSE); FixUpEventFromWindow(ptr->spriteInfo->sprite, xE, focus, None, FALSE);
deliveries = DeliverEventsToWindow(keybd, focus, xE, count, deliveries = DeliverEventsToWindow(keybd, focus, xE, count,
GetEventFilter(keybd, xE), GetEventFilter(keybd, xE),
NullGrab); NullGrab);
@ -3711,7 +3704,8 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
rc = EventToCore(event, &core); rc = EventToCore(event, &core);
if (rc == Success) { if (rc == Success) {
if (XaceHook(XACE_SEND_ACCESS, NULL, keybd, focus, &core, 1) == Success) { if (XaceHook(XACE_SEND_ACCESS, NULL, keybd, focus, &core, 1) == Success) {
FixUpEventFromWindow(keybd, &core, focus, None, FALSE); FixUpEventFromWindow(keybd->spriteInfo->sprite, &core, focus,
None, FALSE);
deliveries = DeliverEventsToWindow(keybd, focus, &core, 1, deliveries = DeliverEventsToWindow(keybd, focus, &core, 1,
GetEventFilter(keybd, &core), GetEventFilter(keybd, &core),
NullGrab); NullGrab);
@ -3801,8 +3795,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
rc = EventToCore(event, &core); rc = EventToCore(event, &core);
if (rc == Success) if (rc == Success)
{ {
FixUpEventFromWindow(thisDev, &core, grab->window, FixUpEventFromWindow(pSprite, &core, grab->window, None, TRUE);
None, TRUE);
if (XaceHook(XACE_SEND_ACCESS, 0, thisDev, if (XaceHook(XACE_SEND_ACCESS, 0, thisDev,
grab->window, &core, 1) || grab->window, &core, 1) ||
XaceHook(XACE_RECEIVE_ACCESS, rClient(grab), XaceHook(XACE_RECEIVE_ACCESS, rClient(grab),
@ -3829,7 +3822,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
grab->xi2mask[XIAllMasterDevices][evtype/8] | grab->xi2mask[XIAllMasterDevices][evtype/8] |
grab->xi2mask[thisDev->id][evtype/8]; grab->xi2mask[thisDev->id][evtype/8];
/* try XI2 event */ /* try XI2 event */
FixUpEventFromWindow(thisDev, xi2, grab->window, None, TRUE); FixUpEventFromWindow(pSprite, xi2, grab->window, None, TRUE);
/* XXX: XACE */ /* XXX: XACE */
deliveries = TryClientEvents(rClient(grab), thisDev, xi2, 1, mask, deliveries = TryClientEvents(rClient(grab), thisDev, xi2, 1, mask,
GetEventFilter(thisDev, xi2), grab); GetEventFilter(thisDev, xi2), grab);
@ -3850,8 +3843,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
else else
mask = grab->eventMask; mask = grab->eventMask;
FixUpEventFromWindow(thisDev, xi, grab->window, FixUpEventFromWindow(pSprite, xi, grab->window, None, TRUE);
None, TRUE);
if (XaceHook(XACE_SEND_ACCESS, 0, thisDev, if (XaceHook(XACE_SEND_ACCESS, 0, thisDev,
grab->window, xi, count) || grab->window, xi, count) ||
@ -4197,7 +4189,7 @@ CoreEnterLeaveEvent(
event.u.enterLeave.rootX = mouse->spriteInfo->sprite->hot.x; event.u.enterLeave.rootX = mouse->spriteInfo->sprite->hot.x;
event.u.enterLeave.rootY = mouse->spriteInfo->sprite->hot.y; event.u.enterLeave.rootY = mouse->spriteInfo->sprite->hot.y;
/* Counts on the same initial structure of crossing & button events! */ /* Counts on the same initial structure of crossing & button events! */
FixUpEventFromWindow(mouse, &event, pWin, None, FALSE); FixUpEventFromWindow(mouse->spriteInfo->sprite, &event, pWin, None, FALSE);
/* Enter/Leave events always set child */ /* Enter/Leave events always set child */
event.u.enterLeave.child = child; event.u.enterLeave.child = child;
event.u.enterLeave.flags = event.u.keyButtonPointer.sameScreen ? event.u.enterLeave.flags = event.u.keyButtonPointer.sameScreen ?
@ -4297,7 +4289,8 @@ DeviceEnterLeaveEvent(
event->group.locked_group = kbd->key->xkbInfo->state.locked_group; event->group.locked_group = kbd->key->xkbInfo->state.locked_group;
} }
FixUpEventFromWindow(mouse, (xEvent*)event, pWin, None, FALSE); FixUpEventFromWindow(mouse->spriteInfo->sprite, (xEvent*)event, pWin,
None, FALSE);
filter = GetEventFilter(mouse, (xEvent*)event); filter = GetEventFilter(mouse, (xEvent*)event);
@ -4554,7 +4547,8 @@ ProcGrabPointer(ClientPtr client)
if (grab) if (grab)
{ {
if (grab->confineTo && !confineTo) if (grab->confineTo && !confineTo)
ConfineCursorToWindow(device, RootWindow(device), FALSE, FALSE); ConfineCursorToWindow(device, GetCurrentRootWindow(device), FALSE,
FALSE);
oldCursor = grab->cursor; oldCursor = grab->cursor;
} }
@ -4883,7 +4877,7 @@ ProcQueryPointer(ClientPtr client)
rep.mask = mouse->button ? (mouse->button->state) : 0; rep.mask = mouse->button ? (mouse->button->state) : 0;
rep.mask |= XkbStateFieldFromRec(&keyboard->key->xkbInfo->state); rep.mask |= XkbStateFieldFromRec(&keyboard->key->xkbInfo->state);
rep.length = 0; rep.length = 0;
rep.root = (RootWindow(mouse))->drawable.id; rep.root = (GetCurrentRootWindow(mouse))->drawable.id;
rep.rootX = pSprite->hot.x; rep.rootX = pSprite->hot.x;
rep.rootY = pSprite->hot.y; rep.rootY = pSprite->hot.y;
rep.child = None; rep.child = None;
@ -5042,7 +5036,7 @@ ProcSendEvent(ClientPtr client)
/* If the input focus is PointerRootWin, send the event to where /* If the input focus is PointerRootWin, send the event to where
the pointer is if possible, then perhaps propogate up to root. */ the pointer is if possible, then perhaps propogate up to root. */
if (inputFocus == PointerRootWin) if (inputFocus == PointerRootWin)
inputFocus = RootWindow(dev); inputFocus = GetCurrentRootWindow(dev);
if (IsParent(inputFocus, pSprite->win)) if (IsParent(inputFocus, pSprite->win))
{ {

View File

@ -372,6 +372,13 @@ extern void AllowSome(
extern void ReleaseActiveGrabs( extern void ReleaseActiveGrabs(
ClientPtr client); ClientPtr client);
extern GrabPtr CheckPassiveGrabsOnWindow(
WindowPtr /* pWin */,
DeviceIntPtr /* device */,
DeviceEvent * /* event */,
BOOL /* checkCore */,
BOOL /* activate */);
extern _X_EXPORT int DeliverEventsToWindow( extern _X_EXPORT int DeliverEventsToWindow(
DeviceIntPtr /* pWin */, DeviceIntPtr /* pWin */,
WindowPtr /* pWin */, WindowPtr /* pWin */,

View File

@ -103,6 +103,7 @@ typedef struct _OtherClients *OtherClientsPtr;
typedef struct _InputClients *InputClientsPtr; typedef struct _InputClients *InputClientsPtr;
typedef struct _DeviceIntRec *DeviceIntPtr; typedef struct _DeviceIntRec *DeviceIntPtr;
typedef struct _ClassesRec *ClassesPtr; typedef struct _ClassesRec *ClassesPtr;
typedef struct _SpriteRec *SpritePtr;
typedef union _GrabMask GrabMask; typedef union _GrabMask GrabMask;
typedef struct _EventList { typedef struct _EventList {
@ -525,13 +526,15 @@ extern _X_EXPORT InputAttributes *DuplicateInputAttributes(InputAttributes *attr
extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs); extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
/* misc event helpers */ /* misc event helpers */
extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event); extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
extern Mask GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev); extern Mask GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev);
void FixUpEventFromWindow(DeviceIntPtr pDev, void FixUpEventFromWindow(SpritePtr pSprite,
xEvent *xE, xEvent *xE,
WindowPtr pWin, WindowPtr pWin,
Window child, Window child,
Bool calcChild); Bool calcChild);
extern WindowPtr XYToWindow(SpritePtr pSprite, int x, int y);
extern int EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, extern int EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event,
WindowPtr win); WindowPtr win);
/** /**

View File

@ -203,6 +203,47 @@ typedef struct _GrabRec {
unsigned char xi2mask[EMASKSIZE][XI2MASKSIZE]; unsigned char xi2mask[EMASKSIZE][XI2MASKSIZE];
} GrabRec; } GrabRec;
/**
* Sprite information for a device.
*/
typedef struct _SpriteRec {
CursorPtr current;
BoxRec hotLimits; /* logical constraints of hot spot */
Bool confined; /* confined to screen */
RegionPtr hotShape; /* additional logical shape constraint */
BoxRec physLimits; /* physical constraints of hot spot */
WindowPtr win; /* window of logical position */
HotSpot hot; /* logical pointer position */
HotSpot hotPhys; /* physical pointer position */
#ifdef PANORAMIX
ScreenPtr screen; /* all others are in Screen 0 coordinates */
RegionRec Reg1; /* Region 1 for confining motion */
RegionRec Reg2; /* Region 2 for confining virtual motion */
WindowPtr windows[MAXSCREENS];
WindowPtr confineWin; /* confine window */
#endif
/* The window trace information is used at dix/events.c to avoid having
* to compute all the windows between the root and the current pointer
* window each time a button or key goes down. The grabs on each of those
* windows must be checked.
* spriteTraces should only be used at dix/events.c! */
WindowPtr *spriteTrace;
int spriteTraceSize;
int spriteTraceGood;
/* Due to delays between event generation and event processing, it is
* possible that the pointer has crossed screen boundaries between the
* time in which it begins generating events and the time when
* those events are processed.
*
* pEnqueueScreen: screen the pointer was on when the event was generated
* pDequeueScreen: screen the pointer was on when the event is processed
*/
ScreenPtr pEnqueueScreen;
ScreenPtr pDequeueScreen;
} SpriteRec;
typedef struct _KeyClassRec { typedef struct _KeyClassRec {
int sourceid; int sourceid;
CARD8 down[DOWN_LENGTH]; CARD8 down[DOWN_LENGTH];
@ -360,47 +401,6 @@ typedef struct _ClassesRec {
} ClassesRec; } ClassesRec;
/**
* Sprite information for a device.
*/
typedef struct {
CursorPtr current;
BoxRec hotLimits; /* logical constraints of hot spot */
Bool confined; /* confined to screen */
RegionPtr hotShape; /* additional logical shape constraint */
BoxRec physLimits; /* physical constraints of hot spot */
WindowPtr win; /* window of logical position */
HotSpot hot; /* logical pointer position */
HotSpot hotPhys; /* physical pointer position */
#ifdef PANORAMIX
ScreenPtr screen; /* all others are in Screen 0 coordinates */
RegionRec Reg1; /* Region 1 for confining motion */
RegionRec Reg2; /* Region 2 for confining virtual motion */
WindowPtr windows[MAXSCREENS];
WindowPtr confineWin; /* confine window */
#endif
/* The window trace information is used at dix/events.c to avoid having
* to compute all the windows between the root and the current pointer
* window each time a button or key goes down. The grabs on each of those
* windows must be checked.
* spriteTraces should only be used at dix/events.c! */
WindowPtr *spriteTrace;
int spriteTraceSize;
int spriteTraceGood;
/* Due to delays between event generation and event processing, it is
* possible that the pointer has crossed screen boundaries between the
* time in which it begins generating events and the time when
* those events are processed.
*
* pEnqueueScreen: screen the pointer was on when the event was generated
* pDequeueScreen: screen the pointer was on when the event is processed
*/
ScreenPtr pEnqueueScreen;
ScreenPtr pDequeueScreen;
} SpriteRec, *SpritePtr;
/* Device properties */ /* Device properties */
typedef struct _XIPropertyValue typedef struct _XIPropertyValue
{ {

View File

@ -256,7 +256,7 @@ static void dix_event_to_core(int type)
#undef test_event #undef test_event
} }
static void dix_event_to_core_conversion(void) static void dix_event_to_core_fail(int evtype, int expected_rc)
{ {
DeviceEvent ev; DeviceEvent ev;
xEvent core; xEvent core;
@ -265,25 +265,18 @@ static void dix_event_to_core_conversion(void)
ev.header = 0xFF; ev.header = 0xFF;
ev.length = sizeof(DeviceEvent); ev.length = sizeof(DeviceEvent);
ev.type = 0; ev.type = evtype;
rc = EventToCore((InternalEvent*)&ev, &core); rc = EventToCore((InternalEvent*)&ev, &core);
g_assert(rc == BadImplementation); g_assert(rc == expected_rc);
}
ev.type = 1; static void dix_event_to_core_conversion(void)
rc = EventToCore((InternalEvent*)&ev, &core); {
g_assert(rc == BadImplementation); dix_event_to_core_fail(0, BadImplementation);
dix_event_to_core_fail(1, BadImplementation);
ev.type = ET_ProximityOut + 1; dix_event_to_core_fail(ET_ProximityOut + 1, BadImplementation);
rc = EventToCore((InternalEvent*)&ev, &core); dix_event_to_core_fail(ET_ProximityIn, BadMatch);
g_assert(rc == BadImplementation); dix_event_to_core_fail(ET_ProximityOut, BadMatch);
ev.type = ET_ProximityIn;
rc = EventToCore((InternalEvent*)&ev, &core);
g_assert(rc == BadMatch);
ev.type = ET_ProximityOut;
rc = EventToCore((InternalEvent*)&ev, &core);
g_assert(rc == BadMatch);
dix_event_to_core(ET_KeyPress); dix_event_to_core(ET_KeyPress);
dix_event_to_core(ET_KeyRelease); dix_event_to_core(ET_KeyRelease);

View File

@ -272,6 +272,7 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
int buttons, valuators; int buttons, valuators;
int i; int i;
unsigned char *ptr; unsigned char *ptr;
uint32_t flagmask = 0;
FP3232 *values; FP3232 *values;
if (swap) { if (swap) {
@ -297,6 +298,7 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
swapl(&out->mods.latched_mods, n); swapl(&out->mods.latched_mods, n);
swapl(&out->mods.locked_mods, n); swapl(&out->mods.locked_mods, n);
swapl(&out->mods.effective_mods, n); swapl(&out->mods.effective_mods, n);
swapl(&out->flags, n);
} }
g_assert(out->extension == 0); /* IReqCode defaults to 0 */ g_assert(out->extension == 0); /* IReqCode defaults to 0 */
@ -308,7 +310,15 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
g_assert(out->deviceid == in->deviceid); g_assert(out->deviceid == in->deviceid);
g_assert(out->sourceid == in->sourceid); g_assert(out->sourceid == in->sourceid);
g_assert(out->flags == 0); /* FIXME: we don't set the flags yet */ switch (in->type) {
case ET_KeyPress:
flagmask = XIKeyRepeat;
break;
default:
flagmask = 0;
break;
}
g_assert((out->flags & ~flagmask) == 0);
g_assert(out->root == in->root); g_assert(out->root == in->root);
g_assert(out->event == None); /* set in FixUpEventFromWindow */ g_assert(out->event == None); /* set in FixUpEventFromWindow */

View File

@ -131,7 +131,7 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
{ {
int i, j; int i, j;
xXIEventMask *mask; xXIEventMask *mask;
int nmasks = (XI_LASTEVENT + 7)/8; int nmasks = (XI2LASTEVENT + 7)/8;
unsigned char *bits; unsigned char *bits;
mask = (xXIEventMask*)&req[1]; mask = (xXIEventMask*)&req[1];
@ -150,14 +150,14 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
request_XISelectEvent(req, Success); request_XISelectEvent(req, Success);
/* Test 1: /* Test 1:
* mask may be larger than needed for XI_LASTEVENT. * mask may be larger than needed for XI2LASTEVENT.
* Test setting each valid mask bit, while leaving unneeded bits 0. * Test setting each valid mask bit, while leaving unneeded bits 0.
* -> Success * -> Success
*/ */
bits = (unsigned char*)&mask[1]; bits = (unsigned char*)&mask[1];
mask->mask_len = (nmasks + 3)/4 * 10; mask->mask_len = (nmasks + 3)/4 * 10;
memset(bits, 0, mask->mask_len * 4); memset(bits, 0, mask->mask_len * 4);
for (j = 0; j <= XI_LASTEVENT; j++) for (j = 0; j <= XI2LASTEVENT; j++)
{ {
SetBit(bits, j); SetBit(bits, j);
request_XISelectEvent(req, Success); request_XISelectEvent(req, Success);
@ -165,7 +165,7 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
} }
/* Test 2: /* Test 2:
* mask may be larger than needed for XI_LASTEVENT. * mask may be larger than needed for XI2LASTEVENT.
* Test setting all valid mask bits, while leaving unneeded bits 0. * Test setting all valid mask bits, while leaving unneeded bits 0.
* -> Success * -> Success
*/ */
@ -173,21 +173,21 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
mask->mask_len = (nmasks + 3)/4 * 10; mask->mask_len = (nmasks + 3)/4 * 10;
memset(bits, 0, mask->mask_len * 4); memset(bits, 0, mask->mask_len * 4);
for (j = 0; j <= XI_LASTEVENT; j++) for (j = 0; j <= XI2LASTEVENT; j++)
{ {
SetBit(bits, j); SetBit(bits, j);
request_XISelectEvent(req, Success); request_XISelectEvent(req, Success);
} }
/* Test 3: /* Test 3:
* mask is larger than needed for XI_LASTEVENT. If any unneeded bit * mask is larger than needed for XI2LASTEVENT. If any unneeded bit
* is set -> BadValue * is set -> BadValue
*/ */
bits = (unsigned char*)&mask[1]; bits = (unsigned char*)&mask[1];
mask->mask_len = (nmasks + 3)/4 * 10; mask->mask_len = (nmasks + 3)/4 * 10;
memset(bits, 0, mask->mask_len * 4); memset(bits, 0, mask->mask_len * 4);
for (j = XI_LASTEVENT + 1; j < mask->mask_len * 4; j++) for (j = XI2LASTEVENT + 1; j < mask->mask_len * 4; j++)
{ {
SetBit(bits, j); SetBit(bits, j);
request_XISelectEvent(req, BadValue); request_XISelectEvent(req, BadValue);
@ -200,7 +200,7 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
bits = (unsigned char*)&mask[1]; bits = (unsigned char*)&mask[1];
mask->mask_len = (nmasks + 3)/4; mask->mask_len = (nmasks + 3)/4;
memset(bits, 0, mask->mask_len * 4); memset(bits, 0, mask->mask_len * 4);
for (j = 0; j <= XI_LASTEVENT; j++) for (j = 0; j <= XI2LASTEVENT; j++)
{ {
SetBit(bits, j); SetBit(bits, j);
request_XISelectEvent(req, Success); request_XISelectEvent(req, Success);
@ -228,7 +228,7 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
bits = (unsigned char*)&mask[1]; bits = (unsigned char*)&mask[1];
mask->mask_len = (nmasks + 3)/4; mask->mask_len = (nmasks + 3)/4;
memset(bits, 0, mask->mask_len * 4); memset(bits, 0, mask->mask_len * 4);
for (j = 0; j <= XI_LASTEVENT; j++) for (j = 0; j <= XI2LASTEVENT; j++)
SetBit(bits, j); SetBit(bits, j);
ClearBit(bits, XI_HierarchyChanged); ClearBit(bits, XI_HierarchyChanged);
for (j = 1; j < 6; j++) for (j = 1; j < 6; j++)