[gtk+/gtk-3-8] GtkWindow: default size is only for initial map
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-8] GtkWindow: default size is only for initial map
- Date: Sat, 11 May 2013 22:46:49 +0000 (UTC)
commit c3852404e66dcb250fff0035bd8ce6ea67b54fb6
Author: Matthias Clasen <mclasen redhat com>
Date: Sat May 11 18:45:27 2013 -0400
GtkWindow: default size is only for initial map
Bring back need_default_size. We need it to preserve this
documented behavior:
The default size of a window only affects the first time a window is
shown; if a window is hidden and re-shown, it will remember the size
it had prior to hiding, rather than using the default size.
With this patch, all of the window sizing tests in
gtk/tests/window pass again.
gtk/gtkwindow.c | 60 +++++++++++++++++++++++++++++++++----------------------
1 files changed, 36 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 605bb97..e7cb987 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -141,6 +141,7 @@ struct _GtkWindowPrivate
* and on unrealize (for size).
*/
guint need_default_position : 1;
+ guint need_default_size : 1;
guint above_initially : 1;
guint accept_focus : 1;
@@ -1144,6 +1145,7 @@ gtk_window_init (GtkWindow *window)
priv->resizable = TRUE;
priv->configure_notify_received = FALSE;
priv->position = GTK_WIN_POS_NONE;
+ priv->need_default_size = TRUE;
priv->need_default_position = TRUE;
priv->modal = FALSE;
priv->gdk_type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
@@ -4929,6 +4931,7 @@ gtk_window_map (GtkWidget *widget)
}
/* No longer use the default settings */
+ priv->need_default_size = FALSE;
priv->need_default_position = FALSE;
if (priv->reset_type_hint)
@@ -5352,6 +5355,7 @@ gtk_window_unrealize (GtkWidget *widget)
*
* Default positioning is reset on unmap, instead of unrealize.
*/
+ priv->need_default_size = TRUE;
info = gtk_window_get_geometry_info (window, FALSE);
if (info)
{
@@ -6551,6 +6555,7 @@ gtk_window_compute_configure_request_size (GtkWindow *window,
gint *width,
gint *height)
{
+ GtkWindowPrivate *priv = window->priv;
GtkWindowGeometryInfo *info;
int w, h;
@@ -6560,32 +6565,39 @@ gtk_window_compute_configure_request_size (GtkWindow *window,
info = gtk_window_get_geometry_info (window, FALSE);
- 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 (*width == 0 && *height == 0)
- {
- *width = 200;
- *height = 200;
- }
-
- /* Override with default size */
-
- if (info)
- {
- if (info->default_width > 0)
- *width = info->default_width;
- if (info->default_height > 0)
- *height = info->default_height;
-
- if (info->default_is_geometry)
- geometry_size_to_pixels (geometry, flags,
+ if (priv->need_default_size)
+ {
+ 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 (*width == 0 && *height == 0)
+ {
+ *width = 200;
+ *height = 200;
+ }
+
+ /* Override with default size */
+ if (info)
+ {
+ if (info->default_width > 0)
+ *width = info->default_width;
+ if (info->default_height > 0)
+ *height = info->default_height;
+
+ if (info->default_is_geometry)
+ geometry_size_to_pixels (geometry, flags,
info->default_width > 0 ? width : NULL,
info->default_height > 0 ? height : NULL);
- }
+ }
+ }
+ else
+ {
+ /* Default to keeping current size */
+ gtk_window_get_remembered_size (window, width, height);
+ }
/* Override any size with gtk_window_resize() values */
if (info)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]