[PATCH 4/5] cursor: Clean up barrier finding code a bit
Jasper St. Pierre
jstpierre at mecheye.net
Sat Nov 3 15:39:35 PDT 2012
From: "Jasper St. Pierre" <jstpierre at mecheye.net>
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 at mecheye.net>
---
xfixes/cursor.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index a34f65c..aac93a7 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);
- }
}
}
--
1.7.12.1
More information about the xorg-devel
mailing list