From 4729cb779e27153b1caf4be523b2bbd2f1104697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 9 May 2020 18:31:39 +0200 Subject: [PATCH 01/10] clutter/stage: Stop using DELEGATE_LAYOUT allocation flag We're going to remove allocation flags, so stop depending on the DELEGATE_LAYOUT flag in ClutterStage and call clutter_layout_manager_allocate() directly, which is pretty straightforward. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245 --- clutter/clutter/clutter-stage.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index d656ec2e995..487af060aca 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -622,6 +622,7 @@ clutter_stage_allocate (ClutterActor *self, float new_width, new_height; float width, height; cairo_rectangle_int_t window_size; + ClutterLayoutManager *layout_manager = clutter_actor_get_layout_manager (self); if (priv->impl == NULL) return; @@ -643,6 +644,12 @@ clutter_stage_allocate (ClutterActor *self, */ if (!clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC)) { + ClutterActorBox children_box; + + children_box.x1 = children_box.y1 = 0.f; + children_box.x2 = box->x2 - box->x1; + children_box.y2 = box->y2 - box->y1; + CLUTTER_NOTE (LAYOUT, "Following allocation to %.2fx%.2f (absolute origin %s)", width, height, @@ -650,8 +657,12 @@ clutter_stage_allocate (ClutterActor *self, ? "changed" : "not changed"); - clutter_actor_set_allocation (self, box, - flags | CLUTTER_DELEGATE_LAYOUT); + clutter_actor_set_allocation (self, box, flags); + + clutter_layout_manager_allocate (layout_manager, + CLUTTER_CONTAINER (self), + &children_box, + flags); /* Ensure the window is sized correctly */ if (priv->min_size_changed) @@ -707,8 +718,12 @@ clutter_stage_allocate (ClutterActor *self, : "not changed"); /* and store the overridden allocation */ - clutter_actor_set_allocation (self, &override, - flags | CLUTTER_DELEGATE_LAYOUT); + clutter_actor_set_allocation (self, &override, flags); + + clutter_layout_manager_allocate (layout_manager, + CLUTTER_CONTAINER (self), + &override, + flags); } /* reset the viewport if the allocation effectively changed */ -- GitLab From 24d7a7ad0bfbc2ad1d3c0420667079a0d42b5412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 9 May 2020 18:35:15 +0200 Subject: [PATCH 02/10] clutter: Remove DELEGATE_LAYOUT allocation flag The CLUTTER_DELEGATE_LAYOUT flag is unintuitive and makes the allocation process inside Clutter unnecessarily complicated. It's very easy for actors overriding the allocate() vfunc to layout their children themselves (in fact most of them do this), and it also never made sense that clutter_actor_set_allocation() does eventually layout children. There was no ClutterActor implementation in mutter or gnome-shell which actually used the DELEGATE_LAYOUT flag, but even without it, it's fairly easy to archive the same behavior now: In the allocate() override, adjust the allocation as wanted, then chain up to the parent vfunc without calling clutter_actor_set_allocation(). So remove the CLUTTER_DELEGATE_LAYOUT flag, which will allow making the relayout code in Clutter a bit easier to follow. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245 --- clutter/clutter/clutter-actor.c | 106 +------------------------------- clutter/clutter/clutter-actor.h | 9 ++- clutter/clutter/clutter-enums.h | 8 --- 3 files changed, 9 insertions(+), 114 deletions(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index d180282856c..fd4532b1ece 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -2649,43 +2649,9 @@ clutter_actor_maybe_layout_children (ClutterActor *self, { ClutterActorPrivate *priv = self->priv; - /* this is going to be a bit hard to follow, so let's put an explanation - * here. - * - * we want ClutterActor to have a default layout manager if the actor was - * created using "g_object_new (CLUTTER_TYPE_ACTOR, NULL)". - * - * we also want any subclass of ClutterActor that does not override the - * ::allocate() virtual function to delegate to a layout manager. - * - * finally, we want to allow people subclassing ClutterActor and overriding - * the ::allocate() vfunc to let Clutter delegate to the layout manager. - * - * on the other hand, we want existing actor subclasses overriding the - * ::allocate() virtual function and chaining up to the parent's - * implementation to continue working without allocating their children - * twice, or without entering an allocation loop. - * - * for the first two points, we check if the class of the actor is - * overridding the ::allocate() virtual function; if it isn't, then we - * follow through with checking whether we have children and a layout - * manager, and eventually calling clutter_layout_manager_allocate(). - * - * for the third point, we check the CLUTTER_DELEGATE_LAYOUT flag in the - * allocation flags that we got passed, and if it is present, we continue - * with the check above. - * - * if neither of these two checks yields a positive result, we just - * assume that the ::allocate() virtual function that resulted in this - * function being called will also allocate the children of the actor. - */ - if (CLUTTER_ACTOR_GET_CLASS (self)->allocate == clutter_actor_real_allocate) goto check_layout; - if ((flags & CLUTTER_DELEGATE_LAYOUT) != 0) - goto check_layout; - return; check_layout: @@ -2693,7 +2659,6 @@ check_layout: priv->layout_manager != NULL) { ClutterContainer *container = CLUTTER_CONTAINER (self); - ClutterAllocationFlags children_flags; ClutterActorBox children_box; /* normalize the box passed to the layout manager */ @@ -2701,13 +2666,6 @@ check_layout: children_box.x2 = (allocation->x2 - allocation->x1); children_box.y2 = (allocation->y2 - allocation->y1); - /* remove the DELEGATE_LAYOUT flag; this won't be passed to - * the actor's children, since it refers only to the current - * actor's allocation. - */ - children_flags = flags; - children_flags &= ~CLUTTER_DELEGATE_LAYOUT; - CLUTTER_NOTE (LAYOUT, "Allocating %d children of %s " "at { %.2f, %.2f - %.2f x %.2f } " @@ -2723,7 +2681,7 @@ check_layout: clutter_layout_manager_allocate (priv->layout_manager, container, &children_box, - children_flags); + flags); } } @@ -10344,13 +10302,8 @@ clutter_actor_allocate (ClutterActor *self, * This function can only be called from within the implementation of * the #ClutterActorClass.allocate() virtual function. * - * The allocation should have been adjusted to take into account constraints, - * alignment, and margin properties. If you are implementing a #ClutterActor - * subclass that provides its own layout management policy for its children - * instead of using a #ClutterLayoutManager delegate, you should not call - * this function on the children of @self; instead, you should call - * clutter_actor_allocate(), which will adjust the allocation box for - * you. + * The allocation @box should have been adjusted to take into account + * constraints, alignment, and margin properties. * * This function should only be used by subclasses of #ClutterActor * that wish to store their allocation but cannot chain up to the @@ -10358,59 +10311,6 @@ clutter_actor_allocate (ClutterActor *self, * #ClutterActorClass.allocate() virtual function will call this * function. * - * It is important to note that, while chaining up was the recommended - * behaviour for #ClutterActor subclasses prior to the introduction of - * this function, it is recommended to call clutter_actor_set_allocation() - * instead. - * - * If the #ClutterActor is using a #ClutterLayoutManager delegate object - * to handle the allocation of its children, this function will call - * the clutter_layout_manager_allocate() function only if the - * %CLUTTER_DELEGATE_LAYOUT flag is set on @flags, otherwise it is - * expected that the subclass will call clutter_layout_manager_allocate() - * by itself. For instance, the following code: - * - * |[ - * static void - * my_actor_allocate (ClutterActor *actor, - * const ClutterActorBox *allocation, - * ClutterAllocationFlags flags) - * { - * ClutterActorBox new_alloc; - * ClutterAllocationFlags new_flags; - * - * adjust_allocation (allocation, &new_alloc); - * - * new_flags = flags | CLUTTER_DELEGATE_LAYOUT; - * - * // this will use the layout manager set on the actor - * clutter_actor_set_allocation (actor, &new_alloc, new_flags); - * } - * ]| - * - * is equivalent to this: - * - * |[ - * static void - * my_actor_allocate (ClutterActor *actor, - * const ClutterActorBox *allocation, - * ClutterAllocationFlags flags) - * { - * ClutterLayoutManager *layout; - * ClutterActorBox new_alloc; - * - * adjust_allocation (allocation, &new_alloc); - * - * clutter_actor_set_allocation (actor, &new_alloc, flags); - * - * layout = clutter_actor_get_layout_manager (actor); - * clutter_layout_manager_allocate (layout, - * CLUTTER_CONTAINER (actor), - * &new_alloc, - * flags); - * } - * ]| - * * Since: 1.10 */ void diff --git a/clutter/clutter/clutter-actor.h b/clutter/clutter/clutter-actor.h index 220289d5364..f473f4f8bd0 100644 --- a/clutter/clutter/clutter-actor.h +++ b/clutter/clutter/clutter-actor.h @@ -175,9 +175,12 @@ struct _ClutterActor * @get_preferred_height: virtual function, used when querying the minimum * and natural heights of an actor for a given width; it is used by * clutter_actor_get_preferred_height() - * @allocate: virtual function, used when settings the coordinates of an - * actor; it is used by clutter_actor_allocate(); it must chain up to - * the parent's implementation, or call clutter_actor_set_allocation() + * @allocate: virtual function, used when setting the coordinates of an + * actor; it is used by clutter_actor_allocate(); when overriding this + * function without chaining up, clutter_actor_set_allocation() must be + * called and children must be allocated by the implementation, when + * chaining up though, those things will be done by the parent's + * implementation. * @apply_transform: virtual function, used when applying the transformations * to an actor before painting it or when transforming coordinates or * the allocation; it must chain up to the parent's implementation diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h index 2d4f41c427b..5c4e3a5dc2c 100644 --- a/clutter/clutter/clutter-enums.h +++ b/clutter/clutter/clutter-enums.h @@ -560,13 +560,6 @@ typedef enum /*< prefix=CLUTTER_OFFSCREEN_REDIRECT >*/ * @CLUTTER_ABSOLUTE_ORIGIN_CHANGED: Whether the absolute origin of the * actor has changed; this implies that any ancestor of the actor has * been moved. - * @CLUTTER_DELEGATE_LAYOUT: Whether the allocation should be delegated - * to the #ClutterLayoutManager instance stored inside the - * #ClutterActor:layout-manager property of #ClutterActor. This flag - * should only be used if you are subclassing #ClutterActor and - * overriding the #ClutterActorClass.allocate() virtual function, but - * you wish to use the default implementation of the virtual function - * inside #ClutterActor. Added in Clutter 1.10. * * Flags passed to the #ClutterActorClass.allocate() virtual function * and to the clutter_actor_allocate() function. @@ -577,7 +570,6 @@ typedef enum { CLUTTER_ALLOCATION_NONE = 0, CLUTTER_ABSOLUTE_ORIGIN_CHANGED = 1 << 1, - CLUTTER_DELEGATE_LAYOUT = 1 << 2 } ClutterAllocationFlags; /** -- GitLab From affb3de829dfb285295bd481713ebe5a40d4adfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 9 May 2020 18:49:05 +0200 Subject: [PATCH 03/10] clutter/actor: Don't layout children inside set_allocation() Now that we no longer have the DELEGATE_LAYOUT we expect all actors overriding the allocate() vfunc to allocate their children themselves. Since clutter_actor_set_allocation() is only called from custom vfunc_allocate() implementations, the condition in clutter_actor_maybe_layout_children() would always fail, which makes calling the function useless anyway. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245 --- clutter/clutter/clutter-actor.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index fd4532b1ece..c134edffdab 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -10338,13 +10338,6 @@ clutter_actor_set_allocation (ClutterActor *self, changed = clutter_actor_set_allocation_internal (self, box, flags); - /* we allocate our children before we notify changes in our geometry, - * so that people connecting to properties will be able to get valid - * data out of the sub-tree of the scene graph that has this actor at - * the root. - */ - clutter_actor_maybe_layout_children (self, box, flags); - if (changed) { ClutterActorBox signal_box = priv->allocation; -- GitLab From 7ae6e0101c451373d680ef8361ac68a07dc69af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 9 May 2020 20:22:51 +0200 Subject: [PATCH 04/10] clutter/actor: Remove clutter_actor_maybe_layout_children() Since we now only layout the children ourselves in case the actor implementation doesn't override the allocate vfunc, we can remove clutter_actor_maybe_layout_children() and move the functionality inside clutter_actor_real_allocate(). https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245 --- clutter/clutter/clutter-actor.c | 59 +++++++++++---------------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index c134edffdab..e04896cfd8e 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -2638,33 +2638,32 @@ clutter_actor_set_allocation_internal (ClutterActor *self, return retval; } -static void clutter_actor_real_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags); - -static inline void -clutter_actor_maybe_layout_children (ClutterActor *self, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) +static void +clutter_actor_real_allocate (ClutterActor *self, + const ClutterActorBox *box, + ClutterAllocationFlags flags) { ClutterActorPrivate *priv = self->priv; + gboolean changed; - if (CLUTTER_ACTOR_GET_CLASS (self)->allocate == clutter_actor_real_allocate) - goto check_layout; + g_object_freeze_notify (G_OBJECT (self)); - return; + changed = clutter_actor_set_allocation_internal (self, box, flags); -check_layout: + /* we allocate our children before we notify changes in our geometry, + * so that people connecting to properties will be able to get valid + * data out of the sub-tree of the scene graph that has this actor at + * the root. + */ if (priv->n_children != 0 && priv->layout_manager != NULL) { - ClutterContainer *container = CLUTTER_CONTAINER (self); ClutterActorBox children_box; /* normalize the box passed to the layout manager */ children_box.x1 = children_box.y1 = 0.f; - children_box.x2 = (allocation->x2 - allocation->x1); - children_box.y2 = (allocation->y2 - allocation->y1); + children_box.x2 = box->x2 - box->x1; + children_box.y2 = box->y2 - box->y1; CLUTTER_NOTE (LAYOUT, "Allocating %d children of %s " @@ -2672,37 +2671,17 @@ check_layout: "using %s", priv->n_children, _clutter_actor_get_debug_name (self), - allocation->x1, - allocation->y1, - (allocation->x2 - allocation->x1), - (allocation->y2 - allocation->y1), + box->x1, + box->y1, + (box->x2 - box->x1), + (box->y2 - box->y1), G_OBJECT_TYPE_NAME (priv->layout_manager)); clutter_layout_manager_allocate (priv->layout_manager, - container, + CLUTTER_CONTAINER (self), &children_box, flags); } -} - -static void -clutter_actor_real_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) -{ - ClutterActorPrivate *priv = self->priv; - gboolean changed; - - g_object_freeze_notify (G_OBJECT (self)); - - changed = clutter_actor_set_allocation_internal (self, box, flags); - - /* we allocate our children before we notify changes in our geometry, - * so that people connecting to properties will be able to get valid - * data out of the sub-tree of the scene graph that has this actor at - * the root. - */ - clutter_actor_maybe_layout_children (self, box, flags); if (changed) { -- GitLab From 04e983383fb56e5de48b56f7bd5a95e4dbc31e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 9 May 2020 19:35:01 +0200 Subject: [PATCH 05/10] clutter/stage: Remove ABSOLUTE_ORIGIN_CHANGED flag from debug message The ABSOLUTE_ORIGIN_CHANGED allocation flag is going to be removed from Clutter, so stop using it for this debug message. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245 --- clutter/clutter/clutter-stage.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index 487af060aca..3d76ede0c50 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -651,11 +651,8 @@ clutter_stage_allocate (ClutterActor *self, children_box.y2 = box->y2 - box->y1; CLUTTER_NOTE (LAYOUT, - "Following allocation to %.2fx%.2f (absolute origin %s)", - width, height, - (flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED) - ? "changed" - : "not changed"); + "Following allocation to %.2fx%.2f", + width, height); clutter_actor_set_allocation (self, box, flags); @@ -710,12 +707,9 @@ clutter_stage_allocate (ClutterActor *self, CLUTTER_NOTE (LAYOUT, "Overriding original allocation of %.2fx%.2f " - "with %.2fx%.2f (absolute origin %s)", + "with %.2fx%.2f", width, height, - override.x2, override.y2, - (flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED) - ? "changed" - : "not changed"); + override.x2, override.y2); /* and store the overridden allocation */ clutter_actor_set_allocation (self, &override, flags); -- GitLab From 0a986fc885092e267f3441e50133f48a9b78b58d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 9 May 2020 21:11:56 +0200 Subject: [PATCH 06/10] clutter/tests: Remove usage of ABSOLUTE_ORIGIN_CHANGED flag We're going to remove this allocation flag, so stop using in the interactive test-layout test. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245 --- src/tests/clutter/interactive/test-layout.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/tests/clutter/interactive/test-layout.c b/src/tests/clutter/interactive/test-layout.c index 9666f15df99..ad9b4e209c6 100644 --- a/src/tests/clutter/interactive/test-layout.c +++ b/src/tests/clutter/interactive/test-layout.c @@ -338,17 +338,8 @@ my_thing_allocate (ClutterActor *self, graphene_point3d_t v1 = { 0, }, v2 = { 0, }; ClutterActorBox transformed_box = { 0, }; - /* origin */ - if (!(flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED)) - { - v1.x = 0; - v1.y = 0; - } - else - { - v1.x = box->x1; - v1.y = box->y1; - } + v1.x = box->x1; + v1.y = box->y1; clutter_actor_apply_transform_to_point (child, &v1, &v2); transformed_box.x1 = v2.x; -- GitLab From dc8e5c7f8be1cc348781d8fd3348e7ad8326dfd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 9 May 2020 19:53:02 +0200 Subject: [PATCH 07/10] clutter/actor: Replace ABSOLUTE_ORIGIN_CHANGED flag with a property The ABSOLUTE_ORIGIN_CHANGED allocation flag is only really useful to propagate the information of the absolute origin of an actor having changed inside Clutter. It wasn't used anywhere else besides for some debug messages and it probably shouldn't be used in custom layout implementations anyway since 1) actors shouldn't have to be aware of absolute allocation changes and 2) it doesn't factor in changes to the transformation matrix of a parent. Also the propagation of absolute origin changes using this flag broke with commit 0eab73dc2e and now hidden actors are no longer notified about those changes. Additionally, this flag gets in the way of a few potential optimizations since it has to be propagated even if the allocation box of the child hasn't changed, forcing a reallocation of the child. So replace this flag with a simple new private property of ClutterActor absolute_origin_changed, but keep the exact same behavior for now. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245 --- clutter/clutter/clutter-actor.c | 29 +++++++++++------------------ clutter/clutter/clutter-enums.h | 4 ---- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index e04896cfd8e..571ee6a8122 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -854,6 +854,7 @@ struct _ClutterActorPrivate guint needs_paint_volume_update : 1; guint had_effects_on_last_paint_volume_update : 1; guint needs_compute_resource_scale : 1; + guint absolute_origin_changed : 1; }; enum @@ -10163,7 +10164,7 @@ clutter_actor_allocate (ClutterActor *self, ClutterAllocationFlags flags) { ClutterActorBox old_allocation, real_allocation; - gboolean origin_changed, child_moved, size_changed; + gboolean origin_changed, size_changed; gboolean stage_allocation_changed; ClutterActorPrivate *priv; @@ -10206,18 +10207,19 @@ clutter_actor_allocate (ClutterActor *self, real_allocation.x2 = MAX (real_allocation.x2, real_allocation.x1); real_allocation.y2 = MAX (real_allocation.y2, real_allocation.y1); - origin_changed = (flags & CLUTTER_ABSOLUTE_ORIGIN_CHANGED); - - child_moved = (real_allocation.x1 != old_allocation.x1 || - real_allocation.y1 != old_allocation.y1); + origin_changed = (real_allocation.x1 != old_allocation.x1 || + real_allocation.y1 != old_allocation.y1); size_changed = (real_allocation.x2 != old_allocation.x2 || real_allocation.y2 != old_allocation.y2); - if (origin_changed || child_moved || size_changed) - stage_allocation_changed = TRUE; - else - stage_allocation_changed = FALSE; + priv->absolute_origin_changed = priv->parent + ? priv->parent->priv->absolute_origin_changed + : FALSE; + + priv->absolute_origin_changed |= origin_changed; + + stage_allocation_changed = priv->absolute_origin_changed || size_changed; /* If we get an allocation "out of the blue" * (we did not queue relayout), then we want to @@ -10251,15 +10253,6 @@ clutter_actor_allocate (ClutterActor *self, return; } - /* When ABSOLUTE_ORIGIN_CHANGED is passed in to - * clutter_actor_allocate(), it indicates whether the parent has its - * absolute origin moved; when passed in to ClutterActor::allocate() - * virtual method though, it indicates whether the child has its - * absolute origin moved. So we set it when child_moved is TRUE - */ - if (child_moved) - flags |= CLUTTER_ABSOLUTE_ORIGIN_CHANGED; - /* store the flags here, so that they can be propagated by the * transition code */ diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h index 5c4e3a5dc2c..aed8e904812 100644 --- a/clutter/clutter/clutter-enums.h +++ b/clutter/clutter/clutter-enums.h @@ -557,9 +557,6 @@ typedef enum /*< prefix=CLUTTER_OFFSCREEN_REDIRECT >*/ /** * ClutterAllocationFlags: * @CLUTTER_ALLOCATION_NONE: No flag set - * @CLUTTER_ABSOLUTE_ORIGIN_CHANGED: Whether the absolute origin of the - * actor has changed; this implies that any ancestor of the actor has - * been moved. * * Flags passed to the #ClutterActorClass.allocate() virtual function * and to the clutter_actor_allocate() function. @@ -569,7 +566,6 @@ typedef enum /*< prefix=CLUTTER_OFFSCREEN_REDIRECT >*/ typedef enum { CLUTTER_ALLOCATION_NONE = 0, - CLUTTER_ABSOLUTE_ORIGIN_CHANGED = 1 << 1, } ClutterAllocationFlags; /** -- GitLab From 3c29bf749121e49072cb857dcfda5afa44a56088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 9 May 2020 21:09:43 +0200 Subject: [PATCH 08/10] clutter: Remove allocation flags Since there are now no more allocation flags, we can remove ClutterAllocationFlags from Clutter. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245 --- clutter/clutter/clutter-actor.c | 75 +++++++-------------- clutter/clutter/clutter-actor.h | 18 ++--- clutter/clutter/clutter-align-constraint.c | 1 - clutter/clutter/clutter-bin-layout.c | 6 +- clutter/clutter/clutter-box-layout.c | 14 ++-- clutter/clutter/clutter-clone.c | 9 ++- clutter/clutter/clutter-deform-effect.c | 1 - clutter/clutter/clutter-enums.h | 14 ---- clutter/clutter/clutter-fixed-layout.c | 5 +- clutter/clutter/clutter-flow-layout.c | 5 +- clutter/clutter/clutter-grid-layout.c | 5 +- clutter/clutter/clutter-layout-manager.c | 9 +-- clutter/clutter/clutter-layout-manager.h | 6 +- clutter/clutter/clutter-stage.c | 16 ++--- clutter/clutter/clutter-text.c | 5 +- clutter/clutter/deprecated/clutter-group.c | 7 +- src/tests/clutter/conform/actor-anchors.c | 4 +- src/tests/clutter/conform/actor-pick.c | 2 +- src/tests/clutter/interactive/test-layout.c | 7 +- 19 files changed, 68 insertions(+), 141 deletions(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index 571ee6a8122..f18df7ce178 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -698,7 +698,6 @@ struct _ClutterActorPrivate * allocation */ ClutterActorBox allocation; - ClutterAllocationFlags allocation_flags; /* clip, in actor coordinates */ graphene_rect_t clip; @@ -2580,8 +2579,7 @@ clutter_actor_notify_if_geometry_changed (ClutterActor *self, */ static inline gboolean clutter_actor_set_allocation_internal (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { ClutterActorPrivate *priv = self->priv; GObject *obj; @@ -2601,7 +2599,6 @@ clutter_actor_set_allocation_internal (ClutterActor *self, y2_changed = priv->allocation.y2 != box->y2; priv->allocation = *box; - priv->allocation_flags = flags; /* allocation is authoritative */ priv->needs_width_request = FALSE; @@ -2641,15 +2638,14 @@ clutter_actor_set_allocation_internal (ClutterActor *self, static void clutter_actor_real_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { ClutterActorPrivate *priv = self->priv; gboolean changed; g_object_freeze_notify (G_OBJECT (self)); - changed = clutter_actor_set_allocation_internal (self, box, flags); + changed = clutter_actor_set_allocation_internal (self, box); /* we allocate our children before we notify changes in our geometry, * so that people connecting to properties will be able to get valid @@ -2680,18 +2676,15 @@ clutter_actor_real_allocate (ClutterActor *self, clutter_layout_manager_allocate (priv->layout_manager, CLUTTER_CONTAINER (self), - &children_box, - flags); + &children_box); } if (changed) { ClutterActorBox signal_box = priv->allocation; - ClutterAllocationFlags signal_flags = priv->allocation_flags; g_signal_emit (self, actor_signals[ALLOCATION_CHANGED], 0, - &signal_box, - signal_flags); + &signal_box); } g_object_thaw_notify (G_OBJECT (self)); @@ -8547,7 +8540,6 @@ clutter_actor_class_init (ClutterActorClass *klass) * ClutterActor::allocation-changed: * @actor: the #ClutterActor that emitted the signal * @box: a #ClutterActorBox with the new allocation - * @flags: #ClutterAllocationFlags for the allocation * * The ::allocation-changed signal is emitted when the * #ClutterActor:allocation property changes. Usually, application @@ -8565,9 +8557,8 @@ clutter_actor_class_init (ClutterActorClass *klass) 0, NULL, NULL, _clutter_marshal_VOID__BOXED_FLAGS, - G_TYPE_NONE, 2, - CLUTTER_TYPE_ACTOR_BOX | G_SIGNAL_TYPE_STATIC_SCOPE, - CLUTTER_TYPE_ALLOCATION_FLAGS); + G_TYPE_NONE, 1, + CLUTTER_TYPE_ACTOR_BOX | G_SIGNAL_TYPE_STATIC_SCOPE); g_signal_set_va_marshaller (actor_signals[ALLOCATION_CHANGED], G_TYPE_FROM_CLASS (object_class), _clutter_marshal_VOID__BOXED_FLAGSv); @@ -10109,8 +10100,7 @@ clutter_actor_adjust_allocation (ClutterActor *self, static void clutter_actor_allocate_internal (ClutterActor *self, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { ClutterActorClass *klass; @@ -10120,7 +10110,7 @@ clutter_actor_allocate_internal (ClutterActor *self, _clutter_actor_get_debug_name (self)); klass = CLUTTER_ACTOR_GET_CLASS (self); - klass->allocate (self, allocation, flags); + klass->allocate (self, allocation); CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_IN_RELAYOUT); @@ -10133,7 +10123,6 @@ clutter_actor_allocate_internal (ClutterActor *self, * clutter_actor_allocate: * @self: A #ClutterActor * @box: new allocation of the actor, in parent-relative coordinates - * @flags: flags that control the allocation * * Assigns the size of a #ClutterActor from the given @box. * @@ -10159,9 +10148,8 @@ clutter_actor_allocate_internal (ClutterActor *self, * Since: 0.8 */ void -clutter_actor_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) +clutter_actor_allocate (ClutterActor *self, + const ClutterActorBox *box) { ClutterActorBox old_allocation, real_allocation; gboolean origin_changed, size_changed; @@ -10249,15 +10237,10 @@ clutter_actor_allocate (ClutterActor *self, { /* If the actor didn't move but needs_allocation is set, we just * need to allocate the children */ - clutter_actor_allocate_internal (self, &real_allocation, flags); + clutter_actor_allocate_internal (self, &real_allocation); return; } - /* store the flags here, so that they can be propagated by the - * transition code - */ - self->priv->allocation_flags = flags; - _clutter_actor_create_transition (self, obj_props[PROP_ALLOCATION], &priv->allocation, &real_allocation); @@ -10267,7 +10250,6 @@ clutter_actor_allocate (ClutterActor *self, * clutter_actor_set_allocation: * @self: a #ClutterActor * @box: a #ClutterActorBox - * @flags: allocation flags * * Stores the allocation of @self as defined by @box. * @@ -10287,8 +10269,7 @@ clutter_actor_allocate (ClutterActor *self, */ void clutter_actor_set_allocation (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { ClutterActorPrivate *priv; gboolean changed; @@ -10308,16 +10289,14 @@ clutter_actor_set_allocation (ClutterActor *self, g_object_freeze_notify (G_OBJECT (self)); - changed = clutter_actor_set_allocation_internal (self, box, flags); + changed = clutter_actor_set_allocation_internal (self, box); if (changed) { ClutterActorBox signal_box = priv->allocation; - ClutterAllocationFlags signal_flags = priv->allocation_flags; g_signal_emit (self, actor_signals[ALLOCATION_CHANGED], 0, - &signal_box, - signal_flags); + &signal_box); } g_object_thaw_notify (G_OBJECT (self)); @@ -14791,9 +14770,7 @@ clutter_actor_set_animatable_property (ClutterActor *actor, break; case PROP_ALLOCATION: - clutter_actor_allocate_internal (actor, - g_value_get_boxed (value), - actor->priv->allocation_flags); + clutter_actor_allocate_internal (actor, g_value_get_boxed (value)); clutter_actor_queue_redraw (actor); break; @@ -15187,7 +15164,6 @@ clutter_actor_get_stage (ClutterActor *actor) * actor's natural width * @available_height: the maximum available height, or -1 to use the * actor's natural height - * @flags: flags controlling the allocation * * Allocates @self taking into account the #ClutterActor's * preferred size, but limiting it to the maximum available width @@ -15234,7 +15210,7 @@ clutter_actor_get_stage (ClutterActor *actor) * box.x1 = x; box.y1 = y; * box.x2 = box.x1 + available_width; * box.y2 = box.y1 + available_height; - * clutter_actor_allocate (self, &box, flags); + * clutter_actor_allocate (self, &box); * ]| * * This function can be used by fluid layout managers to allocate @@ -15248,8 +15224,7 @@ clutter_actor_allocate_available_size (ClutterActor *self, gfloat x, gfloat y, gfloat available_width, - gfloat available_height, - ClutterAllocationFlags flags) + gfloat available_height) { ClutterActorPrivate *priv; gfloat width, height; @@ -15305,13 +15280,12 @@ clutter_actor_allocate_available_size (ClutterActor *self, box.y1 = y; box.x2 = box.x1 + width; box.y2 = box.y1 + height; - clutter_actor_allocate (self, &box, flags); + clutter_actor_allocate (self, &box); } /** * clutter_actor_allocate_preferred_size: * @self: a #ClutterActor - * @flags: flags controlling the allocation * * Allocates the natural size of @self. * @@ -15329,8 +15303,7 @@ clutter_actor_allocate_available_size (ClutterActor *self, * Since: 0.8 */ void -clutter_actor_allocate_preferred_size (ClutterActor *self, - ClutterAllocationFlags flags) +clutter_actor_allocate_preferred_size (ClutterActor *self) { gfloat actor_x, actor_y; gfloat natural_width, natural_height; @@ -15364,7 +15337,7 @@ clutter_actor_allocate_preferred_size (ClutterActor *self, actor_box.x2 = actor_box.x1 + natural_width; actor_box.y2 = actor_box.y1 + natural_height; - clutter_actor_allocate (self, &actor_box, flags); + clutter_actor_allocate (self, &actor_box); } /** @@ -15375,7 +15348,6 @@ clutter_actor_allocate_preferred_size (ClutterActor *self, * @y_align: the vertical alignment, between 0 and 1 * @x_fill: whether the actor should fill horizontally * @y_fill: whether the actor should fill vertically - * @flags: allocation flags to be passed to clutter_actor_allocate() * * Allocates @self by taking into consideration the available allocation * area; an alignment factor on either axis; and whether the actor should @@ -15402,8 +15374,7 @@ clutter_actor_allocate_align_fill (ClutterActor *self, gdouble x_align, gdouble y_align, gboolean x_fill, - gboolean y_fill, - ClutterAllocationFlags flags) + gboolean y_fill) { ClutterActorPrivate *priv; ClutterActorBox allocation = CLUTTER_ACTOR_BOX_INIT_ZERO; @@ -15519,7 +15490,7 @@ out: allocation.x2 = ceilf (allocation.x1 + MAX (child_width, 0)); allocation.y2 = ceilf (allocation.y1 + MAX (child_height, 0)); - clutter_actor_allocate (self, &allocation, flags); + clutter_actor_allocate (self, &allocation); } /** diff --git a/clutter/clutter/clutter-actor.h b/clutter/clutter/clutter-actor.h index f473f4f8bd0..b5d4b7845e1 100644 --- a/clutter/clutter/clutter-actor.h +++ b/clutter/clutter/clutter-actor.h @@ -256,8 +256,7 @@ struct _ClutterActorClass gfloat *min_height_p, gfloat *natural_height_p); void (* allocate) (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags); + const ClutterActorBox *box); /* transformations */ void (* apply_transform) (ClutterActor *actor, @@ -418,30 +417,25 @@ void clutter_actor_get_preferred_size gfloat *natural_height_p); CLUTTER_EXPORT void clutter_actor_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags); + const ClutterActorBox *box); CLUTTER_EXPORT -void clutter_actor_allocate_preferred_size (ClutterActor *self, - ClutterAllocationFlags flags); +void clutter_actor_allocate_preferred_size (ClutterActor *self); CLUTTER_EXPORT void clutter_actor_allocate_available_size (ClutterActor *self, gfloat x, gfloat y, gfloat available_width, - gfloat available_height, - ClutterAllocationFlags flags); + gfloat available_height); CLUTTER_EXPORT void clutter_actor_allocate_align_fill (ClutterActor *self, const ClutterActorBox *box, gdouble x_align, gdouble y_align, gboolean x_fill, - gboolean y_fill, - ClutterAllocationFlags flags); + gboolean y_fill); CLUTTER_EXPORT void clutter_actor_set_allocation (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags); + const ClutterActorBox *box); CLUTTER_EXPORT void clutter_actor_get_allocation_box (ClutterActor *self, ClutterActorBox *box); diff --git a/clutter/clutter/clutter-align-constraint.c b/clutter/clutter/clutter-align-constraint.c index a2694aa6386..c7ff711b744 100644 --- a/clutter/clutter/clutter-align-constraint.c +++ b/clutter/clutter/clutter-align-constraint.c @@ -86,7 +86,6 @@ G_DEFINE_TYPE (ClutterAlignConstraint, static void source_position_changed (ClutterActor *actor, const ClutterActorBox *allocation, - ClutterAllocationFlags flags, ClutterAlignConstraint *align) { if (align->actor != NULL) diff --git a/clutter/clutter/clutter-bin-layout.c b/clutter/clutter/clutter-bin-layout.c index 8c63b802cd7..a17393c48c5 100644 --- a/clutter/clutter/clutter-bin-layout.c +++ b/clutter/clutter/clutter-bin-layout.c @@ -406,8 +406,7 @@ get_actor_align_factor (ClutterActorAlign alignment) static void clutter_bin_layout_allocate (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { gfloat allocation_x, allocation_y; gfloat available_w, available_h; @@ -515,8 +514,7 @@ clutter_bin_layout_allocate (ClutterLayoutManager *manager, clutter_actor_allocate_align_fill (child, &child_alloc, x_align, y_align, - x_fill, y_fill, - flags); + x_fill, y_fill); } } diff --git a/clutter/clutter/clutter-box-layout.c b/clutter/clutter/clutter-box-layout.c index 112200258ec..74d5d16127a 100644 --- a/clutter/clutter/clutter-box-layout.c +++ b/clutter/clutter/clutter-box-layout.c @@ -720,8 +720,7 @@ static void allocate_box_child (ClutterBoxLayout *self, ClutterContainer *container, ClutterActor *child, - ClutterActorBox *child_box, - ClutterAllocationFlags flags) + ClutterActorBox *child_box) { ClutterBoxLayoutPrivate *priv = self->priv; ClutterBoxChild *box_child; @@ -750,14 +749,13 @@ allocate_box_child (ClutterBoxLayout *self, */ if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_HORIZONTAL) || clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_VERTICAL)) - clutter_actor_allocate (child, child_box, flags); + clutter_actor_allocate (child, child_box); else clutter_actor_allocate_align_fill (child, child_box, get_box_alignment_factor (box_child->x_align), get_box_alignment_factor (box_child->y_align), box_child->x_fill, - box_child->y_fill, - flags); + box_child->y_fill); if (priv->use_animations) clutter_actor_restore_easing_state (child); @@ -956,8 +954,7 @@ distribute_natural_allocation (float extra_space, static void clutter_box_layout_allocate (ClutterLayoutManager *layout, ClutterContainer *container, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { ClutterBoxLayoutPrivate *priv = CLUTTER_BOX_LAYOUT (layout)->priv; ClutterActor *actor, *child; @@ -1224,8 +1221,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout, allocate_box_child (CLUTTER_BOX_LAYOUT (layout), container, child, - &child_allocation, - flags); + &child_allocation); i += 1; } diff --git a/clutter/clutter/clutter-clone.c b/clutter/clutter/clutter-clone.c index 8c805725a5c..fb69f6c60bd 100644 --- a/clutter/clutter/clutter-clone.c +++ b/clutter/clutter/clutter-clone.c @@ -240,15 +240,14 @@ clutter_clone_has_overlaps (ClutterActor *actor) static void clutter_clone_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { ClutterClonePrivate *priv = CLUTTER_CLONE (self)->priv; ClutterActorClass *parent_class; /* chain up */ parent_class = CLUTTER_ACTOR_CLASS (clutter_clone_parent_class); - parent_class->allocate (self, box, flags); + parent_class->allocate (self, box); if (priv->clone_source == NULL) return; @@ -258,7 +257,7 @@ clutter_clone_allocate (ClutterActor *self, */ if (clutter_actor_get_parent (priv->clone_source) != NULL && !clutter_actor_has_allocation (priv->clone_source)) - clutter_actor_allocate_preferred_size (priv->clone_source, flags); + clutter_actor_allocate_preferred_size (priv->clone_source); #if 0 /* XXX - this is wrong: ClutterClone cannot clone unparented @@ -273,7 +272,7 @@ clutter_clone_allocate (ClutterActor *self, * paint cycle, we can safely give it as much size as it requires */ if (clutter_actor_get_parent (priv->clone_source) == NULL) - clutter_actor_allocate_preferred_size (priv->clone_source, flags); + clutter_actor_allocate_preferred_size (priv->clone_source); #endif } diff --git a/clutter/clutter/clutter-deform-effect.c b/clutter/clutter/clutter-deform-effect.c index 59ef1ff75a9..5f4de5ac7a0 100644 --- a/clutter/clutter/clutter-deform-effect.c +++ b/clutter/clutter/clutter-deform-effect.c @@ -130,7 +130,6 @@ clutter_deform_effect_deform_vertex (ClutterDeformEffect *effect, static void vbo_invalidate (ClutterActor *actor, const ClutterActorBox *allocation, - ClutterAllocationFlags flags, ClutterDeformEffect *effect) { effect->priv->is_dirty = TRUE; diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h index aed8e904812..4b9b62bcf5a 100644 --- a/clutter/clutter/clutter-enums.h +++ b/clutter/clutter/clutter-enums.h @@ -554,20 +554,6 @@ typedef enum /*< prefix=CLUTTER_OFFSCREEN_REDIRECT >*/ CLUTTER_OFFSCREEN_REDIRECT_ON_IDLE = 1 << 2 } ClutterOffscreenRedirect; -/** - * ClutterAllocationFlags: - * @CLUTTER_ALLOCATION_NONE: No flag set - * - * Flags passed to the #ClutterActorClass.allocate() virtual function - * and to the clutter_actor_allocate() function. - * - * Since: 1.0 - */ -typedef enum -{ - CLUTTER_ALLOCATION_NONE = 0, -} ClutterAllocationFlags; - /** * ClutterAlignAxis: * @CLUTTER_ALIGN_X_AXIS: Maintain the alignment on the X axis diff --git a/clutter/clutter/clutter-fixed-layout.c b/clutter/clutter/clutter-fixed-layout.c index 959f7652e9c..324084809c8 100644 --- a/clutter/clutter/clutter-fixed-layout.c +++ b/clutter/clutter/clutter-fixed-layout.c @@ -131,8 +131,7 @@ clutter_fixed_layout_get_preferred_height (ClutterLayoutManager *manager, static void clutter_fixed_layout_allocate (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { ClutterActor *child; @@ -140,7 +139,7 @@ clutter_fixed_layout_allocate (ClutterLayoutManager *manager, child != NULL; child = clutter_actor_get_next_sibling (child)) { - clutter_actor_allocate_preferred_size (child, flags); + clutter_actor_allocate_preferred_size (child); } } diff --git a/clutter/clutter/clutter-flow-layout.c b/clutter/clutter/clutter-flow-layout.c index 365c5d9d855..f7ced9837fa 100644 --- a/clutter/clutter/clutter-flow-layout.c +++ b/clutter/clutter/clutter-flow-layout.c @@ -566,8 +566,7 @@ clutter_flow_layout_get_preferred_height (ClutterLayoutManager *manager, static void clutter_flow_layout_allocate (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { ClutterFlowLayoutPrivate *priv = CLUTTER_FLOW_LAYOUT (manager)->priv; ClutterActor *actor, *child; @@ -729,7 +728,7 @@ clutter_flow_layout_allocate (ClutterLayoutManager *manager, child_alloc.y1 = ceil (item_y); child_alloc.x2 = ceil (child_alloc.x1 + item_width); child_alloc.y2 = ceil (child_alloc.y1 + item_height); - clutter_actor_allocate (child, &child_alloc, flags); + clutter_actor_allocate (child, &child_alloc); if (priv->orientation == CLUTTER_FLOW_HORIZONTAL) item_x = new_x; diff --git a/clutter/clutter/clutter-grid-layout.c b/clutter/clutter/clutter-grid-layout.c index 29ec547591f..ebc022eb754 100644 --- a/clutter/clutter/clutter-grid-layout.c +++ b/clutter/clutter/clutter-grid-layout.c @@ -1391,8 +1391,7 @@ allocate_child (ClutterGridRequest *request, static void clutter_grid_layout_allocate (ClutterLayoutManager *layout, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { ClutterGridLayout *self = CLUTTER_GRID_LAYOUT (layout); ClutterOrientation orientation; @@ -1453,7 +1452,7 @@ clutter_grid_layout_allocate (ClutterLayoutManager *layout, child_allocation.x2 = child_allocation.x1 + width; child_allocation.y2 = child_allocation.y1 + height; - clutter_actor_allocate (child, &child_allocation, flags); + clutter_actor_allocate (child, &child_allocation); } } diff --git a/clutter/clutter/clutter-layout-manager.c b/clutter/clutter/clutter-layout-manager.c index 6fb49b7a5bb..ad642d8b6a0 100644 --- a/clutter/clutter/clutter-layout-manager.c +++ b/clutter/clutter/clutter-layout-manager.c @@ -253,8 +253,7 @@ layout_manager_real_get_preferred_height (ClutterLayoutManager *manager, static void layout_manager_real_allocate (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { LAYOUT_MANAGER_WARN_NOT_IMPLEMENTED (manager, "allocate"); } @@ -434,7 +433,6 @@ clutter_layout_manager_get_preferred_height (ClutterLayoutManager *manager, * @container: the #ClutterContainer using @manager * @allocation: the #ClutterActorBox containing the allocated area * of @container - * @flags: the allocation flags * * Allocates the children of @container given an area * @@ -445,8 +443,7 @@ clutter_layout_manager_get_preferred_height (ClutterLayoutManager *manager, void clutter_layout_manager_allocate (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { ClutterLayoutManagerClass *klass; @@ -455,7 +452,7 @@ clutter_layout_manager_allocate (ClutterLayoutManager *manager, g_return_if_fail (allocation != NULL); klass = CLUTTER_LAYOUT_MANAGER_GET_CLASS (manager); - klass->allocate (manager, container, allocation, flags); + klass->allocate (manager, container, allocation); } /** diff --git a/clutter/clutter/clutter-layout-manager.h b/clutter/clutter/clutter-layout-manager.h index ec87e0ed7f7..6df0cecdf5a 100644 --- a/clutter/clutter/clutter-layout-manager.h +++ b/clutter/clutter/clutter-layout-manager.h @@ -115,8 +115,7 @@ struct _ClutterLayoutManagerClass gfloat *nat_height_p); void (* allocate) (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags); + const ClutterActorBox *allocation); void (* set_container) (ClutterLayoutManager *manager, ClutterContainer *container); @@ -158,8 +157,7 @@ void clutter_layout_manager_get_preferred_height (ClutterLayoutMa CLUTTER_EXPORT void clutter_layout_manager_allocate (ClutterLayoutManager *manager, ClutterContainer *container, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags); + const ClutterActorBox *allocation); CLUTTER_EXPORT void clutter_layout_manager_set_container (ClutterLayoutManager *manager, diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index 3d76ede0c50..9657dc8b595 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -613,8 +613,7 @@ stage_is_default (ClutterStage *stage) static void clutter_stage_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv; ClutterActorBox alloc = CLUTTER_ACTOR_BOX_INIT_ZERO; @@ -654,12 +653,11 @@ clutter_stage_allocate (ClutterActor *self, "Following allocation to %.2fx%.2f", width, height); - clutter_actor_set_allocation (self, box, flags); + clutter_actor_set_allocation (self, box); clutter_layout_manager_allocate (layout_manager, CLUTTER_CONTAINER (self), - &children_box, - flags); + &children_box); /* Ensure the window is sized correctly */ if (priv->min_size_changed) @@ -712,12 +710,11 @@ clutter_stage_allocate (ClutterActor *self, override.x2, override.y2); /* and store the overridden allocation */ - clutter_actor_set_allocation (self, &override, flags); + clutter_actor_set_allocation (self, &override); clutter_layout_manager_allocate (layout_manager, CLUTTER_CONTAINER (self), - &override, - flags); + &override); } /* reset the viewport if the allocation effectively changed */ @@ -1368,8 +1365,7 @@ _clutter_stage_maybe_relayout (ClutterActor *actor) CLUTTER_SET_PRIVATE_FLAGS (queued_actor, CLUTTER_IN_RELAYOUT); old_version = priv->pending_relayouts_version; - clutter_actor_allocate_preferred_size (queued_actor, - CLUTTER_ALLOCATION_NONE); + clutter_actor_allocate_preferred_size (queued_actor); CLUTTER_UNSET_PRIVATE_FLAGS (queued_actor, CLUTTER_IN_RELAYOUT); diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c index a97e94b9232..2886016fb63 100644 --- a/clutter/clutter/clutter-text.c +++ b/clutter/clutter/clutter-text.c @@ -3037,8 +3037,7 @@ clutter_text_get_preferred_height (ClutterActor *self, static void clutter_text_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { ClutterText *text = CLUTTER_TEXT (self); ClutterActorClass *parent_class; @@ -3058,7 +3057,7 @@ clutter_text_allocate (ClutterActor *self, box->y2 - box->y1); parent_class = CLUTTER_ACTOR_CLASS (clutter_text_parent_class); - parent_class->allocate (self, box, flags); + parent_class->allocate (self, box); } static gboolean diff --git a/clutter/clutter/deprecated/clutter-group.c b/clutter/clutter/deprecated/clutter-group.c index af602fd51ca..dce35cff80e 100644 --- a/clutter/clutter/deprecated/clutter-group.c +++ b/clutter/clutter/deprecated/clutter-group.c @@ -333,21 +333,20 @@ clutter_group_real_get_preferred_height (ClutterActor *actor, static void clutter_group_real_allocate (ClutterActor *actor, - const ClutterActorBox *allocation, - ClutterAllocationFlags flags) + const ClutterActorBox *allocation) { ClutterGroupPrivate *priv = CLUTTER_GROUP (actor)->priv; ClutterActorClass *klass; klass = CLUTTER_ACTOR_CLASS (clutter_group_parent_class); - klass->allocate (actor, allocation, flags); + klass->allocate (actor, allocation); if (priv->children == NULL) return; clutter_layout_manager_allocate (priv->layout, CLUTTER_CONTAINER (actor), - allocation, flags); + allocation); } static void diff --git a/src/tests/clutter/conform/actor-anchors.c b/src/tests/clutter/conform/actor-anchors.c index 3cf3191f307..bd934ff1406 100644 --- a/src/tests/clutter/conform/actor-anchors.c +++ b/src/tests/clutter/conform/actor-anchors.c @@ -716,8 +716,8 @@ actor_pivot (void) clutter_actor_add_child (stage, actor_explicit); /* Fake allocation or pivot-point will not have any effect */ - clutter_actor_allocate (actor_implicit, &allocation, CLUTTER_ALLOCATION_NONE); - clutter_actor_allocate (actor_explicit, &allocation, CLUTTER_ALLOCATION_NONE); + clutter_actor_allocate (actor_implicit, &allocation); + clutter_actor_allocate (actor_explicit, &allocation); clutter_actor_set_pivot_point (actor_implicit, 0.5, 0.5); clutter_actor_set_pivot_point (actor_explicit, 0.5, 0.5); diff --git a/src/tests/clutter/conform/actor-pick.c b/src/tests/clutter/conform/actor-pick.c index dcee96424ed..3511be7d2cd 100644 --- a/src/tests/clutter/conform/actor-pick.c +++ b/src/tests/clutter/conform/actor-pick.c @@ -82,7 +82,7 @@ on_timeout (gpointer data) /* Only allocated actors can be picked, so force an allocation * of the overlay actor here. */ - clutter_actor_allocate (over_actor, &over_actor_box, 0); + clutter_actor_allocate (over_actor, &over_actor_box); if (g_test_verbose ()) g_print ("Clipped covering actor:\n"); diff --git a/src/tests/clutter/interactive/test-layout.c b/src/tests/clutter/interactive/test-layout.c index ad9b4e209c6..5f697c90714 100644 --- a/src/tests/clutter/interactive/test-layout.c +++ b/src/tests/clutter/interactive/test-layout.c @@ -276,15 +276,14 @@ my_thing_get_preferred_height (ClutterActor *self, static void my_thing_allocate (ClutterActor *self, - const ClutterActorBox *box, - ClutterAllocationFlags flags) + const ClutterActorBox *box) { MyThingPrivate *priv; gfloat current_x, current_y, max_row_height; ClutterActorIter iter; ClutterActor *child; - clutter_actor_set_allocation (self, box, flags); + clutter_actor_set_allocation (self, box); priv = MY_THING (self)->priv; @@ -322,7 +321,7 @@ my_thing_allocate (ClutterActor *self, child_box.x2 = child_box.x1 + natural_width; child_box.y2 = child_box.y1 + natural_height; - clutter_actor_allocate (child, &child_box, flags); + clutter_actor_allocate (child, &child_box); /* if we take into account the transformation of the children * then we first check if it's transformed; then we get the -- GitLab From 787d9a5a150f25c659e20df4637b974b565c95e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 9 May 2020 21:43:06 +0200 Subject: [PATCH 09/10] clutter: Use notify::allocation instead of allocation-changed We're going to remove the "allocation-changed" signal from ClutterActor since it's no longer needed now that ClutterAllocationFlags are gone. So listen to "notify-allocation" instead, which has been the recommended thing to do for some time now anyway. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245 --- clutter/clutter/clutter-align-constraint.c | 4 ++-- clutter/clutter/clutter-deform-effect.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clutter/clutter/clutter-align-constraint.c b/clutter/clutter/clutter-align-constraint.c index c7ff711b744..ed10ece2efa 100644 --- a/clutter/clutter/clutter-align-constraint.c +++ b/clutter/clutter/clutter-align-constraint.c @@ -85,7 +85,7 @@ G_DEFINE_TYPE (ClutterAlignConstraint, static void source_position_changed (ClutterActor *actor, - const ClutterActorBox *allocation, + GParamSpec *pspec, ClutterAlignConstraint *align) { if (align->actor != NULL) @@ -409,7 +409,7 @@ clutter_align_constraint_set_source (ClutterAlignConstraint *align, align->source = source; if (align->source != NULL) { - g_signal_connect (align->source, "allocation-changed", + g_signal_connect (align->source, "notify::allocation", G_CALLBACK (source_position_changed), align); g_signal_connect (align->source, "destroy", diff --git a/clutter/clutter/clutter-deform-effect.c b/clutter/clutter/clutter-deform-effect.c index 5f4de5ac7a0..a1b7c89bb51 100644 --- a/clutter/clutter/clutter-deform-effect.c +++ b/clutter/clutter/clutter-deform-effect.c @@ -128,9 +128,9 @@ clutter_deform_effect_deform_vertex (ClutterDeformEffect *effect, } static void -vbo_invalidate (ClutterActor *actor, - const ClutterActorBox *allocation, - ClutterDeformEffect *effect) +vbo_invalidate (ClutterActor *actor, + GParamSpec *pspec, + ClutterDeformEffect *effect) { effect->priv->is_dirty = TRUE; } @@ -155,7 +155,7 @@ clutter_deform_effect_set_actor (ClutterActorMeta *meta, * changes */ if (actor != NULL) - priv->allocation_id = g_signal_connect (actor, "allocation-changed", + priv->allocation_id = g_signal_connect (actor, "notify::allocation", G_CALLBACK (vbo_invalidate), meta); -- GitLab From e50e14af8283582882b198f79ca8ed01de220e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 9 May 2020 21:44:13 +0200 Subject: [PATCH 10/10] clutter/actor: Remove "allocation-changed" signal Since we now no have ClutterAllocationFlags, there's no reason anymore for keeping the "allocation-changed" signal, so remove it. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245 --- clutter/clutter/clutter-actor.c | 63 ++------------------------------- 1 file changed, 3 insertions(+), 60 deletions(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index f18df7ce178..0aa696042d1 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -1013,7 +1013,6 @@ enum MOTION_EVENT, ENTER_EVENT, LEAVE_EVENT, - ALLOCATION_CHANGED, TRANSITIONS_COMPLETED, TOUCH_EVENT, TRANSITION_STOPPED, @@ -2577,14 +2576,13 @@ clutter_actor_notify_if_geometry_changed (ClutterActor *self, * Return value: %TRUE if the allocation of the #ClutterActor has been * changed, and %FALSE otherwise */ -static inline gboolean +static inline void clutter_actor_set_allocation_internal (ClutterActor *self, const ClutterActorBox *box) { ClutterActorPrivate *priv = self->priv; GObject *obj; gboolean x1_changed, y1_changed, x2_changed, y2_changed; - gboolean retval; ClutterActorBox old_alloc = { 0, }; obj = G_OBJECT (self); @@ -2623,17 +2621,11 @@ clutter_actor_set_allocation_internal (ClutterActor *self, priv->content_box_valid = FALSE; g_object_notify_by_pspec (obj, obj_props[PROP_CONTENT_BOX]); } - - retval = TRUE; } - else - retval = FALSE; clutter_actor_notify_if_geometry_changed (self, &old_alloc); g_object_thaw_notify (obj); - - return retval; } static void @@ -2641,11 +2633,10 @@ clutter_actor_real_allocate (ClutterActor *self, const ClutterActorBox *box) { ClutterActorPrivate *priv = self->priv; - gboolean changed; g_object_freeze_notify (G_OBJECT (self)); - changed = clutter_actor_set_allocation_internal (self, box); + clutter_actor_set_allocation_internal (self, box); /* we allocate our children before we notify changes in our geometry, * so that people connecting to properties will be able to get valid @@ -2679,14 +2670,6 @@ clutter_actor_real_allocate (ClutterActor *self, &children_box); } - if (changed) - { - ClutterActorBox signal_box = priv->allocation; - - g_signal_emit (self, actor_signals[ALLOCATION_CHANGED], 0, - &signal_box); - } - g_object_thaw_notify (G_OBJECT (self)); } @@ -8536,33 +8519,6 @@ clutter_actor_class_init (ClutterActorClass *klass) G_TYPE_NONE, 1, CLUTTER_TYPE_PICK_CONTEXT); - /** - * ClutterActor::allocation-changed: - * @actor: the #ClutterActor that emitted the signal - * @box: a #ClutterActorBox with the new allocation - * - * The ::allocation-changed signal is emitted when the - * #ClutterActor:allocation property changes. Usually, application - * code should just use the notifications for the :allocation property - * but if you want to track the allocation flags as well, for instance - * to know whether the absolute origin of @actor changed, then you might - * want use this signal instead. - * - * Since: 1.0 - */ - actor_signals[ALLOCATION_CHANGED] = - g_signal_new (I_("allocation-changed"), - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - _clutter_marshal_VOID__BOXED_FLAGS, - G_TYPE_NONE, 1, - CLUTTER_TYPE_ACTOR_BOX | G_SIGNAL_TYPE_STATIC_SCOPE); - g_signal_set_va_marshaller (actor_signals[ALLOCATION_CHANGED], - G_TYPE_FROM_CLASS (object_class), - _clutter_marshal_VOID__BOXED_FLAGSv); - /** * ClutterActor::transitions-completed: * @actor: a #ClutterActor @@ -10271,9 +10227,6 @@ void clutter_actor_set_allocation (ClutterActor *self, const ClutterActorBox *box) { - ClutterActorPrivate *priv; - gboolean changed; - g_return_if_fail (CLUTTER_IS_ACTOR (self)); g_return_if_fail (box != NULL); @@ -10285,19 +10238,9 @@ clutter_actor_set_allocation (ClutterActor *self, return; } - priv = self->priv; - g_object_freeze_notify (G_OBJECT (self)); - changed = clutter_actor_set_allocation_internal (self, box); - - if (changed) - { - ClutterActorBox signal_box = priv->allocation; - - g_signal_emit (self, actor_signals[ALLOCATION_CHANGED], 0, - &signal_box); - } + clutter_actor_set_allocation_internal (self, box); g_object_thaw_notify (G_OBJECT (self)); } -- GitLab