Skip to content

Some more layout fixes

Sergey Bugaev requested to merge bugaevc/libadwaita:fix-align-game into main

Happy New Year!

The first patch makes AdwToolbarView work much better with height-for-width content.

The second one fixes AdwDialogHost. Please don't use gtk_widget_get_preferred_size () like, ever — it doesn't return anything useful. Perhaps it should get deprecated on the GTK side.

Specifically gtk_widget_get_preferred_size () finds the overall minimum width and then the minimum height for that width, which could be huge. There's no reason for you to clamp your allocated height to that height-for-minimum-width, since your allocated width may be larger than the minimum, and so doesn't necessitate that large of a height. So this resulted in the child being allocated a lot more height than that of the window, an the child then getting clipped at window height.

The proper way to clamp your allocation to the minimum required by a child is what adjust_child_allocation () in adw-view-stack.c does, i.e. you first decide on the width, factoring in its minimum width and your allocated width, and then measure the height for that (or the other way around if the child is width-for-height). We could make that function into a shared helper in adw-widget-utils if only measuring the content child and clamping any dialogs that are larger is what you intended to happen. But it looks more likely that it wasn't intended, so instead I went with just using GtkBinLayout.

Merge request reports

Loading