From 0da7eb18ea20644fd8bcb99cea78f82568a126b3 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 6 Sep 2021 18:01:58 +0200 Subject: [PATCH] surface: add WLR_SURFACE_STATE_SUBSURFACES This allows to figure out when the subsurface list has changed: subsurface added, removed, or re-ordered. In the case where the subsurface list hasn't changed, some book-keeping operations can be skipped. --- include/wlr/types/wlr_surface.h | 1 + types/wlr_surface.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index 4b464401c..dd010b5a8 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -27,6 +27,7 @@ enum wlr_surface_state_field { WLR_SURFACE_STATE_SCALE = 1 << 6, WLR_SURFACE_STATE_FRAME_CALLBACK_LIST = 1 << 7, WLR_SURFACE_STATE_VIEWPORT = 1 << 8, + WLR_SURFACE_STATE_SUBSURFACES = 1 << 9, }; struct wlr_surface_state { diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 15001c5cd..2b35c058f 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -698,6 +698,7 @@ static void subsurface_destroy(struct wlr_subsurface *subsurface) { wl_list_remove(&subsurface->surface_destroy.link); if (subsurface->parent) { + subsurface->parent->pending.committed |= WLR_SURFACE_STATE_SUBSURFACES; wl_list_remove(&subsurface->current.link); wl_list_remove(&subsurface->pending.link); wl_list_remove(&subsurface->parent_destroy.link); @@ -947,6 +948,7 @@ static void subsurface_handle_place_above(struct wl_client *client, node = &sibling->pending.link; } + subsurface->parent->pending.committed |= WLR_SURFACE_STATE_SUBSURFACES; wl_list_remove(&subsurface->pending.link); wl_list_insert(node, &subsurface->pending.link); @@ -979,6 +981,7 @@ static void subsurface_handle_place_below(struct wl_client *client, node = &sibling->pending.link; } + subsurface->parent->pending.committed |= WLR_SURFACE_STATE_SUBSURFACES; wl_list_remove(&subsurface->pending.link); wl_list_insert(node->prev, &subsurface->pending.link); @@ -1190,6 +1193,7 @@ struct wlr_subsurface *subsurface_create(struct wlr_surface *surface, // link parent subsurface->parent = parent; + subsurface->parent->pending.committed |= WLR_SURFACE_STATE_SUBSURFACES; wl_signal_add(&parent->events.destroy, &subsurface->parent_destroy); subsurface->parent_destroy.notify = subsurface_handle_parent_destroy; wl_list_insert(parent->current.subsurfaces_above.prev, &subsurface->current.link);