diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index cfd3b336c..67c137a45 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -10207,6 +10207,32 @@ container_lower (ClutterContainer *container, clutter_actor_queue_relayout (self); } +static gint +sort_by_depth (gconstpointer a, + gconstpointer b) +{ + const ClutterActor *actor_a = a; + const ClutterActor *actor_b = b; + + if (actor_a->priv->z < actor_b->priv->z) + return -1; + + if (actor_a->priv->z > actor_b->priv->z) + return 1; + + return 0; +} + +static void +container_sort_by_depth (ClutterContainer *container) +{ + ClutterActorPrivate *priv = CLUTTER_ACTOR (container)->priv; + + priv->children = g_list_sort (priv->children, sort_by_depth); + + clutter_actor_queue_relayout (CLUTTER_ACTOR (container)); +} + static void clutter_container_iface_init (ClutterContainerIface *iface) { @@ -10216,6 +10242,7 @@ clutter_container_iface_init (ClutterContainerIface *iface) iface->raise = container_raise; iface->lower = container_lower; + iface->sort_depth_order = container_sort_by_depth; } typedef enum