GNOME Bugzilla – Bug 689316
Strange issues with margins
Last modified: 2012-11-30 23:20:16 UTC
Margins may have weird creeping offsets, due to adjusted allocations. Simple gjs testcase: const Clutter = imports.gi.Clutter; Clutter.init(null); let stage = new Clutter.Stage({ user_resizable: true }); let container = new Clutter.Actor(); container.set_margin(new Clutter.Margin({ top: 20, left: 20 })); stage.add_child(container); let box = new Clutter.Actor({ background_color: Clutter.Color.get_static(Clutter.StaticColor.RED), width: 100, height: 100 }); container.add_child(box); stage.show(); Clutter.main(); Attached patch fixes issues.
Created attachment 230254 [details] [review] actor: Use fixed positioning for allocate_preferred_size clutter_actor_allocate_preferred_size is supposed to use the fixed position of an actor. Unfortunately, recent refactorings made it so that it accidentally used the current allocation. As the current allocation may be adjusted by the actor, or have been previously allocated in a strange spot, it may have unintended side effects. Use the fixed positioning of the actor instead. This fixes weird issues with margins colliding with ClutterFixedLayout, causing strange offsets on relayout.
Review of attachment 230254 [details] [review]: looks okay; with one minor change, it can be committed. ::: clutter/clutter-actor.c @@ +15105,3 @@ + if (priv->position_set) + { + info = _clutter_actor_peek_layout_info (self); use _clutter_actor_get_layout_info_or_defaults() instead, to avoid the NULL check.
Attachment 230254 [details] pushed as 15b8118 - actor: Use fixed positioning for allocate_preferred_size Pushed with suggested changes, thanks!