diff options
author | Rui Matos <tiagomatos@gmail.com> | 2011-11-01 21:32:36 +0000 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2011-11-28 09:00:52 -0800 |
commit | bed7d7f31ed48cbf0931ca77fdac135e514a2a44 (patch) | |
tree | 7fa61ce68ce3c83cd4c09097a616e58777089fc7 | |
parent | 4689c84a07f87d35492feeae2bc59642c31b6eb3 (diff) |
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 <tiagomatos@gmail.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 9cc44b955b27de33348d6a20bebc9704930ee18e)
-rw-r--r-- | randr/rrcrtc.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 0437795c4..305a2708e 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -1465,7 +1465,7 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, crtc_bounds(crtc, &left, &right, &top, &bottom); - if ((*x >= left) && (*x <= right) && (*y >= top) && (*y <= bottom)) + if ((*x >= left) && (*x < right) && (*y >= top) && (*y < bottom)) return; } @@ -1481,24 +1481,15 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, crtc_bounds(crtc, &left, &right, &top, &bottom); miPointerGetPosition(pDev, &nx, &ny); - if ((nx >= left) && (nx <= right) && (ny >= top) && (ny <= bottom)) { - if ((*x <= left) || (*x >= right)) { - int dx = *x - nx; - - if (dx > 0) - *x = right; - else if (dx < 0) - *x = left; - } - - if ((*y <= top) || (*y >= bottom)) { - int dy = *y - ny; - - if (dy > 0) - *y = bottom; - else if (dy < 0) - *y = top; - } + if ((nx >= left) && (nx < right) && (ny >= top) && (ny < bottom)) { + if (*x < left) + *x = left; + if (*x >= right) + *x = right - 1; + if (*y < top) + *y = top; + if (*y >= bottom) + *y = bottom - 1; return; } |