diff options
Diffstat (limited to 'dix')
-rw-r--r-- | dix/dispatch.c | 45 | ||||
-rw-r--r-- | dix/events.c | 171 |
2 files changed, 198 insertions, 18 deletions
diff --git a/dix/dispatch.c b/dix/dispatch.c index 414bd0404..b9768d7b4 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -144,6 +144,10 @@ typedef const char *string; #include "Xserver-dtrace.h" #endif +#ifdef COMPOSITE +#include "compint.h" +#endif + #define mskcnt ((MAXCLIENTS + 31) / 32) #define BITMASK(i) (1U << ((i) & 31)) #define MASKIDX(i) ((i) >> 5) @@ -1177,6 +1181,9 @@ ProcTranslateCoords(ClientPtr client) WindowPtr pWin, pDst; xTranslateCoordsReply rep; int rc; +#ifdef COMPOSITE + DeviceIntPtr mouse = PickPointer(client); +#endif REQUEST_SIZE_MATCH(xTranslateCoordsReq); rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixGetAttrAccess); @@ -1197,16 +1204,47 @@ ProcTranslateCoords(ClientPtr client) } else { - INT16 x, y; + int x, y, rootX, rootY; rep.sameScreen = xTrue; rep.child = None; /* computing absolute coordinates -- adjust to destination later */ x = pWin->drawable.x + stuff->srcX; y = pWin->drawable.y + stuff->srcY; + +#ifdef COMPOSITE + /* + * Transform from source window coordinate space to screen + * and then to destination coordinate space. + */ + CompositeXYScreenFromWindowRootCoordinate (pWin, mouse, x, y, &x, &y); + CompositeXYScreenToWindowRootCoordinate (pDst, mouse, x, y, &x, &y); +#endif + + /* adjust to destination coordinates */ + rep.dstX = x - pDst->drawable.x; + rep.dstY = y - pDst->drawable.y; + + rootX = x; + rootY = y; + pWin = pDst->firstChild; while (pWin) { BoxRec box; + + x = rootX; + y = rootY; + +#ifdef COMPOSITE + /* + * Transform from parent to child. + */ + if (pWin->mapped) + { + CompositeXYParentToChild (pWin, x, y, &x, &y); + } +#endif + if ((pWin->mapped) && (x >= pWin->drawable.x - wBorderWidth (pWin)) && (x < pWin->drawable.x + (int)pWin->drawable.width + @@ -1229,15 +1267,14 @@ ProcTranslateCoords(ClientPtr client) y - pWin->drawable.y, &box)) ) { + rootX = x; + rootY = y; rep.child = pWin->drawable.id; pWin = (WindowPtr) NULL; } else pWin = pWin->nextSib; } - /* adjust to destination coordinates */ - rep.dstX = x - pDst->drawable.x; - rep.dstY = y - pDst->drawable.y; } WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep); return(client->noClientException); diff --git a/dix/events.c b/dix/events.c index 90a2675c4..bb5520af9 100644 --- a/dix/events.c +++ b/dix/events.c @@ -142,6 +142,10 @@ typedef const char *string; #include "Xserver-dtrace.h" #endif +#ifdef COMPOSITE +#include "compint.h" +#endif + #include <X11/extensions/XIproto.h> #include <X11/extensions/XI2proto.h> #include <X11/extensions/XI.h> @@ -760,6 +764,13 @@ CheckPhysLimits( } /* constrain the pointer to those limits */ +#ifdef COMPOSITE + if (pSprite->confineTo) + /* Need the transformed root coordinates */ + CompositeXYScreenToWindowRootCoordinate (pSprite->confineTo, pDev, + new.x, new.y, + &new.x, &new.y); +#endif if (new.x < pSprite->physLimits.x1) new.x = pSprite->physLimits.x1; else @@ -772,6 +783,14 @@ CheckPhysLimits( new.y = pSprite->physLimits.y2 - 1; if (pSprite->hotShape) ConfineToShape(pDev, pSprite->hotShape, &new.x, &new.y); +#ifdef COMPOSITE + if (pSprite->confineTo) + /* Back to screen root coordinates */ + CompositeXYScreenFromWindowRootCoordinate (pSprite->confineTo, pDev, + new.x, new.y, + &new.x, &new.y); +#endif + if ((pScreen != pSprite->hotPhys.pScreen) || (new.x != pSprite->hotPhys.x) || (new.y != pSprite->hotPhys.y)) { @@ -869,6 +888,11 @@ CheckVirtualMotion( } } +#ifdef COMPOSITE + /* Need the transformed root coordinates */ + CompositeXYScreenToWindowRootCoordinate (pWin, pDev, + pSprite->hot.x, pSprite->hot.y, &pSprite->hot.x, &pSprite->hot.y); +#endif lims = *REGION_EXTENTS(pWin->drawable.pScreen, &pWin->borderSize); if (pSprite->hot.x < lims.x1) pSprite->hot.x = lims.x1; @@ -894,6 +918,11 @@ CheckVirtualMotion( if (reg) ConfineToShape(pDev, reg, &pSprite->hot.x, &pSprite->hot.y); +#ifdef COMPOSITE + /* Back to screen root coordinates */ + CompositeXYScreenFromWindowRootCoordinate (pWin, pDev, + pSprite->hot.x, pSprite->hot.y, &pSprite->hot.x, &pSprite->hot.y); +#endif if (qe && ev) { @@ -921,6 +950,10 @@ ConfineCursorToWindow(DeviceIntPtr pDev, WindowPtr pWin, Bool generateEvents, Bo } else { +#ifdef COMPOSITE + pSprite->confineTo = (pWin == WindowTable[pWin->drawable.pScreen->myNum]) + ? NullWindow : pWin; +#endif #ifdef PANORAMIX if(!noPanoramiXExtension) { XineramaConfineCursorToWindow(pDev, pWin, generateEvents); @@ -2014,6 +2047,7 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents, return 1; } + /** * Deliver events to a window. At this point, we do not yet know if the event * actually needs to be delivered. May activate a grab if the event is a @@ -2325,8 +2359,28 @@ FixUpEventFromWindow( event->event = pWin->drawable.id; if (pSprite->hot.pScreen == pWin->drawable.pScreen) { - event->event_x = event->root_x - FP1616(pWin->drawable.x, 0); - event->event_y = event->root_y - FP1616(pWin->drawable.y, 0); + int root_x, root_y; + + root_x = event->root_x; + root_y = event->root_y; + +#ifdef COMPOSITE + root_x >>= 16; + root_y >>= 16; + + /* + * rootX and rootY are in screen coordinate space. + * Transform to windows root coordinate space before writing + * events to client. + */ + CompositeXYScreenToWindowRootCoordinate (pWin, pDev, root_x, root_y, + &root_x, &root_y); + + root_x <<= 16; + root_y <<= 16; +#endif + event->event_x = root_x - FP1616(pWin->drawable.x, 0); + event->event_y = root_y - FP1616(pWin->drawable.y, 0); event->child = child; } else { @@ -2339,19 +2393,32 @@ FixUpEventFromWindow( event->evtype == XI_FocusIn || event->evtype == XI_FocusOut) ((xXIEnterEvent*)event)->same_screen = (pSprite->hot.pScreen == pWin->drawable.pScreen); - } else { XE_KBPTR.root = RootWindow(pDev)->drawable.id; XE_KBPTR.event = pWin->drawable.id; if (pSprite->hot.pScreen == pWin->drawable.pScreen) { + int root_x, root_y; + + root_x = XE_KBPTR.rootX; + root_y = XE_KBPTR.rootY; + +#ifdef COMPOSITE + /* + * rootX and rootY are in screen coordinate space. + * Transform to windows root coordinate space before writing + * events to client. + */ + CompositeXYScreenToWindowRootCoordinate (pWin, pDev, root_x, root_y, + &root_x, &root_y); +#endif XE_KBPTR.sameScreen = xTrue; XE_KBPTR.child = child; XE_KBPTR.eventX = - XE_KBPTR.rootX - pWin->drawable.x; + root_x - pWin->drawable.x; XE_KBPTR.eventY = - XE_KBPTR.rootY - pWin->drawable.y; + root_y - pWin->drawable.y; } else { @@ -2642,18 +2709,32 @@ PointInBorderSize(WindowPtr pWin, int x, int y) * @returns the window at the given coordinates. */ static WindowPtr -XYToWindow(DeviceIntPtr pDev, int x, int y) +XYToWindow(DeviceIntPtr pDev, int rootX, int rootY) { WindowPtr pWin; BoxRec box; + int x, y; SpritePtr pSprite; + Bool handle = TRUE; pSprite = pDev->spriteInfo->sprite; pSprite->spriteTraceGood = 1; /* root window still there */ pWin = RootWindow(pDev)->firstChild; while (pWin) { - if ((pWin->mapped) && + x = rootX; + y = rootY; + +#ifdef COMPOSITE + /* + * Transform from parent to child. + */ + if (pWin->mapped) + handle = CompositeXYParentToChild (pWin, x, y, &x, &y); +#endif + + + if ((pWin->mapped) && (handle) && (x >= pWin->drawable.x - wBorderWidth (pWin)) && (x < pWin->drawable.x + (int)pWin->drawable.width + wBorderWidth(pWin)) && @@ -2685,7 +2766,16 @@ XYToWindow(DeviceIntPtr pDev, int x, int y) pSprite->spriteTrace = xrealloc(pSprite->spriteTrace, pSprite->spriteTraceSize*sizeof(WindowPtr)); } +#ifdef COMPOSITE + x -= pWin->drawable.x; + y -= pWin->drawable.y; + pWin = CompositeGetRedirectedWindowInput (pDev, pWin); + x += pWin->drawable.x; + y += pWin->drawable.y; +#endif pSprite->spriteTrace[pSprite->spriteTraceGood++] = pWin; + rootX = x; + rootY = y; pWin = pWin->firstChild; } else @@ -2832,6 +2922,13 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev) pSprite->hot.x = ev->root_x; pSprite->hot.y = ev->root_y; +#ifdef COMPOSITE + if (pSprite->confineTo) + /* Need the transformed root coordinates */ + CompositeXYScreenToWindowRootCoordinate (pSprite->confineTo, pDev, + pSprite->hot.x, pSprite->hot.y, + &pSprite->hot.x, &pSprite->hot.y); +#endif if (pSprite->hot.x < pSprite->physLimits.x1) pSprite->hot.x = pSprite->physLimits.x1; else if (pSprite->hot.x >= pSprite->physLimits.x2) @@ -2842,6 +2939,13 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev) pSprite->hot.y = pSprite->physLimits.y2 - 1; if (pSprite->hotShape) ConfineToShape(pDev, pSprite->hotShape, &pSprite->hot.x, &pSprite->hot.y); +#ifdef COMPOSITE + if (pSprite->confineTo) + /* Back to screen root coordinates */ + CompositeXYScreenFromWindowRootCoordinate (pSprite->confineTo, + pDev, pSprite->hot.x, pSprite->hot.y, + &pSprite->hot.x, &pSprite->hot.y); +#endif pSprite->hotPhys = pSprite->hot; if ((pSprite->hotPhys.x != ev->root_x) || @@ -3075,6 +3179,10 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin) REGION_NULL(pScreen, &pSprite->Reg2); } #endif + +#ifdef COMPOSITE + pSprite->confineTo = NullWindow; +#endif } /** @@ -3240,7 +3348,8 @@ XineramaWarpPointer(ClientPtr client) { WindowPtr dest = NULL; int x, y, rc; - SpritePtr pSprite = PickPointer(client)->spriteInfo->sprite; + DeviceIntPtr dev = PickPointer(client); + SpritePtr pSprite = dev->spriteInfo->sprite; REQUEST(xWarpPointerReq); @@ -3290,6 +3399,12 @@ XineramaWarpPointer(ClientPtr client) x += stuff->dstX; y += stuff->dstY; +#ifdef COMPOSITE + /* Need the transformed root coordinates */ + if (pSprite->confineTo) + CompositeXYScreenToWindowRootCoordinate (pSprite->confineTo, dev, + x, y, &x, &y); +#endif if (x < pSprite->physLimits.x1) x = pSprite->physLimits.x1; else if (x >= pSprite->physLimits.x2) @@ -3299,9 +3414,15 @@ XineramaWarpPointer(ClientPtr client) else if (y >= pSprite->physLimits.y2) y = pSprite->physLimits.y2 - 1; if (pSprite->hotShape) - ConfineToShape(PickPointer(client), pSprite->hotShape, &x, &y); + ConfineToShape(dev, pSprite->hotShape, &x, &y); +#ifdef COMPOSITE + /* Back to screen root coordinates */ + if (pSprite->confineTo) + CompositeXYScreenFromWindowRootCoordinate (pSprite->confineTo, dev, + x, y, &x, &y); +#endif - XineramaSetCursorPosition(PickPointer(client), x, y, TRUE); + XineramaSetCursorPosition(dev, x, y, TRUE); return Success; } @@ -3396,6 +3517,12 @@ ProcWarpPointer(ClientPtr client) if (newScreen == pSprite->hotPhys.pScreen) { +#ifdef COMPOSITE + /* Need the transformed root coordinates */ + if (pSprite->confineTo) + CompositeXYScreenToWindowRootCoordinate (pSprite->confineTo, dev, + x, y, &x, &y); +#endif if (x < pSprite->physLimits.x1) x = pSprite->physLimits.x1; else if (x >= pSprite->physLimits.x2) @@ -3406,6 +3533,12 @@ ProcWarpPointer(ClientPtr client) y = pSprite->physLimits.y2 - 1; if (pSprite->hotShape) ConfineToShape(dev, pSprite->hotShape, &x, &y); +#ifdef COMPOSITE + /* Back to screen root coordinates */ + if (pSprite->confineTo) + CompositeXYScreenFromWindowRootCoordinate (pSprite->confineTo, + dev, x, y, &x, &y); +#endif (*newScreen->SetCursorPosition)(dev, newScreen, x, y, TRUE); } else if (!PointerConfinedToScreen(dev)) @@ -4963,6 +5096,7 @@ ProcQueryPointer(ClientPtr client) DeviceIntPtr keyboard; SpritePtr pSprite; int rc; + int rootX, rootY; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); @@ -4985,14 +5119,23 @@ ProcQueryPointer(ClientPtr client) rep.mask |= XkbStateFieldFromRec(&keyboard->key->xkbInfo->state); rep.length = 0; rep.root = (RootWindow(mouse))->drawable.id; - rep.rootX = pSprite->hot.x; - rep.rootY = pSprite->hot.y; rep.child = None; + + rep.rootX = rootX = pSprite->hot.x; + rep.rootY = rootY = pSprite->hot.y; + if (pSprite->hot.pScreen == pWin->drawable.pScreen) { +#ifdef COMPOSITE + /* + * Return coordinates in windows root coordinate space. + */ + CompositeXYScreenToWindowRootCoordinate (pWin, mouse, rootX, rootY, + &rootX, &rootY); +#endif rep.sameScreen = xTrue; - rep.winX = pSprite->hot.x - pWin->drawable.x; - rep.winY = pSprite->hot.y - pWin->drawable.y; + rep.winX = rootX - pWin->drawable.x; + rep.winY = rootY - pWin->drawable.y; for (t = pSprite->win; t; t = t->parent) if (t->parent == pWin) { |