+static void
+transform_parent_handle_parent_destroy(struct wl_listener *listener,
+ void *data)
+{
+ struct weston_surface *surface =
+ container_of(listener, struct weston_surface,
+ geometry.parent_destroy_listener);
+
+ weston_surface_set_transform_parent(surface, NULL);
+}
+
+WL_EXPORT void
+weston_surface_set_transform_parent(struct weston_surface *surface,
+ struct weston_surface *parent)
+{
+ if (surface->geometry.parent) {
+ wl_list_remove(&surface->geometry.parent_destroy_listener.link);
+ wl_list_remove(&surface->geometry.parent_link);
+ }
+
+ surface->geometry.parent = parent;
+
+ surface->geometry.parent_destroy_listener.notify =
+ transform_parent_handle_parent_destroy;
+ if (parent) {
+ wl_signal_add(&parent->surface.resource.destroy_signal,
+ &surface->geometry.parent_destroy_listener);
+ wl_list_insert(&parent->geometry.child_list,
+ &surface->geometry.parent_link);
+ }
+
+ weston_surface_geometry_dirty(surface);
+}
+