surface: add WLR_SURFACE_STATE_SUBSURFACES

This allows to figure out when the subsurface list has changed:
subsurface added or re-ordered. In the case where the subsurface
list hasn't changed, some book-keeping operations can be skipped.
This commit is contained in:
Simon Ser 2023-12-04 15:39:08 +01:00
parent ab924064f2
commit baf35a89f1
2 changed files with 4 additions and 0 deletions

View file

@ -29,6 +29,7 @@ enum wlr_surface_state_field {
WLR_SURFACE_STATE_FRAME_CALLBACK_LIST = 1 << 7, WLR_SURFACE_STATE_FRAME_CALLBACK_LIST = 1 << 7,
WLR_SURFACE_STATE_VIEWPORT = 1 << 8, WLR_SURFACE_STATE_VIEWPORT = 1 << 8,
WLR_SURFACE_STATE_OFFSET = 1 << 9, WLR_SURFACE_STATE_OFFSET = 1 << 9,
WLR_SURFACE_STATE_SUBSURFACES = 1 << 10, // sub-surface added or re-ordered
}; };
struct wlr_surface_state { struct wlr_surface_state {

View file

@ -116,6 +116,7 @@ static void subsurface_handle_place_above(struct wl_client *client,
node = &sibling->pending.link; node = &sibling->pending.link;
} }
subsurface->parent->pending.committed |= WLR_SURFACE_STATE_SUBSURFACES;
wl_list_remove(&subsurface->pending.link); wl_list_remove(&subsurface->pending.link);
wl_list_insert(node, &subsurface->pending.link); wl_list_insert(node, &subsurface->pending.link);
@ -148,6 +149,7 @@ static void subsurface_handle_place_below(struct wl_client *client,
node = &sibling->pending.link; node = &sibling->pending.link;
} }
subsurface->parent->pending.committed |= WLR_SURFACE_STATE_SUBSURFACES;
wl_list_remove(&subsurface->pending.link); wl_list_remove(&subsurface->pending.link);
wl_list_insert(node->prev, &subsurface->pending.link); wl_list_insert(node->prev, &subsurface->pending.link);
@ -410,6 +412,7 @@ static void subcompositor_handle_get_subsurface(struct wl_client *client,
wl_signal_add(&parent->events.destroy, &subsurface->parent_destroy); wl_signal_add(&parent->events.destroy, &subsurface->parent_destroy);
subsurface->parent_destroy.notify = subsurface_handle_parent_destroy; subsurface->parent_destroy.notify = subsurface_handle_parent_destroy;
subsurface->parent->pending.committed |= WLR_SURFACE_STATE_SUBSURFACES;
wl_list_remove(&subsurface->pending.link); wl_list_remove(&subsurface->pending.link);
wl_list_insert(parent->pending.subsurfaces_above.prev, wl_list_insert(parent->pending.subsurfaces_above.prev,
&subsurface->pending.link); &subsurface->pending.link);