mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-03-30 11:11:21 -04:00
util/box: introduce wlr_fbox_contains_box
Signed-off-by: Loukas Agorgianitis <loukas@agorgianitis.com>
This commit is contained in:
parent
72c31255c3
commit
3f5d8e1d48
2 changed files with 19 additions and 0 deletions
|
|
@ -87,6 +87,14 @@ bool wlr_box_contains_point(const struct wlr_box *box, double x, double y);
|
||||||
*/
|
*/
|
||||||
bool wlr_box_contains_box(const struct wlr_box *bigger, const struct wlr_box *smaller);
|
bool wlr_box_contains_box(const struct wlr_box *bigger, const struct wlr_box *smaller);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies that a box is fully contained within another box.
|
||||||
|
*
|
||||||
|
* Returns true if the "smaller" box is fully contained within the "bigger" box.
|
||||||
|
* If either of the boxes are empty, false is returned.
|
||||||
|
*/
|
||||||
|
bool wlr_fbox_contains_box(const struct wlr_fbox *bigger, const struct wlr_fbox *smaller);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether a box is empty or not.
|
* Checks whether a box is empty or not.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
11
util/box.c
11
util/box.c
|
|
@ -122,6 +122,17 @@ bool wlr_box_contains_box(const struct wlr_box *bigger, const struct wlr_box *sm
|
||||||
smaller->y + smaller->height <= bigger->y + bigger->height;
|
smaller->y + smaller->height <= bigger->y + bigger->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wlr_fbox_contains_box(const struct wlr_fbox *bigger, const struct wlr_fbox *smaller) {
|
||||||
|
if (wlr_fbox_empty(bigger) || wlr_fbox_empty(smaller)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return smaller->x >= bigger->x &&
|
||||||
|
smaller->x + smaller->width <= bigger->x + bigger->width &&
|
||||||
|
smaller->y >= bigger->y &&
|
||||||
|
smaller->y + smaller->height <= bigger->y + bigger->height;
|
||||||
|
}
|
||||||
|
|
||||||
void wlr_box_transform(struct wlr_box *dest, const struct wlr_box *box,
|
void wlr_box_transform(struct wlr_box *dest, const struct wlr_box *box,
|
||||||
enum wl_output_transform transform, int width, int height) {
|
enum wl_output_transform transform, int width, int height) {
|
||||||
struct wlr_box src = {0};
|
struct wlr_box src = {0};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue