Skip to content

clutter/box-layout: Don't cast children sizes to integers

Jonas Dreßler requested to merge verdre/mutter:box-layout-no-ints into main

The distribute_natural_allocation() function was copied over from Gtk to Clutter 11 years ago with commit e636a0bb. Gtk only supports integers sizes in its layout machinery, while Clutter does everything using floats.

Since this function sets the minimum_size (the size we allocate the children in the end) to an integer, this means we're implicitly typecasting floats to integers here, effectively floor()'ing all sizes that we allocate the box children.

A bug this caused in gnome-shell was that a scrollView (like the one in the endSessionDialog) was showing scrollbars even though the content perfectly fit inside the view: Say the content and its scrollView parent request a size of 63.9 px, but get allocated a size of 63 px by a box layout. Now the scrollView notices that its allocated size is smaller than the requested size and thus shows a scrollbar.

So fix that and use floats in distribute_natural_allocation() instead of integers, as we do everywhere else in the layout machinery.

Edited by Jonas Dreßler

Merge request reports