diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index aebfd91ac7..51a35d95fc 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -1160,7 +1160,7 @@ gtk_paned_get_preferred_size_for_opposite_orientation (GtkWidget *widget, int *natural) { GtkPaned *paned = GTK_PANED (widget); - int for_start_child, for_end_child; + int for_start_child, for_end_child, for_handle; int child_min, child_nat; if (size > -1 && @@ -1168,22 +1168,21 @@ gtk_paned_get_preferred_size_for_opposite_orientation (GtkWidget *widget, paned->end_child && gtk_widget_get_visible (paned->end_child)) { int start_child_req, end_child_req; - int handle_size; gtk_widget_measure (paned->handle_widget, - OPPOSITE_ORIENTATION (paned->orientation), + paned->orientation, -1, - NULL, &handle_size, + NULL, &for_handle, NULL, NULL); gtk_widget_measure (paned->start_child, paned->orientation, -1, &start_child_req, NULL, NULL, NULL); gtk_widget_measure (paned->end_child, paned->orientation, -1, &end_child_req, NULL, NULL, NULL); gtk_paned_compute_position (paned, - size - handle_size, start_child_req, end_child_req, + size - for_handle, start_child_req, end_child_req, NULL, NULL, &for_start_child); - for_end_child = size - for_start_child - handle_size; + for_end_child = size - for_start_child - for_handle; if (paned->shrink_start_child) for_start_child = MAX (start_child_req, for_start_child); @@ -1194,6 +1193,7 @@ gtk_paned_get_preferred_size_for_opposite_orientation (GtkWidget *widget, { for_start_child = size; for_end_child = size; + for_handle = -1; } *minimum = *natural = 0; @@ -1202,7 +1202,7 @@ gtk_paned_get_preferred_size_for_opposite_orientation (GtkWidget *widget, { gtk_widget_measure (paned->start_child, OPPOSITE_ORIENTATION (paned->orientation), - MAX (for_start_child, -1), + for_start_child, &child_min, &child_nat, NULL, NULL); @@ -1214,7 +1214,20 @@ gtk_paned_get_preferred_size_for_opposite_orientation (GtkWidget *widget, { gtk_widget_measure (paned->end_child, OPPOSITE_ORIENTATION (paned->orientation), - MAX (for_end_child, -1), + for_end_child, + &child_min, &child_nat, + NULL, NULL); + + *minimum = MAX (*minimum, child_min); + *natural = MAX (*natural, child_nat); + } + + if (paned->start_child && gtk_widget_get_visible (paned->start_child) && + paned->end_child && gtk_widget_get_visible (paned->end_child)) + { + gtk_widget_measure (paned->handle_widget, + OPPOSITE_ORIENTATION (paned->orientation), + for_handle, &child_min, &child_nat, NULL, NULL); diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c index a2a8af3f84..21ee564182 100644 --- a/gtk/gtksizerequest.c +++ b/gtk/gtksizerequest.c @@ -494,8 +494,8 @@ gtk_widget_measure (GtkWidget *widget, gtk_widget_measure (widget, OPPOSITE_ORIENTATION (orientation), -1, &min_opposite_size, NULL, NULL, NULL); if (for_size < min_opposite_size) { - g_critical ("gtk_widget_measure: assertion 'for_size >= minimum opposite size' failed for %s %p: %u >= %u", - G_OBJECT_TYPE_NAME (widget), widget, for_size, min_opposite_size); + g_critical ("gtk_widget_measure: assertion 'for_size >= minimum opposite size' failed: %u >= %u", + for_size, min_opposite_size); for_size = min_opposite_size; } } diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 6ae7cef9fb..5173068453 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -4165,12 +4165,14 @@ update_realized_window_properties (GtkWindow *window) static void gtk_window_compute_default_size (GtkWindow *window, + int cur_width, + int cur_height, int max_width, int max_height, int *min_width, int *min_height, - int *nat_width, - int *nat_height) + int *width, + int *height) { GtkWidget *widget = GTK_WIDGET (window); @@ -4182,14 +4184,20 @@ gtk_window_compute_default_size (GtkWindow *window, &minimum, &natural, NULL, NULL); *min_height = minimum; - *nat_height = MAX (minimum, MIN (max_height, natural)); + if (cur_height > 0) + *height = MAX (cur_height, minimum); + else + *height = MAX (minimum, MIN (max_height, natural)); gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, - *nat_height, + *height, &minimum, &natural, NULL, NULL); *min_width = minimum; - *nat_width = MAX (minimum, MIN (max_width, natural)); + if (cur_width > 0) + *width = MAX (cur_width, minimum); + else + *width = MAX (minimum, MIN (max_width, natural)); } else /* GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or CONSTANT_SIZE */ { @@ -4199,14 +4207,20 @@ gtk_window_compute_default_size (GtkWindow *window, &minimum, &natural, NULL, NULL); *min_width = minimum; - *nat_width = MAX (minimum, MIN (max_width, natural)); + if (cur_width > 0) + *width = MAX (cur_width, minimum); + else + *width = MAX (minimum, MIN (max_width, natural)); gtk_widget_measure (widget, GTK_ORIENTATION_VERTICAL, - *nat_width, + *width, &minimum, &natural, NULL, NULL); *min_height = minimum; - *nat_height = MAX (minimum, MIN (max_height, natural)); + if (cur_height > 0) + *height = MAX (cur_height, minimum); + else + *height = MAX (minimum, MIN (max_height, natural)); } } @@ -4239,22 +4253,15 @@ toplevel_compute_size (GdkToplevel *toplevel, GtkBorder shadow; int bounds_width, bounds_height; int min_width, min_height; - int nat_width, nat_height; gdk_toplevel_size_get_bounds (size, &bounds_width, &bounds_height); gtk_window_compute_default_size (window, + priv->default_width, priv->default_height, bounds_width, bounds_height, &min_width, &min_height, - &nat_width, &nat_height); + &width, &height); - width = priv->default_width; - height = priv->default_height; - - if (width <= 0) - width = nat_width; - if (height <= 0) - height = nat_height; if (width < min_width) width = min_width; diff --git a/testsuite/reftests/default-size-too-small.ref.ui b/testsuite/reftests/default-size-too-small.ref.ui new file mode 100644 index 0000000000..1eaf937c72 --- /dev/null +++ b/testsuite/reftests/default-size-too-small.ref.ui @@ -0,0 +1,12 @@ + + + + 0 + + + Hello +World + + + + diff --git a/testsuite/reftests/default-size-too-small.ui b/testsuite/reftests/default-size-too-small.ui new file mode 100644 index 0000000000..fc504de50e --- /dev/null +++ b/testsuite/reftests/default-size-too-small.ui @@ -0,0 +1,13 @@ + + + + 4 + 0 + + + Hello World + True + + + + diff --git a/testsuite/reftests/meson.build b/testsuite/reftests/meson.build index 1df038aa22..5f36c6ddb4 100644 --- a/testsuite/reftests/meson.build +++ b/testsuite/reftests/meson.build @@ -266,6 +266,8 @@ testdata = [ 'data-url.css', 'data-url.ref.ui', 'data-url.ui', + 'default-size-too-small.ref.ui', + 'default-size-too-small.ui', 'default-size-undecorated.ui', 'default-size-undecorated.ref.ui', 'default-size-with-titlebar.ui', @@ -425,6 +427,9 @@ testdata = [ 'opacity-initial.ui', 'overlay-no-main-widget.ref.ui', 'overlay-no-main-widget.ui', + 'paned-handle-size.css', + 'paned-handle-size.ref.ui', + 'paned-handle-size.ui', 'paned-undersized.css', 'paned-undersized.ref.ui', 'paned-undersized.ui', diff --git a/testsuite/reftests/paned-handle-size.css b/testsuite/reftests/paned-handle-size.css new file mode 100644 index 0000000000..502437c543 --- /dev/null +++ b/testsuite/reftests/paned-handle-size.css @@ -0,0 +1,15 @@ +paned separator, +picture { + all: unset; + background: firebrick; +} + +paned.vertical > separator { + min-width: 10px; + min-height: 20px; +} + +paned.horizontal > separator { + min-width: 20px; + min-height: 10px; +} diff --git a/testsuite/reftests/paned-handle-size.ref.ui b/testsuite/reftests/paned-handle-size.ref.ui new file mode 100644 index 0000000000..72a83a93c3 --- /dev/null +++ b/testsuite/reftests/paned-handle-size.ref.ui @@ -0,0 +1,55 @@ + + + + 0 + + + + + vertical + + + top left + + + + + 20 + + + + + bottom left + + + + + + + 20 + + + + + vertical + + + top right + + + + + 20 + + + + + bottom right + + + + + + + + diff --git a/testsuite/reftests/paned-handle-size.ui b/testsuite/reftests/paned-handle-size.ui new file mode 100644 index 0000000000..c050dd2fde --- /dev/null +++ b/testsuite/reftests/paned-handle-size.ui @@ -0,0 +1,40 @@ + + + + 0 + + + + + vertical + + + top left + + + + + bottom left + + + + + + + vertical + + + top right + + + + + bottom right + + + + + + + + diff --git a/testsuite/tools/simplify-data-3to4/box.expected b/testsuite/tools/simplify-data-3to4/box.expected index 54dde405b9..15b6f34c74 100644 --- a/testsuite/tools/simplify-data-3to4/box.expected +++ b/testsuite/tools/simplify-data-3to4/box.expected @@ -7,15 +7,15 @@ 1 - 1 + vertical - 3 + center 1 0 - 3 + center _ 1 1 @@ -30,7 +30,7 @@ - 3 + center 1 E 1 @@ -50,12 +50,12 @@ 0 - 3 + center 1 0 - 3 + center _ 1 1 @@ -70,7 +70,7 @@ - 3 + center 1 E 1 @@ -91,13 +91,13 @@ - 3 - 1 + center + vertical 0 1 - 3 + center _ 1 1 @@ -112,7 +112,7 @@ - 3 + center 1 E 1 @@ -133,10 +133,10 @@ 0 1 - 1 + vertical - 3 + center _I 1 1 @@ -151,7 +151,7 @@ - 3 + center 1 EI 1 @@ -171,7 +171,7 @@ _S 1 1 - 3 + center @@ -179,7 +179,7 @@ FS 1 1 - 1 + start @@ -188,7 +188,7 @@ ES 1 1 - 3 + center @@ -197,7 +197,7 @@ FES 1 1 - 1 + start @@ -205,7 +205,7 @@ _N 1 1 - 3 + center @@ -213,7 +213,7 @@ FN 1 1 - 2 + end @@ -222,7 +222,7 @@ EN 1 1 - 3 + center @@ -231,7 +231,7 @@ FEN 1 1 - 2 + end @@ -239,7 +239,7 @@ _C 1 1 - 3 + center @@ -247,7 +247,7 @@ FC 1 1 - 3 + center @@ -256,7 +256,7 @@ EC 1 1 - 3 + center @@ -265,7 +265,7 @@ FEC 1 1 - 3 + center @@ -273,7 +273,7 @@ _B 1 1 - 3 + center @@ -281,7 +281,7 @@ FB 1 1 - 4 + baseline @@ -290,7 +290,7 @@ EB 1 1 - 3 + center @@ -299,7 +299,7 @@ FEB 1 1 - 4 + baseline @@ -308,10 +308,10 @@ 0 1 - 1 + vertical - 3 + center _I 1 1 @@ -328,7 +328,7 @@ - 3 + center EI 1 1 @@ -348,7 +348,7 @@ _S 1 1 - 3 + center 0 @@ -357,7 +357,7 @@ FS 1 1 - 1 + start 0 @@ -366,7 +366,7 @@ ES 1 1 - 3 + center 1 @@ -375,7 +375,7 @@ FES 1 1 - 1 + start 1 @@ -384,7 +384,7 @@ _N 1 1 - 3 + center 0 @@ -393,7 +393,7 @@ FN 1 1 - 2 + end 0 @@ -402,7 +402,7 @@ EN 1 1 - 3 + center 1 @@ -411,7 +411,7 @@ FEN 1 1 - 2 + end 1 @@ -420,7 +420,7 @@ _C 1 1 - 3 + center 0 @@ -429,7 +429,7 @@ FC 1 1 - 3 + center 0 @@ -438,7 +438,7 @@ EC 1 1 - 3 + center 1 @@ -447,7 +447,7 @@ FEC 1 1 - 3 + center 1 @@ -456,7 +456,7 @@ _B 1 1 - 3 + center 0 @@ -465,7 +465,7 @@ FB 1 1 - 4 + baseline 0 @@ -474,7 +474,7 @@ EB 1 1 - 3 + center 1 @@ -483,7 +483,7 @@ FEB 1 1 - 4 + baseline 1 @@ -493,10 +493,10 @@ 0 1 - 1 + vertical - 3 + center _I 1 1 @@ -513,7 +513,7 @@ - 3 + center EI 1 1 @@ -533,7 +533,7 @@ _S 1 1 - 3 + center 1 @@ -542,7 +542,7 @@ FS 1 1 - 1 + start 1 @@ -551,7 +551,7 @@ ES 1 1 - 3 + center 1 @@ -560,7 +560,7 @@ FES 1 1 - 1 + start 1 @@ -569,7 +569,7 @@ _N 1 1 - 3 + center 1 @@ -578,7 +578,7 @@ FN 1 1 - 2 + end 1 @@ -587,7 +587,7 @@ EN 1 1 - 3 + center 1 @@ -596,7 +596,7 @@ FEN 1 1 - 2 + end 1 @@ -605,7 +605,7 @@ _C 1 1 - 3 + center 1 @@ -614,7 +614,7 @@ FC 1 1 - 3 + center 1 @@ -623,7 +623,7 @@ EC 1 1 - 3 + center 1 @@ -632,7 +632,7 @@ FEC 1 1 - 3 + center 1 @@ -641,7 +641,7 @@ _B 1 1 - 3 + center 1 @@ -650,7 +650,7 @@ FB 1 1 - 4 + baseline 1 @@ -659,7 +659,7 @@ EB 1 1 - 3 + center 1 @@ -668,7 +668,7 @@ FEB 1 1 - 4 + baseline 1 diff --git a/testsuite/tools/simplify-data-3to4/checkbutton.expected b/testsuite/tools/simplify-data-3to4/checkbutton.expected index 24ef3bcd37..c5f8ed6361 100644 --- a/testsuite/tools/simplify-data-3to4/checkbutton.expected +++ b/testsuite/tools/simplify-data-3to4/checkbutton.expected @@ -4,7 +4,7 @@ - 1 + vertical 1 diff --git a/testsuite/tools/simplify-data-3to4/grid.expected b/testsuite/tools/simplify-data-3to4/grid.expected index 60f2972846..2d040d0f19 100644 --- a/testsuite/tools/simplify-data-3to4/grid.expected +++ b/testsuite/tools/simplify-data-3to4/grid.expected @@ -100,8 +100,8 @@ 1 1 - 3 - 3 + center + center 1 1 @@ -112,8 +112,8 @@ 1 1 - 3 - 3 + center + center 2 1 diff --git a/testsuite/tools/simplify-data-3to4/gtkfilechooserdialog.expected b/testsuite/tools/simplify-data-3to4/gtkfilechooserdialog.expected index 9275810c54..b96ec784d8 100644 --- a/testsuite/tools/simplify-data-3to4/gtkfilechooserdialog.expected +++ b/testsuite/tools/simplify-data-3to4/gtkfilechooserdialog.expected @@ -9,7 +9,7 @@ 0 - 1 + vertical 0 @@ -31,6 +31,6 @@ - 2 + vertical diff --git a/testsuite/tools/simplify-data-3to4/office-runner.expected b/testsuite/tools/simplify-data-3to4/office-runner.expected index b166475564..fa8453830d 100644 --- a/testsuite/tools/simplify-data-3to4/office-runner.expected +++ b/testsuite/tools/simplify-data-3to4/office-runner.expected @@ -11,7 +11,7 @@ 12 12 12 - 1 + vertical 12 @@ -34,7 +34,7 @@ - 1 + start 1 0 • Click the "Run!" button, and then dash to your desk or meeting. @@ -129,11 +129,11 @@ - 3 - 1 + center + vertical - 1 + start 0 Silver Trophy! 1 @@ -148,7 +148,7 @@ - 1 + start 0 You managed to finish the route with the 2nd best time ever, <b>48.15 seconds!</b> 1 @@ -157,7 +157,7 @@ - 1 + start 0 Only <b>3.75 seconds</b> separate you from the gold trophy! 1 diff --git a/testsuite/tools/simplify-data-3to4/toolbar.expected b/testsuite/tools/simplify-data-3to4/toolbar.expected index d1bafefd5c..6b5db81054 100644 --- a/testsuite/tools/simplify-data-3to4/toolbar.expected +++ b/testsuite/tools/simplify-data-3to4/toolbar.expected @@ -12,7 +12,7 @@ - 1 + vertical diff --git a/tools/gtk-builder-tool-simplify.c b/tools/gtk-builder-tool-simplify.c index 0f13bf7a6d..dfa4eb7097 100644 --- a/tools/gtk-builder-tool-simplify.c +++ b/tools/gtk-builder-tool-simplify.c @@ -621,7 +621,15 @@ canonical_enum_value (MyParserData *data, GValue value = G_VALUE_INIT; if (gtk_builder_value_from_string_type (data->builder, type, string, &value, NULL)) - return g_strdup_printf ("%d", g_value_get_enum (&value)); + { + GEnumClass *eclass = g_type_class_ref (type); + GEnumValue *evalue = g_enum_get_value (eclass, g_value_get_enum (&value)); + + if (evalue) + return g_strdup (evalue->value_nick); + else + return g_strdup_printf ("%d", g_value_get_enum (&value)); + } return NULL; }