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.

(cherry picked from commit f5e7caf599)
This commit is contained in:
Isaac Freund 2025-06-18 13:30:21 +02:00 committed by Simon Zeni
parent 13a62a23a2
commit f3fe6b9a43

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->width = x2 - x1;
dest->height = y2 - y1; 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) { bool wlr_box_contains_point(const struct wlr_box *box, double x, double y) {