util/box: set dest to empty if boxes don't intersect

Currently if both box_a and box_b are non-empty but do not intersect,
this function does not set dest to an empty box. This contradicts the
doc comments and is surprising for users.
This commit is contained in:
Isaac Freund 2025-06-18 13:30:21 +02:00 committed by Simon Ser
parent 98af337175
commit f5e7caf599

View file

@ -67,7 +67,12 @@ bool wlr_box_intersection(struct wlr_box *dest, const struct wlr_box *box_a,
dest->width = x2 - x1;
dest->height = y2 - y1;
return !wlr_box_empty(dest);
if (wlr_box_empty(dest)) {
*dest = (struct wlr_box){0};
return false;
}
return true;
}
bool wlr_box_contains_point(const struct wlr_box *box, double x, double y) {