From 90803c52e3097d3abf3e8a0cdeecbfd07bfc59e4 Mon Sep 17 00:00:00 2001 From: Matthijs Velsink Date: Tue, 2 Jul 2024 03:47:02 +0200 Subject: [PATCH] popover: Fix invalid width/height check in layout Commit a4cc95b2 introduced a check in layout() that closes the popover if the width or height is smaller than the minimum width or height, respectively. However, that was using gtk_widget_get_preferred_size(), which finds out the minimum height for the minimum width and vice versa, but not the minimum height for the layout width and vice versa. So, certain popovers were not showing, even though they would not have generated a critical to begin with. To fix this, we copy the logic from gtk_widget_allocate() that generates the criticals, and use that to check if we have a good width/height for the popover native or not. Closes #6826 --- gtk/gtkpopover.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index d632bd5997..9071a5ee89 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -698,10 +698,14 @@ gtk_popover_native_layout (GtkNative *native, GtkPopover *popover = GTK_POPOVER (native); GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover); GtkWidget *widget = GTK_WIDGET (popover); - GtkRequisition min, nat; + int min_height_for_width, min_width_for_height; - gtk_widget_get_preferred_size (widget, &min, &nat); - if (width < min.width || height < min.height) + gtk_widget_measure (widget, GTK_ORIENTATION_VERTICAL, width, + &min_height_for_width, NULL, NULL, NULL); + gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, height, + &min_width_for_height, NULL, NULL, NULL); + + if (width < min_width_for_height || height < min_height_for_width) { gtk_popover_popdown (popover); return;