clutter/actor: Make sure expand_set flags are set correctly

If an actor's expand properties haven't been set explicitly, its
expand flags are computed by traversing its children.

However we currently also traverse into children when explicitly
setting "expand" to FALSE, because that is the default value and
the properties are only marked as explicitly-set when the value
actually changed.

Fix this, so propagating expand flags can be stopped without
hacks like
```c
  g_object_set (actor, "x-expand", TRUE, NULL);
  g_object_set (actor, "x-expand", FALSE, NULL);
``

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3088>
This commit is contained in:
Florian Müllner 2023-06-22 21:31:14 +02:00
parent 993c42e11f
commit 9f46258ff9

View File

@ -18275,13 +18275,16 @@ clutter_actor_set_x_expand (ClutterActor *self,
gboolean expand)
{
ClutterLayoutInfo *info;
gboolean changed;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
expand = !!expand;
info = _clutter_actor_get_layout_info (self);
if (info->x_expand != expand)
changed = info->x_expand != expand;
if (changed || !self->priv->x_expand_set)
{
info->x_expand = expand;
@ -18289,8 +18292,9 @@ clutter_actor_set_x_expand (ClutterActor *self,
clutter_actor_queue_compute_expand (self);
g_object_notify_by_pspec (G_OBJECT (self),
obj_props[PROP_X_EXPAND]);
if (changed)
g_object_notify_by_pspec (G_OBJECT (self),
obj_props[PROP_X_EXPAND]);
}
}
@ -18330,13 +18334,16 @@ clutter_actor_set_y_expand (ClutterActor *self,
gboolean expand)
{
ClutterLayoutInfo *info;
gboolean changed;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
expand = !!expand;
info = _clutter_actor_get_layout_info (self);
if (info->y_expand != expand)
changed = info->y_expand != expand;
if (changed || !self->priv->y_expand_set)
{
info->y_expand = expand;
@ -18344,8 +18351,9 @@ clutter_actor_set_y_expand (ClutterActor *self,
clutter_actor_queue_compute_expand (self);
g_object_notify_by_pspec (G_OBJECT (self),
obj_props[PROP_Y_EXPAND]);
if (changed)
g_object_notify_by_pspec (G_OBJECT (self),
obj_props[PROP_Y_EXPAND]);
}
}