[gtk+/wip/csd: 423/429] window: Move allocation of decorations to _gtk_window_set_allocation
- From: Rob Bradford <rbradford src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/csd: 423/429] window: Move allocation of decorations to _gtk_window_set_allocation
- Date: Tue, 22 Jan 2013 18:05:14 +0000 (UTC)
commit 7b8109072b33dc454f5ea9b125b78c0c597050ab
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 0efca6d..476cf89 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -5693,9 +5693,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
@@ -5713,6 +5740,8 @@ _gtk_window_set_allocation (GtkWindow *window,
set_grip_position (window);
}
}
+
+ *allocation = child_allocation;
}
static void
@@ -5721,40 +5750,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]