[gtk+] GtkWindow: some min/nat size corrections.



commit 48ea0cbe4b8bcd37958601d39b9e93be7d28fa8b
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Mon Jun 22 19:22:10 2015 +0200

    GtkWindow: some min/nat size corrections.
    
    Don't add the container border to the title request size; it
    is only used for the child widget.
    
    Don't call gtk_widget_get_preferred_width_for_height() for
    the title bar with an unrelated height and subtract the title
    bar height before querying the child widget width.
    
    Guard against negative size requests after substracting the
    borders/shadows and the title bar.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751341

 gtk/gtkwindow.c |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 68f7220..ce24667 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -8387,10 +8387,8 @@ gtk_window_get_preferred_width (GtkWidget *widget,
         gtk_widget_get_preferred_width (priv->title_box,
                                         &title_min, &title_nat);
 
-      title_min += border_width * 2 +
-                   window_border.left + window_border.right;
-      title_nat += border_width * 2 +
-                   window_border.left + window_border.right;
+      title_min += window_border.left + window_border.right;
+      title_nat += window_border.left + window_border.right;
     }
 
   if (child && gtk_widget_get_visible (child))
@@ -8426,6 +8424,7 @@ gtk_window_get_preferred_width_for_height (GtkWidget *widget,
   guint border_width;
   gint title_min = 0, title_nat = 0;
   gint child_min = 0, child_nat = 0;
+  gint title_height = 0;
   GtkBorder window_border = { 0 };
 
   window = GTK_WINDOW (widget);
@@ -8446,20 +8445,23 @@ gtk_window_get_preferred_width_for_height (GtkWidget *widget,
       if (priv->title_box != NULL &&
           gtk_widget_get_visible (priv->title_box) &&
           gtk_widget_get_child_visible (priv->title_box))
-        gtk_widget_get_preferred_width_for_height (priv->title_box,
-                                                   height,
-                                                   &title_min, &title_nat);
+        {
+          gtk_widget_get_preferred_height (priv->title_box,
+                                           NULL, &title_height);
+          gtk_widget_get_preferred_width_for_height (priv->title_box,
+                                                     title_height,
+                                                     &title_min, &title_nat);
+          height -= title_height;
+        }
 
-      title_min += border_width * 2 +
-                   window_border.left + window_border.right;
-      title_nat += border_width * 2 +
-                   window_border.left + window_border.right;
+      title_min += window_border.left + window_border.right;
+      title_nat += window_border.left + window_border.right;
     }
 
   if (child && gtk_widget_get_visible (child))
     {
       gtk_widget_get_preferred_width_for_height (child,
-                                                 height,
+                                                 MAX (height, 0),
                                                  &child_min, &child_nat);
 
       if (child_nat == 0 && height == 0)
@@ -8572,7 +8574,7 @@ gtk_window_get_preferred_height_for_width (GtkWidget *widget,
           gtk_widget_get_visible (priv->title_box) &&
           gtk_widget_get_child_visible (priv->title_box))
         gtk_widget_get_preferred_height_for_width (priv->title_box,
-                                                   width,
+                                                   MAX (width, 0),
                                                    &title_min,
                                                    &title_height);
 
@@ -8586,7 +8588,7 @@ gtk_window_get_preferred_height_for_width (GtkWidget *widget,
   if (child && gtk_widget_get_visible (child))
     {
       gint child_min, child_nat;
-      gtk_widget_get_preferred_height_for_width (child, width,
+      gtk_widget_get_preferred_height_for_width (child, MAX (width, 0),
                                                  &child_min, &child_nat);
 
       if (child_nat == 0 && width == 0)


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