Skip to content

Commit

Permalink
#1220 fix off-by-one
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Apr 28, 2022
1 parent 7e9b09b commit 3202ff2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,20 +490,20 @@ struct window_node *view_find_min_depth_leaf_node(struct window_node *node)
static inline bool area_is_in_direction(struct area *r1, CGPoint r1_max, struct area *r2, CGPoint r2_max, int direction)
{
if (direction == DIR_NORTH && r1_max.y <= r2->y) return false;
if (direction == DIR_EAST && r2_max.x < r1->x) return false;
if (direction == DIR_SOUTH && r2_max.y < r1->y) return false;
if (direction == DIR_EAST && r2_max.x <= r1->x) return false;
if (direction == DIR_SOUTH && r2_max.y <= r1->y) return false;
if (direction == DIR_WEST && r1_max.x <= r2->x) return false;

if (direction == DIR_NORTH || direction == DIR_SOUTH) {
return ((r2_max.x >= r1->x && r2_max.x <= r1_max.x) ||
(r2->x <= r1->x && r2_max.x >= r1_max.x) ||
(r2->x >= r1->x && r2->x <= r1_max.x));
return ((r2_max.x > r1->x && r2_max.x <= r1_max.x) ||
(r2->x < r1->x && r2_max.x > r1_max.x) ||
(r2->x >= r1->x && r2->x < r1_max.x));
}

if (direction == DIR_EAST || direction == DIR_WEST) {
return ((r2_max.y >= r1->y && r2_max.y <= r1_max.y) ||
(r2->y <= r1->y && r2_max.y >= r1_max.y) ||
(r2->y >= r1->y && r2->y <= r1_max.y));
return ((r2_max.y > r1->y && r2_max.y <= r1_max.y) ||
(r2->y < r1->y && r2_max.y > r1_max.y) ||
(r2->y >= r1->y && r2->y < r1_max.y));
}

return false;
Expand Down

0 comments on commit 3202ff2

Please sign in to comment.