From 93c5fb0b31ce2cf9a5058878a8f4106e0317dab0 Mon Sep 17 00:00:00 2001 From: Matthijs Velsink Date: Tue, 2 Jul 2024 02:50:29 +0200 Subject: [PATCH] popover: Take shadow size into account in measure Commit b9487997 introduced shadows for GtkPopover. These are correctly subtracted while allocating the child widget, but the child is not measured with those shadows subtracted (as is correctly done for the arrow). This can give criticals, for example with some wrapping labels. To fix this, we subtract the shadow size from the `for_size` before passing it to the measure() of the child widget. Closes #5782 Fixes #6796 --- gtk/gtkpopover.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index bdd66f2f8b..f93075d2a0 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -1511,12 +1511,20 @@ gtk_popover_measure (GtkWidget *widget, GtkCssStyle *style; GtkBorder shadow_width; - if (for_size >= 0 && (POS_IS_VERTICAL (priv->position) == (orientation == GTK_ORIENTATION_HORIZONTAL))) - for_size -= tail_height; - style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (priv->contents_widget))); gtk_css_shadow_value_get_extents (style->used->box_shadow, &shadow_width); + if (for_size >= 0) + { + if ((POS_IS_VERTICAL (priv->position) == (orientation == GTK_ORIENTATION_HORIZONTAL))) + for_size -= tail_height; + + if (orientation == GTK_ORIENTATION_HORIZONTAL) + for_size -= shadow_width.top + shadow_width.bottom; + else + for_size -= shadow_width.left + shadow_width.right; + } + gtk_widget_measure (priv->contents_widget, orientation, for_size, minimum, natural,