util/box: transform empty boxes' origins

Not a huge fan of this, but changing this behavior would be a breaking change
to a stable API.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3650
This commit is contained in:
Kirill Primak 2023-05-24 09:26:34 +03:00 committed by Simon Ser
parent 09f5a00585
commit dc6402d153
1 changed files with 6 additions and 10 deletions

View File

@ -71,13 +71,11 @@ bool wlr_box_contains_point(const struct wlr_box *box, double x, double y) {
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) {
if (wlr_box_empty(box)) { struct wlr_box src = {0};
*dest = (struct wlr_box){0}; if (box != NULL) {
return; src = *box;
} }
struct wlr_box src = *box;
if (transform % 2 == 0) { if (transform % 2 == 0) {
dest->width = src.width; dest->width = src.width;
dest->height = src.height; dest->height = src.height;
@ -128,13 +126,11 @@ bool wlr_fbox_empty(const struct wlr_fbox *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) {
if (wlr_fbox_empty(box)) { struct wlr_fbox src = {0};
*dest = (struct wlr_fbox){0}; if (box != NULL) {
return; src = *box;
} }
struct wlr_fbox src = *box;
if (transform % 2 == 0) { if (transform % 2 == 0) {
dest->width = src.width; dest->width = src.width;
dest->height = src.height; dest->height = src.height;