From: Egbert Eich Date: Fri Feb 7 09:19:45 2014 +0100 Subject: [PATCH 2/2]DIX/ConfineTo: Don't bother about the bounding box when grabbing a shaped window Patch-mainline: to be upstreamed Git-commit: 3f7cc03e47a35d05ffb3f7a6de521c41638b4c7a References: bnc#62146 Signed-off-by: Egbert Eich Limiting the the cursor coordinates on the bounding box of a shaped window before applying ConfineTo leads to strange cursor placement when the pointer is located outside the vertial and horizontal strip of this bounding box. Ignoring the bounding box when a shape is set leads to the correct behavior. Signed-off-by: Egbert Eich Reviewed-by: Keith Packard --- dix/events.c | 78 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/dix/events.c b/dix/events.c index 5244781..8aa4af7 100644 --- a/dix/events.c +++ b/dix/events.c @@ -753,17 +753,19 @@ CheckPhysLimits(DeviceIntPtr pDev, CursorPtr cursor, Bool generateEvents, (*pScreen->ConstrainCursor) (pDev, pScreen, &pSprite->physLimits); } - /* constrain the pointer to those limits */ - if (new.x < pSprite->physLimits.x1) - new.x = pSprite->physLimits.x1; - else if (new.x >= pSprite->physLimits.x2) - new.x = pSprite->physLimits.x2 - 1; - if (new.y < pSprite->physLimits.y1) - new.y = pSprite->physLimits.y1; - else if (new.y >= pSprite->physLimits.y2) - new.y = pSprite->physLimits.y2 - 1; if (pSprite->hotShape) ConfineToShape(pDev, pSprite->hotShape, &new.x, &new.y); + else { + /* constrain the pointer to those limits */ + if (new.x < pSprite->physLimits.x1) + new.x = pSprite->physLimits.x1; + else if (new.x >= pSprite->physLimits.x2) + new.x = pSprite->physLimits.x2 - 1; + if (new.y < pSprite->physLimits.y1) + new.y = pSprite->physLimits.y1; + else if (new.y >= pSprite->physLimits.y2) + new.y = pSprite->physLimits.y2 - 1; + } if (( #ifdef PANORAMIX noPanoramiXExtension && @@ -914,7 +916,8 @@ ConfineCursorToWindow(DeviceIntPtr pDev, WindowPtr pWin, Bool generateEvents, return; } #endif - pSprite->hotLimits = *RegionExtents(&pWin->borderSize); +// if (!wBoundingShape(pWin)) + pSprite->hotLimits = *RegionExtents(&pWin->borderSize); pSprite->hotShape = wBoundingShape(pWin) ? &pWin->borderSize : NullRegion; CheckPhysLimits(pDev, pSprite->current, generateEvents, @@ -3039,17 +3042,19 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev) pSprite->hot.x = ev->root_x; pSprite->hot.y = ev->root_y; - if (pSprite->hot.x < pSprite->physLimits.x1) - pSprite->hot.x = pSprite->physLimits.x1; - else if (pSprite->hot.x >= pSprite->physLimits.x2) - pSprite->hot.x = pSprite->physLimits.x2 - 1; - if (pSprite->hot.y < pSprite->physLimits.y1) - pSprite->hot.y = pSprite->physLimits.y1; - else if (pSprite->hot.y >= pSprite->physLimits.y2) - pSprite->hot.y = pSprite->physLimits.y2 - 1; if (pSprite->hotShape) ConfineToShape(pDev, pSprite->hotShape, &pSprite->hot.x, &pSprite->hot.y); + else { + if (pSprite->hot.x < pSprite->physLimits.x1) + pSprite->hot.x = pSprite->physLimits.x1; + else if (pSprite->hot.x >= pSprite->physLimits.x2) + pSprite->hot.x = pSprite->physLimits.x2 - 1; + if (pSprite->hot.y < pSprite->physLimits.y1) + pSprite->hot.y = pSprite->physLimits.y1; + else if (pSprite->hot.y >= pSprite->physLimits.y2) + pSprite->hot.y = pSprite->physLimits.y2 - 1; + } pSprite->hotPhys = pSprite->hot; if ((pSprite->hotPhys.x != ev->root_x) || @@ -3516,17 +3521,18 @@ XineramaWarpPointer(ClientPtr client) x += stuff->dstX; y += stuff->dstY; - if (x < pSprite->physLimits.x1) - x = pSprite->physLimits.x1; - else if (x >= pSprite->physLimits.x2) - x = pSprite->physLimits.x2 - 1; - if (y < pSprite->physLimits.y1) - y = pSprite->physLimits.y1; - else if (y >= pSprite->physLimits.y2) - y = pSprite->physLimits.y2 - 1; if (pSprite->hotShape) ConfineToShape(PickPointer(client), pSprite->hotShape, &x, &y); - + else { + if (x < pSprite->physLimits.x1) + x = pSprite->physLimits.x1; + else if (x >= pSprite->physLimits.x2) + x = pSprite->physLimits.x2 - 1; + if (y < pSprite->physLimits.y1) + y = pSprite->physLimits.y1; + else if (y >= pSprite->physLimits.y2) + y = pSprite->physLimits.y2 - 1; + } XineramaSetCursorPosition(PickPointer(client), x, y, TRUE); return Success; @@ -3619,16 +3625,18 @@ ProcWarpPointer(ClientPtr client) y = newScreen->height - 1; if (newScreen == pSprite->hotPhys.pScreen) { - if (x < pSprite->physLimits.x1) - x = pSprite->physLimits.x1; - else if (x >= pSprite->physLimits.x2) - x = pSprite->physLimits.x2 - 1; - if (y < pSprite->physLimits.y1) - y = pSprite->physLimits.y1; - else if (y >= pSprite->physLimits.y2) - y = pSprite->physLimits.y2 - 1; if (pSprite->hotShape) ConfineToShape(dev, pSprite->hotShape, &x, &y); + else { + if (x < pSprite->physLimits.x1) + x = pSprite->physLimits.x1; + else if (x >= pSprite->physLimits.x2) + x = pSprite->physLimits.x2 - 1; + if (y < pSprite->physLimits.y1) + y = pSprite->physLimits.y1; + else if (y >= pSprite->physLimits.y2) + y = pSprite->physLimits.y2 - 1; + } (*newScreen->SetCursorPosition) (dev, newScreen, x, y, TRUE); } else if (!PointerConfinedToScreen(dev)) {