From 1f6cc467f9cc733a9432a0699212a72b9e56a27c Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 14 Jan 2023 23:46:59 +0100 Subject: [PATCH] window: Don't make initial window size 100% of screen size Take 85%, because it's the same magic number eog uses, so that windows don't hug the edge of the screen and look like they're maximized. We only do this for the first dimension because it's better to match aspect ratios than it is to not hug the screen. Note that we do not do that if ::default-size is set because an explicitly set width means somebody knows what they're doing. --- gtk/gtkwindow.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 66177192fd..3dacb0328d 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -4149,6 +4149,12 @@ gtk_window_compute_min_size (GtkWidget *window, *min_height = other; } +/* The maximum size we pick for windows if we have free choice. + * We don't want them to get so big that they hug the screen edges and + * look like they are maximized. + */ +#define MAX_DEFAULT_SIZE (0.85) + static void gtk_window_compute_default_width_for_height (GtkWindow *window, int cur_width, @@ -4169,8 +4175,10 @@ gtk_window_compute_default_width_for_height (GtkWindow *window, NULL, NULL); *min_height = minimum; if (cur_height <= 0) - cur_height = natural; - *height = MAX (minimum, MIN (max_height, cur_height)); + cur_height = MIN (natural, max_height * MAX_DEFAULT_SIZE); + else + cur_height = MIN (max_height, cur_height); + *height = MAX (minimum, cur_height); gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, *height, @@ -4206,8 +4214,10 @@ gtk_window_compute_default_height_for_width (GtkWindow *window, NULL, NULL); *min_width = minimum; if (cur_width <= 0) - cur_width = natural; - *width = MAX (minimum, MIN (max_width, cur_width)); + cur_width = MIN (natural, max_width * MAX_DEFAULT_SIZE); + else + cur_width = MIN (max_width, cur_width); + *width = MAX (minimum, cur_width); gtk_widget_measure (widget, GTK_ORIENTATION_VERTICAL, *width,