mirror of
https://github.com/brl/mutter.git
synced 2025-01-30 13:22:47 +00:00
67eeea6b62
The usual way to implement a container actor is to override the allocate() virtual function, chain up, and then allocate the actor's children. Clutter now has the ability to delegate layout management to ClutterLayoutManager directly; in the allocation, this is done by checking whether the actor has children, and then call clutter_layout_manager_allocate() from within the default implementation of the ClutterActor::allocate() vfunc. The same vfunc that everyone, has been chaining up to. Whoopsie. Well, we can check if there's a layout manager, and if it's NULL, we bail out. Except that there's a default layout manager, and it's the fixed layout manager, so that classes like Group and Stage work by default. Double whoopsie. The fix for this scenario is a bit nasty; we have to check if the actor class has overridden the allocate() vfunc or not, before actually looking at the layout manager. This means that classes that override the allocate() vfunc are expected to do everything that ClutterActor's default implementation does - which I think it's a fair requirement to have. For newly written code, though, it would probably be best if we just provided a function that does the right thing by default, and that you're supposed to be calling from within the allocate() vfunc implementation, if you ever chose to override it. This new function, clutter_actor_set_allocation(), should come with a warning the size of Texas, to avoid people thinking it's a way to override the whole "call allocate() on each child" mechanism. Plus, it should check if we're inside an allocation sequence, and bail out if not.