[gtk+/wip/csd: 6/9] window: Move allocation of decorations to _gtk_window_set_allocation



commit 82c9468165201de1ea642b94577e9a88422b8263
Author: Rob Bradford <rob linux intel com>
Date:   Fri Apr 13 17:01:33 2012 +0100

    window: Move allocation of decorations to _gtk_window_set_allocation
    
    This function now also updates the allocation passed in to be the allocation
    whilst respecting the decorations - it can then be used as the child
    allocation.
    
    This allows subclasses (such as GtkApplicationWindow) to allocate its children
    relative to any decorations.

 gtk/gtkwindow.c |   58 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 31 insertions(+), 27 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 0ee8d88..647dadd 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5672,9 +5672,36 @@ _gtk_window_set_allocation (GtkWindow     *window,
                             GtkAllocation *allocation)
 {
   GtkWidget *widget = (GtkWidget *)window;
+  GtkWindowPrivate *priv = window->priv;
+  GtkAllocation child_allocation;
+  guint border_width;
 
   gtk_widget_set_allocation (widget, allocation);
 
+  border_width = gtk_container_get_border_width (GTK_CONTAINER (window));
+  if (priv->title_box && gtk_widget_get_visual(priv->title_box))
+    {
+      child_allocation.x = priv->title_border.left + priv->window_border.left;
+      child_allocation.y = priv->title_border.top + priv->window_border.top;
+      child_allocation.width =
+        MAX (1, (gint) allocation->width -
+             priv->title_border.left - priv->title_border.right -
+             priv->window_border.left - priv->window_border.right);
+      child_allocation.height = priv->title_height;
+
+      gtk_widget_size_allocate (priv->title_box, &child_allocation);
+    }
+
+  child_allocation.x = border_width + priv->window_border.left;
+  child_allocation.y =
+    border_width + priv->window_border.top + priv->title_height +
+    priv->title_border.top + priv->title_border.bottom;
+  child_allocation.width =
+    MAX (1, (gint)allocation->width - child_allocation.x * 2);
+  child_allocation.height =
+    MAX (1, (gint)allocation->height -
+         child_allocation.y - border_width - priv->window_border.bottom);
+
   if (gtk_widget_get_realized (widget))
     {
       /* If it's not a toplevel we're embedded, we need to resize
@@ -5692,6 +5719,8 @@ _gtk_window_set_allocation (GtkWindow     *window,
           set_grip_position (window);
         }
     }
+
+  *allocation = child_allocation;
 }
 
 static void
@@ -5700,40 +5729,15 @@ gtk_window_size_allocate (GtkWidget     *widget,
 {
   GtkWindow *window = GTK_WINDOW (widget);
   GtkWindowPrivate *priv = window->priv;
-  GtkAllocation child_allocation;
   GtkWidget *child;
-  guint border_width;
 
+  /* Updates the allocation to the child allocation in place */
   _gtk_window_set_allocation (window, allocation);
 
-  border_width = gtk_container_get_border_width (GTK_CONTAINER (window));
-  if (priv->title_box && gtk_widget_get_visual(priv->title_box))
-    {
-      child_allocation.x = priv->title_border.left + priv->window_border.left;
-      child_allocation.y = priv->title_border.top + priv->window_border.top;
-      child_allocation.width =
-	MAX (1, (gint) allocation->width -
-	     priv->title_border.left - priv->title_border.right -
-	     priv->window_border.left - priv->window_border.right);
-      child_allocation.height = priv->title_height;
-
-      gtk_widget_size_allocate (priv->title_box, &child_allocation);
-    }
-
   child = gtk_bin_get_child (&(window->bin));
   if (child && gtk_widget_get_visible (child))
     {
-      child_allocation.x = border_width + priv->window_border.left;
-      child_allocation.y =
-	border_width + priv->window_border.top + priv->title_height +
-	priv->title_border.top + priv->title_border.bottom;
-      child_allocation.width =
-	MAX (1, (gint)allocation->width - child_allocation.x * 2);
-      child_allocation.height =
-	MAX (1, (gint)allocation->height -
-	     child_allocation.y - border_width - priv->window_border.bottom);
-
-      gtk_widget_size_allocate (child, &child_allocation);
+      gtk_widget_size_allocate (child, allocation);
     }
 }
 



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