From 9dc5d98607996d4e6aee666f65017d1c4e7b137c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 2 Nov 2023 18:42:03 +0100 Subject: [PATCH] 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: --- src/wayland/meta-wayland-subsurface.c | 46 ++++++++++++--------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/src/wayland/meta-wayland-subsurface.c b/src/wayland/meta-wayland-subsurface.c index 83680b408..1285053b2 100644 --- a/src/wayland/meta-wayland-subsurface.c +++ b/src/wayland/meta-wayland-subsurface.c @@ -397,26 +397,30 @@ wl_subsurface_place_below (struct wl_client *client, META_WAYLAND_SUBSURFACE_PLACEMENT_BELOW); } +static void +permanently_unmap_subsurface (MetaWaylandSurface *surface) +{ + MetaWaylandSubsurfacePlacementOp *op; + MetaWaylandTransaction *transaction; + + op = get_subsurface_placement_op (surface, NULL, + META_WAYLAND_SUBSURFACE_PLACEMENT_BELOW); + + transaction = meta_wayland_transaction_new (surface->compositor); + 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); - MetaWaylandSurface *parent = surface->protocol_state.parent; - if (parent) - { - MetaWaylandSubsurfacePlacementOp *op; - MetaWaylandTransaction *transaction; - - op = get_subsurface_placement_op (surface, NULL, - META_WAYLAND_SUBSURFACE_PLACEMENT_BELOW); - - transaction = meta_wayland_transaction_new (surface->compositor); - meta_wayland_transaction_add_placement_op (transaction, parent, op); - meta_wayland_transaction_commit (transaction); - - surface->protocol_state.parent = NULL; - } + 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