wlr_{box, fbox}_equal: Consider empty boxes NULL

master
Alexander Orzechowski 2 years ago committed by Kirill Primak
parent acaf57dcca
commit d495fb8c04

@ -754,16 +754,14 @@ void wlr_scene_buffer_set_opaque_region(struct wlr_scene_buffer *scene_buffer,
void wlr_scene_buffer_set_source_box(struct wlr_scene_buffer *scene_buffer, void wlr_scene_buffer_set_source_box(struct wlr_scene_buffer *scene_buffer,
const struct wlr_fbox *box) { const struct wlr_fbox *box) {
struct wlr_fbox *cur = &scene_buffer->src_box; if (wlr_fbox_equal(&scene_buffer->src_box, box)) {
if ((wlr_fbox_empty(box) && wlr_fbox_empty(cur)) ||
(box != NULL && wlr_fbox_equal(cur, box))) {
return; return;
} }
if (box != NULL) { if (box != NULL) {
memcpy(cur, box, sizeof(*box)); scene_buffer->src_box = *box;
} else { } else {
memset(cur, 0, sizeof(*cur)); scene_buffer->src_box = (struct wlr_fbox){0};
} }
scene_node_update(&scene_buffer->node, NULL); scene_node_update(&scene_buffer->node, NULL);

@ -175,6 +175,13 @@ void wlr_fbox_transform(struct wlr_fbox *dest, const struct wlr_fbox *box,
#ifdef WLR_USE_UNSTABLE #ifdef WLR_USE_UNSTABLE
bool wlr_box_equal(const struct wlr_box *a, const struct wlr_box *b) { bool wlr_box_equal(const struct wlr_box *a, const struct wlr_box *b) {
if (wlr_box_empty(a)) {
a = NULL;
}
if (wlr_box_empty(b)) {
b = NULL;
}
if (a == NULL || b == NULL) { if (a == NULL || b == NULL) {
return a == b; return a == b;
} }
@ -184,6 +191,13 @@ bool wlr_box_equal(const struct wlr_box *a, const struct wlr_box *b) {
} }
bool wlr_fbox_equal(const struct wlr_fbox *a, const struct wlr_fbox *b) { bool wlr_fbox_equal(const struct wlr_fbox *a, const struct wlr_fbox *b) {
if (wlr_fbox_empty(a)) {
a = NULL;
}
if (wlr_fbox_empty(b)) {
b = NULL;
}
if (a == NULL || b == NULL) { if (a == NULL || b == NULL) {
return a == b; return a == b;
} }

Loading…
Cancel
Save