From 69ca584168f6bc4c984b9132a75a9a5c251c1f84 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 4 Jun 2018 16:11:42 +0200 Subject: [PATCH] wayland: Handle get_subsurface() with a role-less parent surface The order of role creation is undetermined, so we can't account that the parent surface will have a role (and an actor) at the time of creating the wl_subsurface role for a child surface. So we must do it both ways, add the subsurface as a child on get_subsurface() if the parent already got a role, and lazily add child subsurface actors to the current one if the parent surface got it at a later point. Related: #132 --- src/wayland/meta-wayland-actor-surface.c | 8 ++++++++ src/wayland/meta-wayland-subsurface.c | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/wayland/meta-wayland-actor-surface.c b/src/wayland/meta-wayland-actor-surface.c index 43e88aac4..c0dc0c62b 100644 --- a/src/wayland/meta-wayland-actor-surface.c +++ b/src/wayland/meta-wayland-actor-surface.c @@ -72,10 +72,18 @@ meta_wayland_actor_surface_assigned (MetaWaylandSurfaceRole *surface_role) meta_wayland_actor_surface_get_instance_private (META_WAYLAND_ACTOR_SURFACE (surface_role)); MetaWaylandSurface *surface = meta_wayland_surface_role_get_surface (surface_role); + GList *l; meta_surface_actor_wayland_add_frame_callbacks (META_SURFACE_ACTOR_WAYLAND (priv->actor), &surface->pending_frame_callback_list); wl_list_init (&surface->pending_frame_callback_list); + + for (l = surface->subsurfaces; l; l = l->next) + { + ClutterActor *subsurface_actor = + CLUTTER_ACTOR (meta_wayland_surface_get_actor (l->data)); + clutter_actor_add_child (CLUTTER_ACTOR (priv->actor), subsurface_actor); + } } static void diff --git a/src/wayland/meta-wayland-subsurface.c b/src/wayland/meta-wayland-subsurface.c index 399212da6..2a42305f6 100644 --- a/src/wayland/meta-wayland-subsurface.c +++ b/src/wayland/meta-wayland-subsurface.c @@ -471,8 +471,11 @@ wl_subcompositor_get_subsurface (struct wl_client *client, &surface->sub.parent_destroy_listener); parent->subsurfaces = g_list_append (parent->subsurfaces, surface); - clutter_actor_add_child (CLUTTER_ACTOR (meta_wayland_surface_get_actor (parent)), - CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface))); + if (meta_wayland_surface_get_actor (parent)) + { + clutter_actor_add_child (CLUTTER_ACTOR (meta_wayland_surface_get_actor (parent)), + CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface))); + } clutter_actor_set_reactive (CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface)), TRUE); }