diff --git a/gtk/gtklayoutmanager.c b/gtk/gtklayoutmanager.c index 6467b8ee5a..47ced92b07 100644 --- a/gtk/gtklayoutmanager.c +++ b/gtk/gtklayoutmanager.c @@ -122,7 +122,12 @@ gtk_layout_manager_real_get_request_mode (GtkLayoutManager *manager, child != NULL; child = _gtk_widget_get_next_sibling (child)) { - GtkSizeRequestMode res = gtk_widget_get_request_mode (child); + GtkSizeRequestMode res; + + if (!gtk_widget_should_layout (child)) + continue; + + res = gtk_widget_get_request_mode (child); switch (res) { @@ -143,8 +148,8 @@ gtk_layout_manager_real_get_request_mode (GtkLayoutManager *manager, if (hfw == 0 && wfh == 0) return GTK_SIZE_REQUEST_CONSTANT_SIZE; - return hfw > wfh ? GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH - : GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT; + return hfw >= wfh ? GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH + : GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT; } static void diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c index 001bb26d65..a19f9cea7b 100644 --- a/gtk/gtkstack.c +++ b/gtk/gtkstack.c @@ -2328,9 +2328,30 @@ gtk_stack_compute_expand (GtkWidget *widget, static GtkSizeRequestMode gtk_stack_get_request_mode (GtkWidget *widget) { + GtkStack *stack = GTK_STACK (widget); + GtkStackPrivate *priv = gtk_stack_get_instance_private (stack); GtkWidget *w; int wfh = 0, hfw = 0; + if (!priv->homogeneous[GTK_ORIENTATION_VERTICAL] && + !priv->homogeneous[GTK_ORIENTATION_HORIZONTAL]) + { + GtkSizeRequestMode lv_mode; + + /* Only the visible child, and perhaps the last visible child + * during a transition, matter. Attempt to return constant-size + * when we can. */ + if (priv->last_visible_child) + lv_mode = gtk_widget_get_request_mode (priv->last_visible_child->widget); + else + lv_mode = GTK_SIZE_REQUEST_CONSTANT_SIZE; + + if (lv_mode == GTK_SIZE_REQUEST_CONSTANT_SIZE && priv->visible_child) + return gtk_widget_get_request_mode (priv->visible_child->widget); + else + return lv_mode; + } + for (w = gtk_widget_get_first_child (widget); w != NULL; w = gtk_widget_get_next_sibling (w))