util/box: introduce wlr_fbox_empty

Same as wlr_box_empty, but for wlr_fbox.
This commit is contained in:
Simon Ser 2021-09-20 17:51:31 +02:00 committed by Simon Zeni
parent 7939bf8cc6
commit fdc22449d6
2 changed files with 15 additions and 3 deletions

View File

@ -78,9 +78,17 @@ bool wlr_box_empty(const struct wlr_box *box);
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);
/**
* Checks whether a box is empty or not.
*
* A wlr_box is considered empty if its width and/or height is zero or negative.
*/
bool wlr_fbox_empty(const struct wlr_fbox *box);
/** /**
* Transforms a floating-point box inside a (0, 0, width, height) box. * Transforms a floating-point box inside a (0, 0, width, height) box.
*/ */
void wlr_fbox_transform(struct wlr_fbox *dest, const struct wlr_fbox *box, void wlr_fbox_transform(struct wlr_fbox *dest, const struct wlr_fbox *box,
enum wl_output_transform transform, double width, double height); enum wl_output_transform transform, double width, double height);
#endif #endif

View File

@ -120,6 +120,10 @@ void wlr_box_transform(struct wlr_box *dest, const struct wlr_box *box,
} }
} }
bool wlr_fbox_empty(const struct wlr_fbox *box) {
return box == NULL || box->width <= 0 || box->height <= 0;
}
void wlr_fbox_transform(struct wlr_fbox *dest, const struct wlr_fbox *box, void wlr_fbox_transform(struct wlr_fbox *dest, const struct wlr_fbox *box,
enum wl_output_transform transform, double width, double height) { enum wl_output_transform transform, double width, double height) {
struct wlr_fbox src = *box; struct wlr_fbox src = *box;