[gtk+] gtkwindow: default size with fixed size windows



commit cdc580463e409a9b7e5f1480afa68d875ff3ff65
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Fri Mar 4 21:29:25 2016 +0100

    gtkwindow: default size with fixed size windows
    
    Allow fixed size windows with a default size to grow or shrink as the
    content requires, but not smaller than the given default size.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762974

 gtk/gtkwindow.c |   40 ++++++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 563414d..f5cf1ba 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -9001,9 +9001,6 @@ gtk_window_compute_configure_request_size (GtkWindow   *window,
   *height = MAX (*height, 1);
 }
 
-#undef INCLUDE_CSD_SIZE
-#undef EXCLUDE_CSD_SIZE
-
 static GtkWindowPosition
 get_effective_position (GtkWindow *window)
 {
@@ -9774,7 +9771,7 @@ gtk_window_constrain_size (GtkWindow   *window,
  * width/height if set, but can still grow if their content requires.
  *
  * Note: Fixed size windows with a default size set will not shrink
- * when their content requires less size.
+ * smaller than the default size when their content requires less size.
  */
 static void
 gtk_window_update_fixed_size (GtkWindow   *window,
@@ -9783,25 +9780,33 @@ gtk_window_update_fixed_size (GtkWindow   *window,
                               gint         new_height)
 {
   GtkWindowPrivate *priv = window->priv;
-  gint default_width;
-  gint default_height;
+  GtkWindowGeometryInfo *info;
 
   /* Adjust the geometry hints for non-resizable windows only */
   if (priv->resizable)
     return;
 
-  /* if a default size is set, make sure the hints allow for the new size */
-  gtk_window_get_default_size (window, &default_width, &default_height);
-  if (default_width > -1)
+  info = gtk_window_get_geometry_info (window, FALSE);
+  if (info)
     {
-      new_geometry->min_width = MAX (new_width, new_geometry->min_width);
-      new_geometry->max_width = new_geometry->min_width;
-    }
+      gint default_width_csd = info->default_width;
+      gint default_height_csd = info->default_height;
 
-  if (default_height > -1)
-    {
-      new_geometry->min_height = MAX (new_height, new_geometry->min_height);
-      new_geometry->max_height = new_geometry->min_height;
+      gtk_window_update_csd_size (window,
+                                  &default_width_csd, &default_height_csd,
+                                  INCLUDE_CSD_SIZE);
+
+      if (info->default_width > -1)
+        {
+          new_geometry->min_width = MAX (default_width_csd, new_width);
+          new_geometry->max_width = new_geometry->min_width;
+        }
+
+      if (info->default_height > -1)
+        {
+          new_geometry->min_height = MAX (default_height_csd, new_height);
+          new_geometry->max_height = new_geometry->min_height;
+        }
     }
 }
 
@@ -9916,6 +9921,9 @@ gtk_window_compute_hints (GtkWindow   *window,
   new_geometry->win_gravity = priv->gravity;
 }
 
+#undef INCLUDE_CSD_SIZE
+#undef EXCLUDE_CSD_SIZE
+
 /***********************
  * Redrawing functions *
  ***********************/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]