From 0296b0b0cb4d398fbc03d3a1ed9714f17a9a7bab Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 4 Aug 2021 18:59:20 -0600 Subject: [PATCH] canvas: don't call ::size_allocate() for children unless there is just one child and it is "layout sensitive the dumb/Item version of ::size_allocate_children() doesn't do anything but give its full allocation to children, and if there was more than one child, this could not be done in a "dumb" way. Likewise, if the sole child is not layout sensitive, it doesn't care about size allocation --- libs/canvas/item.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/libs/canvas/item.cc b/libs/canvas/item.cc index ae9a47a448..997f914272 100644 --- a/libs/canvas/item.cc +++ b/libs/canvas/item.cc @@ -625,19 +625,13 @@ Item::_size_allocate (Rect const & r) void Item::size_allocate_children (Rect const & r) { - bool have_constraint_container = false; + /* this does nothing by default. Containers like Box or + * ConstraintPacker can override it to do "smart" layout based on this + * Item's allocation. + */ - for (list::const_iterator i = _items.begin(); i != _items.end(); ++i) { - - (*i)->size_allocate (r); - - if (dynamic_cast (*i)) { - have_constraint_container = true; - } - } - - if (have_constraint_container) { - _bounding_box_dirty = true; + if (_items.size() == 1 && _items.front()->layout_sensitive()) { + _items.front()->size_allocate (r); } }