window: Split out a function

We don't want to remember sizes in the not resizable case. Also a
function named "guess_default_size" should not look at previous sizes,
it should guess.
This commit is contained in:
Benjamin Otte 2013-04-09 12:06:51 +02:00
parent 33f1210f72
commit 70dbb14f89

View File

@ -5558,7 +5558,6 @@ gtk_window_guess_default_size (GtkWindow *window,
gint *width, gint *width,
gint *height) gint *height)
{ {
GtkWindowGeometryInfo *info;
GtkWidget *widget; GtkWidget *widget;
GdkScreen *screen; GdkScreen *screen;
int minimum, natural; int minimum, natural;
@ -5598,11 +5597,21 @@ gtk_window_guess_default_size (GtkWindow *window,
gtk_widget_get_preferred_height_for_width (widget, *width, &minimum, &natural); gtk_widget_get_preferred_height_for_width (widget, *width, &minimum, &natural);
*height = MAX (minimum, MIN (*height, natural)); *height = MAX (minimum, MIN (*height, natural));
} }
}
static void
gtk_window_get_remembered_size (GtkWindow *window,
int *width,
int *height)
{
GtkWindowGeometryInfo *info;
*width = 0;
*height = 0;
info = gtk_window_get_geometry_info (window, FALSE); info = gtk_window_get_geometry_info (window, FALSE);
if (info) if (info)
{ {
g_print ("last geometry info was %d %d\n", info->last.configure_request.width, info->last.configure_request.height);
/* MAX() works even if the last request is unset with -1 */ /* MAX() works even if the last request is unset with -1 */
*width = MAX (*width, info->last.configure_request.width); *width = MAX (*width, info->last.configure_request.width);
*height = MAX (*height, info->last.configure_request.height); *height = MAX (*height, info->last.configure_request.height);
@ -5674,11 +5683,15 @@ gtk_window_realize (GtkWidget *widget)
allocation.width == 1 && allocation.width == 1 &&
allocation.height == 1) allocation.height == 1)
{ {
gint w, h;
allocation.x = 0; allocation.x = 0;
allocation.y = 0; allocation.y = 0;
gtk_window_guess_default_size (window, &allocation.width, &allocation.height); gtk_window_guess_default_size (window, &allocation.width, &allocation.height);
gtk_window_get_remembered_size (window, &w, &h);
allocation.width = MAX (allocation.width, w);
allocation.height = MAX (allocation.height, h);
if (allocation.width == 0 || allocation.height == 0) if (allocation.width == 0 || allocation.height == 0)
{ {
/* non-empty window */ /* non-empty window */
@ -7978,6 +7991,7 @@ gtk_window_compute_configure_request_size (GtkWindow *window,
gint *height) gint *height)
{ {
GtkWindowGeometryInfo *info; GtkWindowGeometryInfo *info;
int w, h;
/* Preconditions: /* Preconditions:
* - we've done a size request * - we've done a size request
@ -7986,6 +8000,9 @@ gtk_window_compute_configure_request_size (GtkWindow *window,
info = gtk_window_get_geometry_info (window, FALSE); info = gtk_window_get_geometry_info (window, FALSE);
gtk_window_guess_default_size (window, width, height); gtk_window_guess_default_size (window, width, height);
gtk_window_get_remembered_size (window, &w, &h);
*width = MAX (*width, w);
*height = MAX (*height, h);
/* If window is empty so requests 0, default to random nonzero size */ /* If window is empty so requests 0, default to random nonzero size */
if (*width == 0 && *height == 0) if (*width == 0 && *height == 0)