summaryrefslogtreecommitdiff
path: root/xfixes/cursor.c
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2012-11-03 20:23:45 -0400
committerPeter Hutterer <peter.hutterer@who-t.net>2012-11-06 10:48:32 +1000
commit944213bbc7099f1e0238f39973653d459efdc2c9 (patch)
tree60114d6f44fe6b19788c89e9352fd678efced407 /xfixes/cursor.c
parent1536bc2d213713af45541a15b5e49c552d8d0592 (diff)
cursor: Clean up barrier finding code a bit
The current code manually unrolls the loop, by finding a barrier, clamping it, and then repeaing the code. Since we want to modify both passes of the loop to support device-specific barriers, make it into an actual loop. Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'xfixes/cursor.c')
-rw-r--r--xfixes/cursor.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index f66bd68cb..45b07c38a 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -1204,6 +1204,7 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode,
mode == Relative) {
int ox, oy;
int dir;
+ int i;
struct PointerBarrier *nearest = NULL;
/* where are we coming from */
@@ -1218,8 +1219,12 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode,
*/
dir = barrier_get_direction(ox, oy, *x, *y);
- nearest = barrier_find_nearest(cs, dir, ox, oy, *x, *y);
- if (nearest) {
+#define MAX_BARRIERS 2
+ for (i = 0; i < MAX_BARRIERS; i++) {
+ nearest = barrier_find_nearest(cs, dir, ox, oy, *x, *y);
+ if (!nearest)
+ break;
+
barrier_clamp_to_barrier(nearest, dir, x, y);
if (barrier_is_vertical(nearest)) {
@@ -1230,11 +1235,6 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode,
dir &= ~(BarrierNegativeY | BarrierPositiveY);
oy = *y;
}
-
- nearest = barrier_find_nearest(cs, dir, ox, oy, *x, *y);
- if (nearest) {
- barrier_clamp_to_barrier(nearest, dir, x, y);
- }
}
}