From 0fcc842291d9d714e9c210839ae72429c5c3eae4 Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Mon, 6 Dec 2021 14:59:00 +0300 Subject: [PATCH] subsurface: don't add to parent list immediately --- include/wlr/types/wlr_surface.h | 1 + types/wlr_surface.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index 4255a1f2..59168eaa 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -185,6 +185,7 @@ struct wlr_subsurface { bool synchronized; bool reordered; bool mapped; + bool added; struct wl_listener surface_destroy; struct wl_listener parent_destroy; diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 42b75f96..d5d49571 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -511,6 +511,12 @@ static void subsurface_parent_commit(struct wlr_subsurface *subsurface) { wlr_surface_for_each_surface(surface, 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) { @@ -877,12 +883,12 @@ static struct wlr_subsurface *subsurface_find_sibling( struct wlr_surface *parent = subsurface->parent; 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) { 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) { return sibling; } @@ -1134,14 +1140,13 @@ struct wlr_subsurface *subsurface_create(struct wlr_surface *surface, subsurface->parent = parent; 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); + + wl_list_init(&subsurface->current.link); wl_list_insert(parent->pending.subsurfaces_above.prev, &subsurface->pending.link); surface->role_data = subsurface; - wlr_signal_emit_safe(&parent->events.new_subsurface, subsurface); - return subsurface; }