Skip to content

Commit

Permalink
cursor: Revise edge cases for the pointer moving towards barriers
Browse files Browse the repository at this point in the history
Since barriers block the invisible line between pixels, that means
that we need to explicitly check the boundaries, or else we'll have
a potential off-by-one error. This fixes issues when trying to move
down or right across a barrier and having the pointer visibly bounce.

Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
magcius authored and whot committed Nov 29, 2012
1 parent 1712a45 commit a51b2c3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions xfixes/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,11 @@ barrier_is_blocking(const struct PointerBarrier * barrier,
if (dir & BarrierNegativeX && x1 == (barrier->x1 - 1))
return FALSE;
/* startpoint adjacent to barrier, moving towards -> block */
if (x1 == barrier->x1 && y1 >= barrier->y1 && y1 <= barrier->y2) {
if (dir & BarrierPositiveX && x1 == (barrier->x1 - 1) && y1 >= barrier->y1 && y1 <= barrier->y2) {
*distance = 0;
return TRUE;
}
if (dir & BarrierNegativeX && x1 == barrier->x1 && y1 >= barrier->y1 && y1 <= barrier->y2) {
*distance = 0;
return TRUE;
}
Expand All @@ -1105,7 +1109,11 @@ barrier_is_blocking(const struct PointerBarrier * barrier,
if (dir & BarrierNegativeY && y1 == (barrier->y1 - 1))
return FALSE;
/* startpoint adjacent to barrier, moving towards -> block */
if (y1 == barrier->y1 && x1 >= barrier->x1 && x1 <= barrier->x2) {
if (dir & BarrierPositiveY && y1 == (barrier->y1 - 1) && x1 >= barrier->x1 && x1 <= barrier->x2) {
*distance = 0;
return TRUE;
}
if (dir & BarrierNegativeY && y1 == barrier->y1 && x1 >= barrier->x1 && x1 <= barrier->x2) {
*distance = 0;
return TRUE;
}
Expand Down

0 comments on commit a51b2c3

Please sign in to comment.