[PATCH xserver 03/10] Input: Pass sprite instead of device to FixUpEventFromWindow
Peter Hutterer
peter.hutterer at who-t.net
Tue Dec 21 17:36:47 PST 2010
On Fri, Dec 17, 2010 at 05:13:28PM +0000, Daniel Stone wrote:
> Since FixUpEventFromWindow only uses the sprite trace to determine the
> window stack, pass in a sprite instead of hardcoding the device sprite,
> so we can deliver to windows other than the one currently containing the
> sprite.
>
> Signed-off-by: Daniel Stone <daniel at fooishbar.org>
> ---
> Xi/exevents.c | 3 ++-
> dix/events.c | 43 +++++++++++++++++++++----------------------
> include/input.h | 3 ++-
> include/inputstr.h | 4 ++--
> 4 files changed, 27 insertions(+), 26 deletions(-)
>
> diff --git a/Xi/exevents.c b/Xi/exevents.c
> index 8615fd4..327873e 100644
> --- a/Xi/exevents.c
> +++ b/Xi/exevents.c
> @@ -1261,7 +1261,8 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
> 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,
> GetEventFilter(dev, (xEvent*)xi2event), NullGrab);
> diff --git a/dix/events.c b/dix/events.c
> index 4e2dd89..4aa71c1 100644
> --- a/dix/events.c
> +++ b/dix/events.c
> @@ -2181,9 +2181,8 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
> 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];
> Window child = None;
>
> @@ -2222,16 +2221,14 @@ static Window FindChildForEvent(DeviceIntPtr dev, WindowPtr event)
> */
> void
> FixUpEventFromWindow(
> - DeviceIntPtr pDev,
> + SpritePtr pSprite,
> xEvent *xE,
> WindowPtr pWin,
> Window child,
> Bool calcChild)
> {
> - SpritePtr pSprite = pDev->spriteInfo->sprite;
> -
> if (calcChild)
> - child = FindChildForEvent(pDev, pWin);
> + child = FindChildForEvent(pSprite, pWin);
>
> if (XI2_EVENT(xE))
> {
> @@ -2247,7 +2244,7 @@ FixUpEventFromWindow(
> event->evtype == XI_PropertyEvent)
> return;
>
> - event->root = RootWindow(pDev)->drawable.id;
> + event->root = pSprite->spriteTrace[0]->drawable.id;
> event->event = pWin->drawable.id;
> if (pSprite->hot.pScreen == pWin->drawable.pScreen)
> {
> @@ -2268,7 +2265,7 @@ FixUpEventFromWindow(
>
> } else
> {
> - XE_KBPTR.root = RootWindow(pDev)->drawable.id;
> + XE_KBPTR.root = pSprite->spriteTrace[0]->drawable.id;
can you please add a macro similar to RootWindow() so the code is more
obvious to read. is RootWindow() still used now? maybe you can just change
that. other than that,
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
please send me an updated patch and i'll include it in my next pull.
Cheers,
Peter
> XE_KBPTR.event = pWin->drawable.id;
> if (pSprite->hot.pScreen == pWin->drawable.pScreen)
> {
> @@ -2385,6 +2382,7 @@ int
> DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
> WindowPtr stopAt, DeviceIntPtr dev)
> {
> + SpritePtr pSprite = dev->spriteInfo->sprite;
> Window child = None;
> Mask filter;
> int deliveries = 0;
> @@ -2407,7 +2405,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
> {
> /* XXX: XACE */
> filter = GetEventFilter(dev, xi2);
> - FixUpEventFromWindow(dev, xi2, pWin, child, FALSE);
> + FixUpEventFromWindow(pSprite, xi2, pWin, child, FALSE);
> deliveries = DeliverEventsToWindow(dev, pWin, xi2, 1,
> filter, grab);
> free(xi2);
> @@ -2425,7 +2423,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
> if (rc == Success) {
> if (XaceHook(XACE_SEND_ACCESS, NULL, dev, pWin, xE, count) == Success) {
> filter = GetEventFilter(dev, xE);
> - FixUpEventFromWindow(dev, xE, pWin, child, FALSE);
> + FixUpEventFromWindow(pSprite, xE, pWin, child, FALSE);
> deliveries = DeliverEventsToWindow(dev, pWin, xE, count,
> filter, grab);
> if (deliveries > 0)
> @@ -2443,7 +2441,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
> if (rc == Success) {
> if (XaceHook(XACE_SEND_ACCESS, NULL, dev, pWin, &core, 1) == Success) {
> filter = GetEventFilter(dev, &core);
> - FixUpEventFromWindow(dev, &core, pWin, child, FALSE);
> + FixUpEventFromWindow(pSprite, &core, pWin, child, FALSE);
> deliveries = DeliverEventsToWindow(dev, pWin, &core, 1,
> filter, grab);
> if (deliveries > 0)
> @@ -3378,6 +3376,7 @@ CheckPassiveGrabsOnWindow(
> DeviceEvent *event,
> BOOL checkCore)
> {
> + SpritePtr pSprite = device->spriteInfo->sprite;
> GrabPtr grab = wPassiveGrabs(pWin);
> GrabRec tempGrab;
> GrabInfoPtr grabinfo;
> @@ -3541,7 +3540,7 @@ CheckPassiveGrabsOnWindow(
>
> if (xE)
> {
> - FixUpEventFromWindow(device, xE, grab->window, None, TRUE);
> + FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
>
> TryClientEvents(rClient(grab), device, xE, count,
> GetEventFilter(device, xE),
> @@ -3693,7 +3692,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
> {
> /* XXX: XACE */
> 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,
> filter, NullGrab);
> if (deliveries > 0)
> @@ -3706,7 +3705,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
> if (rc == 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,
> GetEventFilter(keybd, xE),
> NullGrab);
> @@ -3722,7 +3721,8 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
> rc = EventToCore(event, &core);
> if (rc == 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,
> GetEventFilter(keybd, &core),
> NullGrab);
> @@ -3812,8 +3812,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
> rc = EventToCore(event, &core);
> if (rc == Success)
> {
> - FixUpEventFromWindow(thisDev, &core, grab->window,
> - None, TRUE);
> + FixUpEventFromWindow(pSprite, &core, grab->window, None, TRUE);
> if (XaceHook(XACE_SEND_ACCESS, 0, thisDev,
> grab->window, &core, 1) ||
> XaceHook(XACE_RECEIVE_ACCESS, rClient(grab),
> @@ -3840,7 +3839,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
> grab->xi2mask[XIAllMasterDevices][evtype/8] |
> grab->xi2mask[thisDev->id][evtype/8];
> /* try XI2 event */
> - FixUpEventFromWindow(thisDev, xi2, grab->window, None, TRUE);
> + FixUpEventFromWindow(pSprite, xi2, grab->window, None, TRUE);
> /* XXX: XACE */
> deliveries = TryClientEvents(rClient(grab), thisDev, xi2, 1, mask,
> GetEventFilter(thisDev, xi2), grab);
> @@ -3861,8 +3860,7 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
> else
> mask = grab->eventMask;
>
> - FixUpEventFromWindow(thisDev, xi, grab->window,
> - None, TRUE);
> + FixUpEventFromWindow(pSprite, xi, grab->window, None, TRUE);
>
> if (XaceHook(XACE_SEND_ACCESS, 0, thisDev,
> grab->window, xi, count) ||
> @@ -4208,7 +4206,7 @@ CoreEnterLeaveEvent(
> event.u.enterLeave.rootX = mouse->spriteInfo->sprite->hot.x;
> event.u.enterLeave.rootY = mouse->spriteInfo->sprite->hot.y;
> /* 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 */
> event.u.enterLeave.child = child;
> event.u.enterLeave.flags = event.u.keyButtonPointer.sameScreen ?
> @@ -4308,7 +4306,8 @@ DeviceEnterLeaveEvent(
> 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);
>
> diff --git a/include/input.h b/include/input.h
> index fef69a1..31fdc52 100644
> --- a/include/input.h
> +++ b/include/input.h
> @@ -103,6 +103,7 @@ typedef struct _OtherClients *OtherClientsPtr;
> typedef struct _InputClients *InputClientsPtr;
> typedef struct _DeviceIntRec *DeviceIntPtr;
> typedef struct _ClassesRec *ClassesPtr;
> +typedef struct _SpriteRec *SpritePtr;
> typedef union _GrabMask GrabMask;
>
> typedef struct _EventList {
> @@ -527,7 +528,7 @@ extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
> /* misc event helpers */
> extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
> extern Mask GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev);
> -void FixUpEventFromWindow(DeviceIntPtr pDev,
> +void FixUpEventFromWindow(SpritePtr pSprite,
> xEvent *xE,
> WindowPtr pWin,
> Window child,
> diff --git a/include/inputstr.h b/include/inputstr.h
> index 44de9c4..bada398 100644
> --- a/include/inputstr.h
> +++ b/include/inputstr.h
> @@ -363,7 +363,7 @@ typedef struct _ClassesRec {
> /**
> * Sprite information for a device.
> */
> -typedef struct {
> +typedef struct _SpriteRec {
> CursorPtr current;
> BoxRec hotLimits; /* logical constraints of hot spot */
> Bool confined; /* confined to screen */
> @@ -399,7 +399,7 @@ typedef struct {
> ScreenPtr pEnqueueScreen;
> ScreenPtr pDequeueScreen;
>
> -} SpriteRec, *SpritePtr;
> +} SpriteRec;
>
> /* Device properties */
> typedef struct _XIPropertyValue
> --
> 1.7.2.3
More information about the xorg-devel
mailing list