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>
This commit is contained in:
parent
1536bc2d21
commit
944213bbc7
|
@ -1204,6 +1204,7 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode,
|
||||||
mode == Relative) {
|
mode == Relative) {
|
||||||
int ox, oy;
|
int ox, oy;
|
||||||
int dir;
|
int dir;
|
||||||
|
int i;
|
||||||
struct PointerBarrier *nearest = NULL;
|
struct PointerBarrier *nearest = NULL;
|
||||||
|
|
||||||
/* where are we coming from */
|
/* where are we coming from */
|
||||||
|
@ -1218,8 +1219,12 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode,
|
||||||
*/
|
*/
|
||||||
dir = barrier_get_direction(ox, oy, *x, *y);
|
dir = barrier_get_direction(ox, oy, *x, *y);
|
||||||
|
|
||||||
|
#define MAX_BARRIERS 2
|
||||||
|
for (i = 0; i < MAX_BARRIERS; i++) {
|
||||||
nearest = barrier_find_nearest(cs, dir, ox, oy, *x, *y);
|
nearest = barrier_find_nearest(cs, dir, ox, oy, *x, *y);
|
||||||
if (nearest) {
|
if (!nearest)
|
||||||
|
break;
|
||||||
|
|
||||||
barrier_clamp_to_barrier(nearest, dir, x, y);
|
barrier_clamp_to_barrier(nearest, dir, x, y);
|
||||||
|
|
||||||
if (barrier_is_vertical(nearest)) {
|
if (barrier_is_vertical(nearest)) {
|
||||||
|
@ -1230,11 +1235,6 @@ CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode,
|
||||||
dir &= ~(BarrierNegativeY | BarrierPositiveY);
|
dir &= ~(BarrierNegativeY | BarrierPositiveY);
|
||||||
oy = *y;
|
oy = *y;
|
||||||
}
|
}
|
||||||
|
|
||||||
nearest = barrier_find_nearest(cs, dir, ox, oy, *x, *y);
|
|
||||||
if (nearest) {
|
|
||||||
barrier_clamp_to_barrier(nearest, dir, x, y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue