GTK4: Widget measurement

I’ve another question, please. I’ve noticed that widget.measure get called only 2 times during widget creation. What would be the best practice to update widget size depending on parent or window size change?

Widgets only change size when their contents changes size—which either means a child widget changes size, or some other content-related entity, like a PangoLayout or an image, changes size.

Whenever a widget needs to invalidate its size, it needs to call gtk_widget_queue_resize(); this will invalidate the cached size, and once the parent asks for the size of the widget, the GtkWidgetClass.measure() virtual function will be called.


Why this snippet pass 0 always for the height parameter?

public class Gtk4Demo.TestDA : Gtk.DrawingArea {
    construct {
        this.resize.connect ((w, h) => {
            print ("w %d, h %d\n", w, h);

prints something like this

w 656, h 0
w 660, h 0
w 661, h 0
w 662, h 0
w 663, h 0

now I know my mistake! this is because the widget is inside a box and vertical expansion is not set.