barriers: Reindent the constrainment hook

This is to make future diffs much cleaner. Best viewed with -w.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Jasper St. Pierre 2012-12-09 22:48:18 -05:00 committed by Peter Hutterer
parent 97da74c80e
commit 85a37ddcc2

View File

@ -311,43 +311,44 @@ input_constrain_cursor(DeviceIntPtr dev, ScreenPtr screen,
BarrierScreenPtr cs = GetBarrierScreen(screen); BarrierScreenPtr cs = GetBarrierScreen(screen);
int x = dest_x, int x = dest_x,
y = dest_y; y = dest_y;
int dir;
int i;
struct PointerBarrier *nearest = NULL;
PointerBarrierClientPtr c;
if (!xorg_list_is_empty(&cs->barriers) && !IsFloating(dev)) { if (xorg_list_is_empty(&cs->barriers) || IsFloating(dev))
int dir; goto out;
int i;
struct PointerBarrier *nearest = NULL;
PointerBarrierClientPtr c;
/* How this works: /* How this works:
* Given the origin and the movement vector, get the nearest barrier * Given the origin and the movement vector, get the nearest barrier
* to the origin that is blocking the movement. * to the origin that is blocking the movement.
* Clamp to that barrier. * Clamp to that barrier.
* Then, check from the clamped intersection to the original * Then, check from the clamped intersection to the original
* destination, again finding the nearest barrier and clamping. * destination, again finding the nearest barrier and clamping.
*/ */
dir = barrier_get_direction(current_x, current_y, x, y); dir = barrier_get_direction(current_x, current_y, x, y);
#define MAX_BARRIERS 2 #define MAX_BARRIERS 2
for (i = 0; i < MAX_BARRIERS; i++) { for (i = 0; i < MAX_BARRIERS; i++) {
c = barrier_find_nearest(cs, dev, dir, current_x, current_y, x, y); c = barrier_find_nearest(cs, dev, dir, current_x, current_y, x, y);
if (!c) if (!c)
break; break;
nearest = &c->barrier; nearest = &c->barrier;
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)) {
dir &= ~(BarrierNegativeX | BarrierPositiveX); dir &= ~(BarrierNegativeX | BarrierPositiveX);
current_x = x; current_x = x;
} }
else if (barrier_is_horizontal(nearest)) { else if (barrier_is_horizontal(nearest)) {
dir &= ~(BarrierNegativeY | BarrierPositiveY); dir &= ~(BarrierNegativeY | BarrierPositiveY);
current_y = y; current_y = y;
}
} }
} }
out:
*out_x = x; *out_x = x;
*out_y = y; *out_y = y;
} }