Skip to content

clutter/actor: Notify first/last child changes when moving children

Marco Trevisan requested to merge 3v1n0/mutter:first-last-child-notify-fix into main

A clutter actor may not properly notify first/last-child changes when using functions such as set_child_at_index(), set_child_above_sibling() and set_child_below_sibling().

In fact, in the case we've a container actor with two children, and we swap them, we temporarily unparent the one we want to move, while the remaining one is marked as both first and last child, but we don't notify about its new actual state (as first or last child); differently, once we've added the moving child back, we do notify about its new state (as first or last child), but since the other child didn't change location with this operation, we end up informing the API clients only about the new first (or last) child and not about the new last (or first) child.

This is particularly problematic for gnome-shell, because StWidget's relies on fist/last-child notifications to compute the first/last-visible widgets and to apply on them the relative pseudo classes that can be used by CSS selectors.
And so, in the described case we might end up having a container with more than one widget, where a single widget is marked as both first and last visible one, breaking theming.

Thus, use REMOVE_CHILD_NOTIFY_FIRST_LAST flag to ensure that we notify changes to first/last child, thawing the object first to make sure that we only emit the notifications once the actors reordering is completed and not while the container is missing an actor.

Add tests simulating the case, and further checks on first/last-child notifications.

Merge request reports

Loading