Commit 85aebe74 authored by Benjamin Otte's avatar Benjamin Otte

window: Be smarter about computing the default size

See the code comments for the reasoning behind this. After we don't
force a "guessed" minimum size for labels anymore, a lot of issues
started to surface that this patch attempts to fix. In particular:

1) Tooltips where wrapped as much as possible.
2) The recentchooser submenu displayed only ellipsize dots.
parent 08b2ac1d
......@@ -4833,18 +4833,71 @@ gtk_window_unmap (GtkWidget *widget)
gtk_widget_unmap (child);
/* (Note: Replace "size" with "width" or "height". Also, the request
* mode is honoured.)
* For selecting the default window size, the following conditions
* should hold (in order of importance):
* - the size is not below the minimum size
* Windows cannot be resized below their minimum size, so we must
* ensure we don't do that either.
* - the size is not above the natural size
* It seems weird to allocate more than this in an initial guess.
* - the size does not exceed that of a maximized window
* We want to see the whole window after all.
* (Note that this may not be possible to achieve due to imperfect
* information from the windowing system.)
/* We use these for now to not make windows too big by accident. Note
* that we still clamp these numbers by screen size. Also note that
* minimum size still overrides this. So keep your windows small! :)
static void
gtk_window_guess_default_size (GtkWindow *window,
gint *width,
gint *height)
GtkWidget *widget = GTK_WIDGET (window);
GtkRequisition requisition;
GdkScreen *screen;
int minimum, natural;
screen = gtk_widget_get_screen (widget);
*width = gdk_screen_get_width (screen);
*height = gdk_screen_get_height (screen);
if (*width < *height)
/* landscape */
*width = MIN (*width, MAX_DEFAULT_WINDOW_WIDTH);
*height = MIN (*height, MAX_DEFAULT_WINDOW_HEIGHT);
/* portrait */
*height = MIN (*height, MAX_DEFAULT_WINDOW_WIDTH);
gtk_widget_get_preferred_size (widget, &requisition, NULL);
if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT)
gtk_widget_get_preferred_height (widget, &minimum, &natural);
*height = MAX (minimum, MIN (*height, natural));
*width = requisition.width;
*height = requisition.height;
gtk_widget_get_preferred_width_for_height (widget, *height, &minimum, &natural);
*width = MAX (minimum, MIN (*width, natural));
gtk_widget_get_preferred_width (widget, &minimum, &natural);
*width = MAX (minimum, MIN (*width, natural));
gtk_widget_get_preferred_height_for_width (widget, *width, &minimum, &natural);
*height = MAX (minimum, MIN (*height, natural));
static void
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment