wayland/subsurface: Use unmap helper in destructor & parent_destroyed

Instead of duplicating the code in both.

v2:
* Rename helper to make it clear(er) that it permanently unmaps the
  sub-surface
* Move transaction allocation & commit into the helper

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3364>
This commit is contained in:
Michel Dänzer 2023-11-02 18:42:03 +01:00 committed by Marge Bot
parent 9f4eee33a2
commit 9dc5d98607

View File

@ -398,12 +398,7 @@ wl_subsurface_place_below (struct wl_client *client,
}
static void
wl_subsurface_destructor (struct wl_resource *resource)
{
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
MetaWaylandSurface *parent = surface->protocol_state.parent;
if (parent)
permanently_unmap_subsurface (MetaWaylandSurface *surface)
{
MetaWaylandSubsurfacePlacementOp *op;
MetaWaylandTransaction *transaction;
@ -412,12 +407,21 @@ wl_subsurface_destructor (struct wl_resource *resource)
META_WAYLAND_SUBSURFACE_PLACEMENT_BELOW);
transaction = meta_wayland_transaction_new (surface->compositor);
meta_wayland_transaction_add_placement_op (transaction, parent, op);
meta_wayland_transaction_add_placement_op (transaction,
surface->protocol_state.parent, op);
meta_wayland_transaction_commit (transaction);
surface->protocol_state.parent = NULL;
}
static void
wl_subsurface_destructor (struct wl_resource *resource)
{
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
if (surface->protocol_state.parent)
permanently_unmap_subsurface (surface);
surface->wl_subsurface = NULL;
}
@ -480,17 +484,7 @@ wl_subcompositor_destroy (struct wl_client *client,
void
meta_wayland_subsurface_parent_destroyed (MetaWaylandSurface *surface)
{
MetaWaylandSurface *parent = surface->protocol_state.parent;
MetaWaylandTransaction *transaction;
MetaWaylandSubsurfacePlacementOp *op;
transaction = meta_wayland_transaction_new (surface->compositor);
op = get_subsurface_placement_op (surface, NULL,
META_WAYLAND_SUBSURFACE_PLACEMENT_BELOW);
meta_wayland_transaction_add_placement_op (transaction, parent, op);
meta_wayland_transaction_commit (transaction);
surface->protocol_state.parent = NULL;
permanently_unmap_subsurface (surface);
}
static gboolean