summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2023-01-14 23:46:59 +0100
committerBenjamin Otte <otte@redhat.com>2023-01-14 23:57:13 +0100
commit1f6cc467f9cc733a9432a0699212a72b9e56a27c (patch)
treeb83da5c274f2b8535102055cc348cc388ca98ac3
parent79bce4070bc00b496f17c07ee3ffef1da1778168 (diff)
downloadgtk+-wip/otte/end-of-loupe-shouting-match.tar.gz
window: Don't make initial window size 100% of screen sizewip/otte/end-of-loupe-shouting-match
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.
-rw-r--r--gtk/gtkwindow.c18
1 files 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,