From 227fe601ad2d6318694d4c7cbc1e858f90218fdd Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Sun, 4 Jan 2026 23:55:23 -0500 Subject: [PATCH] common: add box_midpoint() --- include/common/box.h | 6 ++++++ src/common/box.c | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/include/common/box.h b/include/common/box.h index 9f18b45e..10608c25 100644 --- a/include/common/box.h +++ b/include/common/box.h @@ -4,6 +4,12 @@ #include +struct point { + int x, y; +}; + +struct point box_midpoint(const struct wlr_box *box); + bool box_intersects(struct wlr_box *box_a, struct wlr_box *box_b); /* Returns the bounding box of 2 boxes */ diff --git a/src/common/box.c b/src/common/box.c index 5cc91bf3..3cbe09df 100644 --- a/src/common/box.c +++ b/src/common/box.c @@ -2,6 +2,15 @@ #include "common/box.h" #include "common/macros.h" +struct point +box_midpoint(const struct wlr_box *box) +{ + return (struct point) { + .x = box->x + box->width / 2, + .y = box->y + box->height / 2, + }; +} + bool box_intersects(struct wlr_box *box_a, struct wlr_box *box_b) {