common: add box_midpoint()

This commit is contained in:
John Lindgren 2026-01-04 23:55:23 -05:00
parent e11600da9e
commit 227fe601ad
2 changed files with 15 additions and 0 deletions

View file

@ -4,6 +4,12 @@
#include <wlr/util/box.h>
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 */

View file

@ -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)
{