[PATCH] [DIX/ConfineTo] Don't bother about the bounding box when grabbing a shaped window
Egbert Eich
eich at freedesktop.org
Fri Feb 7 03:51:33 PST 2014
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 <eich at freedesktop.org>
---
dix/events.c | 78 +++++++++++++++++++++++++++++++++---------------------------
1 file changed, 43 insertions(+), 35 deletions(-)
diff --git a/dix/events.c b/dix/events.c
index 8d7d12b..d3b4609 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -758,17 +758,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 &&
@@ -919,7 +921,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,
@@ -3083,17 +3086,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) ||
@@ -3560,17 +3565,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;
@@ -3663,16 +3669,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)) {
--
1.8.1.4
More information about the xorg-devel
mailing list