Skip to content

Commit bed7d7f

Browse files
rtcmjeremyhu
authored andcommitted
randr: Make the RRConstrainCursorHarder logic the same as miPointerSetPosition
The constraining logic in RRConstrainCursorHarder allows the cursor to reach crtc positions of x = width and y = height while the constraining code in miPointerSetPosition only allows it to reach x = width - 1 and y = height - 1 for the analogous screen case. This patch makes the former's logic equivalent to the latter's which allows applications to benefit from Fitts's law. E.g. a maximized application adjacent to a crtc border wouldn't get pointer events if the user moved the pointer all the way until it's contained. Signed-off-by: Rui Matos <[email protected]> Reviewed-by: Daniel Stone <[email protected]> Signed-off-by: Keith Packard <[email protected]> (cherry picked from commit 9cc44b9)
1 parent 4689c84 commit bed7d7f

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

randr/rrcrtc.c

+10-19
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x,
14651465

14661466
crtc_bounds(crtc, &left, &right, &top, &bottom);
14671467

1468-
if ((*x >= left) && (*x <= right) && (*y >= top) && (*y <= bottom))
1468+
if ((*x >= left) && (*x < right) && (*y >= top) && (*y < bottom))
14691469
return;
14701470
}
14711471

@@ -1481,24 +1481,15 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x,
14811481
crtc_bounds(crtc, &left, &right, &top, &bottom);
14821482
miPointerGetPosition(pDev, &nx, &ny);
14831483

1484-
if ((nx >= left) && (nx <= right) && (ny >= top) && (ny <= bottom)) {
1485-
if ((*x <= left) || (*x >= right)) {
1486-
int dx = *x - nx;
1487-
1488-
if (dx > 0)
1489-
*x = right;
1490-
else if (dx < 0)
1491-
*x = left;
1492-
}
1493-
1494-
if ((*y <= top) || (*y >= bottom)) {
1495-
int dy = *y - ny;
1496-
1497-
if (dy > 0)
1498-
*y = bottom;
1499-
else if (dy < 0)
1500-
*y = top;
1501-
}
1484+
if ((nx >= left) && (nx < right) && (ny >= top) && (ny < bottom)) {
1485+
if (*x < left)
1486+
*x = left;
1487+
if (*x >= right)
1488+
*x = right - 1;
1489+
if (*y < top)
1490+
*y = top;
1491+
if (*y >= bottom)
1492+
*y = bottom - 1;
15021493

15031494
return;
15041495
}

0 commit comments

Comments
 (0)