[gtk+] gtkwindow: apply CSD adjustments to the default size when used instead of when setting it



commit 308aec53c686eae69adbeaf5ca234a29cfd6eefa
Author: Christoph Reiter <creiter src gnome org>
Date:   Wed Nov 18 19:17:01 2015 +0100

    gtkwindow: apply CSD adjustments to the default size when used instead of when setting it
    
    Before the resulting window size would differ if the default size was set
    before adding a headerbar vs after. Now the saved state is again the actual
    requested size and it is adjusted at the time we request a window size.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756618

 gtk/gtkwindow.c |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index f87acd9..309a1fe 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5232,7 +5232,6 @@ gtk_window_set_default_size (GtkWindow   *window,
   g_return_if_fail (width >= -1);
   g_return_if_fail (height >= -1);
 
-  gtk_window_update_csd_size (window, &width, &height, INCLUDE_CSD_SIZE);
   gtk_window_set_default_size_internal (window, TRUE, width, TRUE, height, FALSE);
 }
 
@@ -5278,20 +5277,16 @@ gtk_window_get_default_size (GtkWindow *window,
                             gint      *height)
 {
   GtkWindowGeometryInfo *info;
-  gint w, h;
 
   g_return_if_fail (GTK_IS_WINDOW (window));
 
   info = gtk_window_get_geometry_info (window, FALSE);
-  w = info ? info->default_width : -1;
-  h = info ? info->default_height : -1;
-  gtk_window_update_csd_size (window, &w, &h, EXCLUDE_CSD_SIZE);
 
   if (width)
-    *width = w;
+    *width = info ? info->default_width : -1;
 
   if (height)
-    *height = h;
+    *height = info ? info->default_height : -1;
 }
 
 /**
@@ -5827,9 +5822,6 @@ gtk_window_get_position (GtkWindow *window,
     }
 }
 
-#undef INCLUDE_CSD_SIZE
-#undef EXCLUDE_CSD_SIZE
-
 /**
  * gtk_window_reshow_with_initial_size:
  * @window: a #GtkWindow
@@ -8996,10 +8988,19 @@ gtk_window_compute_configure_request_size (GtkWindow   *window,
       /* Override with default size */
       if (info)
         {
+          /* Take width of shadows/headerbar into account. We want to set the
+           * default size of the content area and not the window area.
+           */
+          gint default_width_csd = info->default_width;
+          gint default_height_csd = info->default_height;
+          gtk_window_update_csd_size (window,
+                                      &default_width_csd, &default_height_csd,
+                                      INCLUDE_CSD_SIZE);
+
           if (info->default_width > 0)
-            *width = info->default_width;
+            *width = default_width_csd;
           if (info->default_height > 0)
-            *height = info->default_height;
+            *height = default_height_csd;
 
           if (info->default_is_geometry)
             geometry_size_to_pixels (geometry, flags,
@@ -9040,6 +9041,9 @@ 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)
 {


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