subsurface: don't add to parent list immediately

This commit is contained in:
Kirill Primak 2021-12-06 14:59:00 +03:00 committed by Simon Ser
parent 7964bdae76
commit 0fcc842291
2 changed files with 11 additions and 5 deletions

View File

@ -185,6 +185,7 @@ struct wlr_subsurface {
bool synchronized; bool synchronized;
bool reordered; bool reordered;
bool mapped; bool mapped;
bool added;
struct wl_listener surface_destroy; struct wl_listener surface_destroy;
struct wl_listener parent_destroy; struct wl_listener parent_destroy;

View File

@ -511,6 +511,12 @@ static void subsurface_parent_commit(struct wlr_subsurface *subsurface) {
wlr_surface_for_each_surface(surface, wlr_surface_for_each_surface(surface,
collect_subsurface_damage_iter, subsurface); collect_subsurface_damage_iter, subsurface);
} }
if (!subsurface->added) {
subsurface->added = true;
wlr_signal_emit_safe(&subsurface->parent->events.new_subsurface,
subsurface);
}
} }
static void subsurface_commit(struct wlr_subsurface *subsurface) { static void subsurface_commit(struct wlr_subsurface *subsurface) {
@ -877,12 +883,12 @@ static struct wlr_subsurface *subsurface_find_sibling(
struct wlr_surface *parent = subsurface->parent; struct wlr_surface *parent = subsurface->parent;
struct wlr_subsurface *sibling; struct wlr_subsurface *sibling;
wl_list_for_each(sibling, &parent->current.subsurfaces_below, current.link) { wl_list_for_each(sibling, &parent->pending.subsurfaces_below, pending.link) {
if (sibling->surface == surface && sibling != subsurface) { if (sibling->surface == surface && sibling != subsurface) {
return sibling; return sibling;
} }
} }
wl_list_for_each(sibling, &parent->current.subsurfaces_above, current.link) { wl_list_for_each(sibling, &parent->pending.subsurfaces_above, pending.link) {
if (sibling->surface == surface && sibling != subsurface) { if (sibling->surface == surface && sibling != subsurface) {
return sibling; return sibling;
} }
@ -1134,14 +1140,13 @@ struct wlr_subsurface *subsurface_create(struct wlr_surface *surface,
subsurface->parent = parent; subsurface->parent = parent;
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;
wl_list_insert(parent->current.subsurfaces_above.prev, &subsurface->current.link);
wl_list_init(&subsurface->current.link);
wl_list_insert(parent->pending.subsurfaces_above.prev, wl_list_insert(parent->pending.subsurfaces_above.prev,
&subsurface->pending.link); &subsurface->pending.link);
surface->role_data = subsurface; surface->role_data = subsurface;
wlr_signal_emit_safe(&parent->events.new_subsurface, subsurface);
return subsurface; return subsurface;
} }