From b3d5e39790625c75c794240c1ac153aea6c6d094 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 13 Apr 2012 17:01:33 +0100 Subject: [PATCH] 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 file changed, 31 insertions(+), 27 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 2057048936..603b1b6bf6 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -5647,9 +5647,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 @@ -5667,6 +5694,8 @@ _gtk_window_set_allocation (GtkWindow *window, set_grip_position (window); } } + + *allocation = child_allocation; } static void @@ -5675,40 +5704,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); } }