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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user