[gtk/wip/otte/hfw-min-size: 1/4] window: Always clamp to max size
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/hfw-min-size: 1/4] window: Always clamp to max size
- Date: Sun, 21 Nov 2021 06:12:59 +0000 (UTC)
commit 358893aa841c42017160bbe74e74e40c8abc3eb6
Author: Benjamin Otte <otte redhat com>
Date: Sun Nov 21 05:32:20 2021 +0100
window: Always clamp to max size
When computing the window size, always try to clamp to the max size.
This will shrink a window down into a sane size if it was too big
before.
gtk/gtkwindow.c | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 5173068453..32c9798476 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -4184,20 +4184,18 @@ gtk_window_compute_default_size (GtkWindow *window,
&minimum, &natural,
NULL, NULL);
*min_height = minimum;
- if (cur_height > 0)
- *height = MAX (cur_height, minimum);
- else
- *height = MAX (minimum, MIN (max_height, natural));
+ if (cur_height <= 0)
+ cur_height = natural;
+ *height = MAX (minimum, MIN (max_height, cur_height));
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL,
*height,
&minimum, &natural,
NULL, NULL);
*min_width = minimum;
- if (cur_width > 0)
- *width = MAX (cur_width, minimum);
- else
- *width = MAX (minimum, MIN (max_width, natural));
+ if (cur_width <= 0)
+ cur_width = natural;
+ *width = MAX (minimum, MIN (max_width, cur_width));
}
else /* GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or CONSTANT_SIZE */
{
@@ -4207,20 +4205,19 @@ gtk_window_compute_default_size (GtkWindow *window,
&minimum, &natural,
NULL, NULL);
*min_width = minimum;
- if (cur_width > 0)
- *width = MAX (cur_width, minimum);
- else
- *width = MAX (minimum, MIN (max_width, natural));
+ if (cur_width <= 0)
+ cur_width = natural;
+ *width = MAX (minimum, MIN (max_width, cur_width));
gtk_widget_measure (widget, GTK_ORIENTATION_VERTICAL,
*width,
&minimum, &natural,
NULL, NULL);
*min_height = minimum;
- if (cur_height > 0)
- *height = MAX (cur_height, minimum);
- else
- *height = MAX (minimum, MIN (max_height, natural));
+ if (cur_height <= 0)
+ cur_height = natural;
+
+ *height = MAX (minimum, MIN (max_height, cur_height));
}
}
@@ -4262,7 +4259,6 @@ toplevel_compute_size (GdkToplevel *toplevel,
&min_width, &min_height,
&width, &height);
-
if (width < min_width)
width = min_width;
if (height < min_height)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]