From ade171a2ed1f868b13dd1f1cb221e6622b92e052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 16 Aug 2018 06:53:03 +0200 Subject: [PATCH] widget: Don't pass a position to ->size_allocate The values have been 0/0 for a long time now, so just drop the GtkAllocation argument and replace it with width and height. --- demos/gtk-demo/application.c | 11 ++-- demos/gtk-demo/gtkfishbowl.c | 11 ++-- demos/gtk-demo/paint.c | 11 ++-- gtk/a11y/gtkwidgetaccessible.c | 17 +++--- gtk/gtkaccellabel.c | 13 +++-- gtk/gtkactionbar.c | 14 +++-- gtk/gtkappchooserbutton.c | 9 ++-- gtk/gtkappchooserwidget.c | 13 +++-- gtk/gtkapplicationwindow.c | 8 +-- gtk/gtkbbox.c | 83 ++++++++++++++-------------- gtk/gtkbin.c | 13 +++-- gtk/gtkbox.c | 33 ++++++------ gtk/gtkcalendar.c | 20 +++---- gtk/gtkcellview.c | 23 ++++---- gtk/gtkcenterbox.c | 35 ++++++------ gtk/gtkcheckbutton.c | 98 +++++++++++++++++----------------- gtk/gtkcheckmenuitem.c | 14 ++--- gtk/gtkcolorbutton.c | 14 +++-- gtk/gtkcolorplane.c | 7 +-- gtk/gtkcolorswatch.c | 13 +++-- gtk/gtkcombobox.c | 15 ++++-- gtk/gtkentry.c | 38 ++++++------- gtk/gtkexpander.c | 20 ++++--- gtk/gtkfilechooserbutton.c | 13 +++-- gtk/gtkfilechooserdialog.c | 15 +++--- gtk/gtkfilechooserwidget.c | 17 +++--- gtk/gtkfixed.c | 14 ++--- gtk/gtkflowbox.c | 53 ++++-------------- gtk/gtkfontbutton.c | 12 +++-- gtk/gtkfontchooserwidget.c | 16 +++--- gtk/gtkframe.c | 26 ++++----- gtk/gtkgizmo.c | 11 ++-- gtk/gtkgizmoprivate.h | 7 +-- gtk/gtkglarea.c | 9 ++-- gtk/gtkgrid.c | 23 ++++---- gtk/gtkheaderbar.c | 49 ++++++++--------- gtk/gtkiconview.c | 14 ++--- gtk/gtklabel.c | 17 +++--- gtk/gtklayout.c | 14 ++--- gtk/gtklevelbar.c | 56 ++++++++++--------- gtk/gtklistbox.c | 28 +++++----- gtk/gtkmediacontrols.c | 13 +++-- gtk/gtkmenu.c | 27 +++++----- gtk/gtkmenubar.c | 16 +++--- gtk/gtkmenuitem.c | 10 ++-- gtk/gtkmodelbutton.c | 24 +++++---- gtk/gtknotebook.c | 79 +++++++++++++++------------ gtk/gtkoverlay.c | 13 +++-- gtk/gtkpaned.c | 55 +++++++++---------- gtk/gtkpathbar.c | 28 +++++----- gtk/gtkpopover.c | 31 ++++++----- gtk/gtkprogressbar.c | 83 ++++++++++++++-------------- gtk/gtkrange.c | 81 +++++++++++++++------------- gtk/gtkrevealer.c | 26 ++++----- gtk/gtkscale.c | 50 +++++++++-------- gtk/gtkscrollbar.c | 13 +++-- gtk/gtkscrolledwindow.c | 66 +++++++++++------------ gtk/gtksearchbar.c | 13 +++-- gtk/gtkshortcutsshortcut.c | 15 ++++-- gtk/gtkspinbutton.c | 21 +++++--- gtk/gtkstack.c | 36 +++++++------ gtk/gtkstatusbar.c | 13 +++-- gtk/gtkswitch.c | 21 ++++---- gtk/gtktextview.c | 14 ++--- gtk/gtktoolbar.c | 34 ++++-------- gtk/gtktreeview.c | 30 ++++++----- gtk/gtkvideo.c | 13 +++-- gtk/gtkviewport.c | 14 ++--- gtk/gtkwidget.c | 25 +++++---- gtk/gtkwidget.h | 3 +- gtk/gtkwindow.c | 30 +++++------ gtk/gtkwindowprivate.h | 7 +-- gtk/inspector/gtkstackcombo.c | 14 +++-- gtk/inspector/misc-info.c | 5 +- tests/testwidgetfocus.c | 11 ++-- 75 files changed, 1005 insertions(+), 856 deletions(-) diff --git a/demos/gtk-demo/application.c b/demos/gtk-demo/application.c index b865970742..02352c1105 100644 --- a/demos/gtk-demo/application.c +++ b/demos/gtk-demo/application.c @@ -455,13 +455,16 @@ demo_application_window_constructed (GObject *object) } static void -demo_application_window_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +demo_application_window_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { DemoApplicationWindow *window = (DemoApplicationWindow *)widget; - GTK_WIDGET_CLASS (demo_application_window_parent_class)->size_allocate (widget, allocation, + GTK_WIDGET_CLASS (demo_application_window_parent_class)->size_allocate (widget, + width, + height, baseline); if (!window->maximized && !window->fullscreen) diff --git a/demos/gtk-demo/gtkfishbowl.c b/demos/gtk-demo/gtkfishbowl.c index 642db66afe..5cfbcf83fc 100644 --- a/demos/gtk-demo/gtkfishbowl.c +++ b/demos/gtk-demo/gtkfishbowl.c @@ -128,9 +128,10 @@ gtk_fishbowl_measure (GtkWidget *widget, } static void -gtk_fishbowl_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_fishbowl_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkFishbowl *fishbowl = GTK_FISHBOWL (widget); GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl); @@ -147,8 +148,8 @@ gtk_fishbowl_size_allocate (GtkWidget *widget, continue; gtk_widget_get_preferred_size (child->widget, &child_requisition, NULL); - child_allocation.x = allocation->x + round (child->x * (allocation->width - child_requisition.width)); - child_allocation.y = allocation->y + round (child->y * (allocation->height - child_requisition.height)); + child_allocation.x = round (child->x * (width - child_requisition.width)); + child_allocation.y = round (child->y * (height - child_requisition.height)); child_allocation.width = child_requisition.width; child_allocation.height = child_requisition.height; diff --git a/demos/gtk-demo/paint.c b/demos/gtk-demo/paint.c index 170a2f7697..33921f49ba 100644 --- a/demos/gtk-demo/paint.c +++ b/demos/gtk-demo/paint.c @@ -84,15 +84,16 @@ drawing_area_ensure_surface (DrawingArea *area, } static void -drawing_area_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +drawing_area_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { DrawingArea *area = (DrawingArea *) widget; - drawing_area_ensure_surface (area, allocation->width, allocation->height); + drawing_area_ensure_surface (area, width, height); - GTK_WIDGET_CLASS (drawing_area_parent_class)->size_allocate (widget, allocation, baseline); + GTK_WIDGET_CLASS (drawing_area_parent_class)->size_allocate (widget, width, height, baseline); } static void diff --git a/gtk/a11y/gtkwidgetaccessible.c b/gtk/a11y/gtkwidgetaccessible.c index 437c1212b1..69a205f508 100644 --- a/gtk/a11y/gtkwidgetaccessible.c +++ b/gtk/a11y/gtkwidgetaccessible.c @@ -59,8 +59,9 @@ notify_cb (GObject *obj, /* Translate GtkWidget::size-allocate to AtkComponent::bounds-changed */ static void -size_allocate_cb (GtkWidget *widget, - GtkAllocation *allocation) +size_allocate_cb (GtkWidget *widget, + int width, + int height) { AtkObject* accessible; AtkRectangle rect; @@ -68,10 +69,14 @@ size_allocate_cb (GtkWidget *widget, accessible = gtk_widget_get_accessible (widget); if (ATK_IS_COMPONENT (accessible)) { - rect.x = allocation->x; - rect.y = allocation->y; - rect.width = allocation->width; - rect.height = allocation->height; + GtkAllocation alloc; + gtk_widget_get_allocation (widget, &alloc); + + rect.x = alloc.x; + rect.y = alloc.y; + rect.width = alloc.width; + rect.height = alloc.height; + g_signal_emit_by_name (accessible, "bounds-changed", &rect); } } diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c index 1781cb6e11..e8a0ba6121 100644 --- a/gtk/gtkaccellabel.c +++ b/gtk/gtkaccellabel.c @@ -160,14 +160,19 @@ static void gtk_accel_label_measure (GtkWidget *widget, G_DEFINE_TYPE_WITH_PRIVATE (GtkAccelLabel, gtk_accel_label, GTK_TYPE_WIDGET) static void -gtk_accel_label_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_accel_label_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkAccelLabel *al = GTK_ACCEL_LABEL (widget); GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (al); - gtk_widget_size_allocate (priv->box, allocation, baseline); + gtk_widget_size_allocate (priv->box, + &(GtkAllocation) { + 0, 0, + width, height + },baseline); } static void diff --git a/gtk/gtkactionbar.c b/gtk/gtkactionbar.c index f9f0a73b69..edf1b49ada 100644 --- a/gtk/gtkactionbar.c +++ b/gtk/gtkactionbar.c @@ -259,13 +259,19 @@ gtk_action_bar_set_child_property (GtkContainer *container, } static void -gtk_action_bar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_action_bar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (widget)); - gtk_widget_size_allocate (priv->revealer, allocation, baseline); + gtk_widget_size_allocate (priv->revealer, + &(GtkAllocation) { + 0, 0, + width, height + }, + baseline); } static void diff --git a/gtk/gtkappchooserbutton.c b/gtk/gtkappchooserbutton.c index 0e60e2bea0..f8721a0720 100644 --- a/gtk/gtkappchooserbutton.c +++ b/gtk/gtkappchooserbutton.c @@ -624,14 +624,15 @@ gtk_app_chooser_button_measure (GtkWidget *widget, } static void -gtk_app_chooser_button_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_app_chooser_button_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkAppChooserButton *button = GTK_APP_CHOOSER_BUTTON (widget); GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (button); - gtk_widget_size_allocate (priv->combobox, allocation, baseline); + gtk_widget_size_allocate (priv->combobox, &(GtkAllocation){0, 0, width, height}, baseline); } static void diff --git a/gtk/gtkappchooserwidget.c b/gtk/gtkappchooserwidget.c index bf5acc36f9..62f3566a38 100644 --- a/gtk/gtkappchooserwidget.c +++ b/gtk/gtkappchooserwidget.c @@ -934,16 +934,21 @@ gtk_app_chooser_widget_snapshot (GtkWidget *widget, } static void -gtk_app_chooser_widget_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, +gtk_app_chooser_widget_size_allocate (GtkWidget *widget, + int width, + int height, int baseline) { GtkAppChooserWidget *self = GTK_APP_CHOOSER_WIDGET (widget); GtkAppChooserWidgetPrivate *priv = gtk_app_chooser_widget_get_instance_private (self); - GTK_WIDGET_CLASS (gtk_app_chooser_widget_parent_class)->size_allocate (widget, allocation, baseline); + GTK_WIDGET_CLASS (gtk_app_chooser_widget_parent_class)->size_allocate (widget, width, height, baseline); - gtk_widget_size_allocate (priv->overlay, allocation, baseline); + gtk_widget_size_allocate (priv->overlay, + &(GtkAllocation) { + 0, 0, + width, height + },baseline); } static void diff --git a/gtk/gtkapplicationwindow.c b/gtk/gtkapplicationwindow.c index 01e2efcb98..9651aedc05 100644 --- a/gtk/gtkapplicationwindow.c +++ b/gtk/gtkapplicationwindow.c @@ -592,7 +592,8 @@ gtk_application_window_measure (GtkWidget *widget, static void gtk_application_window_real_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, + int width, + int height, int baseline) { GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget); @@ -604,7 +605,7 @@ gtk_application_window_real_size_allocate (GtkWidget *widget, gint menubar_height; GtkWidget *child; - _gtk_window_set_allocation (GTK_WINDOW (widget), allocation, &child_allocation); + _gtk_window_set_allocation (GTK_WINDOW (widget), width, height, &child_allocation); menubar_allocation = child_allocation; gtk_widget_measure (window->priv->menubar, GTK_ORIENTATION_VERTICAL, @@ -622,7 +623,8 @@ gtk_application_window_real_size_allocate (GtkWidget *widget, } else GTK_WIDGET_CLASS (gtk_application_window_parent_class)->size_allocate (widget, - allocation, + width, + height, baseline); } diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c index 46db70e9b6..4ea91a69e9 100644 --- a/gtk/gtkbbox.c +++ b/gtk/gtkbbox.c @@ -97,9 +97,10 @@ static void gtk_button_box_measure (GtkWidget *widget, int *natural, int *minimum_baseline, int *natural_baseline); -static void gtk_button_box_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_button_box_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_button_box_remove (GtkContainer *container, GtkWidget *widget); static void gtk_button_box_set_child_property (GtkContainer *container, @@ -742,9 +743,10 @@ gtk_button_box_measure (GtkWidget *widget, } static void -gtk_button_box_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_button_box_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkButtonBox *bbox = GTK_BUTTON_BOX (widget); GtkButtonBoxPrivate *priv = bbox->priv; @@ -757,8 +759,6 @@ gtk_button_box_size_allocate (GtkWidget *widget, gint y = 0; gint secondary_x = 0; gint secondary_y = 0; - gint width = 0; - gint height = 0; gint childspacing = 0; gint spacing; GtkOrientation orientation; @@ -776,7 +776,7 @@ gtk_button_box_size_allocate (GtkWidget *widget, if (priv->layout_style == GTK_BUTTONBOX_EXPAND) { GTK_WIDGET_CLASS (gtk_button_box_parent_class)->size_allocate (widget, - allocation, + width, height, baseline); return; } @@ -799,10 +799,10 @@ gtk_button_box_size_allocate (GtkWidget *widget, /* keep baseline as is */ break; case GTK_BASELINE_POSITION_CENTER: - baseline = baseline + (allocation->height - baseline_height) / 2; + baseline = baseline + (height - baseline_height) / 2; break; case GTK_BASELINE_POSITION_BOTTOM: - baseline = allocation->height - (baseline_height - baseline); + baseline = height - (baseline_height - baseline); break; } } @@ -836,9 +836,9 @@ gtk_button_box_size_allocate (GtkWidget *widget, total_size = primary_size + secondary_size; if (orientation == GTK_ORIENTATION_HORIZONTAL) - width = allocation->width; + width = width; else - height = allocation->height; + height = height; switch (priv->layout_style) { @@ -847,13 +847,13 @@ gtk_button_box_size_allocate (GtkWidget *widget, if (orientation == GTK_ORIENTATION_HORIZONTAL) { childspacing = (width - total_size) / (nvis_children + 1); - x = allocation->x + childspacing; + x = childspacing; secondary_x = x + primary_size + n_primaries * childspacing; } else { childspacing = (height - total_size) / (nvis_children + 1); - y = allocation->y + childspacing; + y = childspacing; secondary_y = y + primary_size + n_primaries * childspacing; } @@ -866,21 +866,20 @@ gtk_button_box_size_allocate (GtkWidget *widget, if (nvis_children >= 2) { childspacing = (width - total_size) / (nvis_children - 1); - x = allocation->x; + x = 0; secondary_x = x + primary_size + n_primaries * childspacing; } else if (nvis_children == 1) { /* one child, just center */ childspacing = width; - x = secondary_x = allocation->x - + (allocation->width - widths[0]) / 2; + x = secondary_x = (width - widths[0]) / 2; } else { /* zero children, meh */ childspacing = width; - x = secondary_x = allocation->x + allocation->width / 2; + x = secondary_x = width / 2; } } else @@ -888,21 +887,21 @@ gtk_button_box_size_allocate (GtkWidget *widget, if (nvis_children >= 2) { childspacing = (height - total_size) / (nvis_children - 1); - y = allocation->y; + y = 0; secondary_y = y + primary_size + n_primaries * childspacing; } else if (nvis_children == 1) { /* one child, just center */ childspacing = height; - y = secondary_y = allocation->y - + (allocation->height - heights[0]) / 2; + y = secondary_y = 0 + + (height - heights[0]) / 2; } else { /* zero children, meh */ childspacing = height; - y = secondary_y = allocation->y + allocation->height / 2; + y = secondary_y = 0 + height / 2; } } @@ -913,15 +912,15 @@ gtk_button_box_size_allocate (GtkWidget *widget, if (orientation == GTK_ORIENTATION_HORIZONTAL) { childspacing = spacing; - x = allocation->x; - secondary_x = allocation->x + allocation->width + x = 0; + secondary_x = 0 + width - secondary_size - spacing * (n_secondaries - 1); } else { childspacing = spacing; - y = allocation->y; - secondary_y = allocation->y + allocation->height + y = 0; + secondary_y = 0 + height - secondary_size - spacing * (n_secondaries - 1); } @@ -932,16 +931,16 @@ gtk_button_box_size_allocate (GtkWidget *widget, if (orientation == GTK_ORIENTATION_HORIZONTAL) { childspacing = spacing; - x = allocation->x + allocation->width + x = 0 + width - primary_size - spacing * (n_primaries - 1); - secondary_x = allocation->x; + secondary_x = 0; } else { childspacing = spacing; - y = allocation->y + allocation->height + y = 0 + height - primary_size - spacing * (n_primaries - 1); - secondary_y = allocation->y; + secondary_y = 0; } break; @@ -951,20 +950,20 @@ gtk_button_box_size_allocate (GtkWidget *widget, if (orientation == GTK_ORIENTATION_HORIZONTAL) { childspacing = spacing; - x = allocation->x + - (allocation->width + x = 0 + + (width - (primary_size + spacing * (n_primaries - 1))) / 2 + (secondary_size + n_secondaries * spacing) / 2; - secondary_x = allocation->x; + secondary_x = 0; } else { childspacing = spacing; - y = allocation->y + - (allocation->height + y = 0 + + (height - (primary_size + spacing * (n_primaries - 1))) / 2 + (secondary_size + n_secondaries * spacing) / 2; - secondary_y = allocation->y; + secondary_y = 0; } break; @@ -994,11 +993,11 @@ gtk_button_box_size_allocate (GtkWidget *widget, { if (baselines[i] != -1) { - child_allocation.y = allocation->y + baseline - baselines[i]; + child_allocation.y = 0 + baseline - baselines[i]; child_baseline = baselines[i]; } else - child_allocation.y = allocation->y + (allocation->height - child_allocation.height) / 2; + child_allocation.y = 0 + (height - child_allocation.height) / 2; if (gtk_button_box_get_child_secondary (bbox, child)) { @@ -1012,12 +1011,12 @@ gtk_button_box_size_allocate (GtkWidget *widget, } if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - child_allocation.x = (allocation->x + allocation->width) - - (child_allocation.x + child_allocation.width - allocation->x); + child_allocation.x = (0 + width) + - (child_allocation.x + child_allocation.width - 0); } else { - child_allocation.x = allocation->x + (allocation->width - child_allocation.width) / 2; + child_allocation.x = 0 + (width - child_allocation.width) / 2; if (gtk_button_box_get_child_secondary (bbox, child)) { diff --git a/gtk/gtkbin.c b/gtk/gtkbin.c index 65433dce88..10b010f2d7 100644 --- a/gtk/gtkbin.c +++ b/gtk/gtkbin.c @@ -64,15 +64,20 @@ static void gtk_bin_measure (GtkWidget G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkBin, gtk_bin, GTK_TYPE_CONTAINER) static void -gtk_bin_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_bin_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkBin *bin = GTK_BIN (widget); GtkBinPrivate *priv = gtk_bin_get_instance_private (bin); if (priv->child && gtk_widget_get_visible (priv->child)) - gtk_widget_size_allocate (priv->child, allocation, baseline); + gtk_widget_size_allocate (priv->child, + &(GtkAllocation) { + 0, 0, + width, height + }, baseline); } static void diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c index c4d489a770..21f0d226ce 100644 --- a/gtk/gtkbox.c +++ b/gtk/gtkbox.c @@ -137,9 +137,10 @@ struct _GtkBoxChild guint pack : 1; }; -static void gtk_box_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_box_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_box_set_property (GObject *object, guint prop_id, @@ -360,9 +361,10 @@ get_spacing (GtkBox *box) } static void -gtk_box_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_box_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkBox *box = GTK_BOX (widget); GtkBoxPrivate *priv = gtk_box_get_instance_private (box); @@ -401,9 +403,9 @@ gtk_box_size_allocate (GtkWidget *widget, spacing = get_spacing (box); if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) - extra_space = allocation->width - (nvis_children - 1) * spacing; + extra_space = width - (nvis_children - 1) * spacing; else - extra_space = allocation->height - (nvis_children - 1) * spacing; + extra_space = height - (nvis_children - 1) * spacing; have_baseline = FALSE; minimum_above = natural_above = 0; @@ -419,8 +421,7 @@ gtk_box_size_allocate (GtkWidget *widget, gtk_widget_measure (child->widget, priv->orientation, - priv->orientation == GTK_ORIENTATION_HORIZONTAL ? - allocation->height : allocation->width, + priv->orientation == GTK_ORIENTATION_HORIZONTAL ? height : width, &sizes[i].minimum_size, &sizes[i].natural_size, NULL, NULL); @@ -548,8 +549,6 @@ gtk_box_size_allocate (GtkWidget *widget, * and any of the child widgets explicitly request one */ if (baseline == -1 && have_baseline) { - gint height = allocation->height; - /* TODO: This is purely based on the minimum baseline, when things fit we should use the natural one? */ @@ -575,20 +574,20 @@ gtk_box_size_allocate (GtkWidget *widget, if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { child_allocation.y = 0; - child_allocation.height = allocation->height; + child_allocation.height = height; if (packing == GTK_PACK_START) x = 0; else - x = allocation->width; + x = width; } else { child_allocation.x = 0; - child_allocation.width = allocation->width; + child_allocation.width = width; if (packing == GTK_PACK_START) y = 0; else - y = allocation->height; + y = height; } for (i = 0, children = priv->children; @@ -630,7 +629,7 @@ gtk_box_size_allocate (GtkWidget *widget, } if (direction == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; + child_allocation.x = width - child_allocation.x - child_allocation.width; } else /* (priv->orientation == GTK_ORIENTATION_VERTICAL) */ diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index 2f1b1bc5c7..8b9de85d2a 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -265,9 +265,10 @@ static void gtk_calendar_measure (GtkWidget *widget, int *natural, int *minimum_baseline, int *natural_baseline); -static void gtk_calendar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_calendar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_calendar_snapshot (GtkWidget *widget, GtkSnapshot *snapshot); static void gtk_calendar_button_press (GtkGestureMultiPress *gesture, @@ -1844,9 +1845,10 @@ gtk_calendar_measure (GtkWidget *widget, } static void -gtk_calendar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_calendar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkCalendar *calendar = GTK_CALENDAR (widget); GtkCalendarPrivate *priv = calendar->priv; @@ -1856,16 +1858,16 @@ gtk_calendar_size_allocate (GtkWidget *widget, if (priv->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS) { priv->day_width = (priv->min_day_width - * ((allocation->width - (inner_border * 2) + * ((width - (inner_border * 2) - (CALENDAR_MARGIN * 2) - (DAY_XSEP * 6) - calendar_xsep * 2)) / (7 * priv->min_day_width + priv->max_week_char_width * 2)); - priv->week_width = ((allocation->width - (inner_border * 2) + priv->week_width = ((width - (inner_border * 2) - (CALENDAR_MARGIN * 2) - (DAY_XSEP * 6) - calendar_xsep * 2 ) - priv->day_width * 7 + CALENDAR_MARGIN + calendar_xsep); } else { - priv->day_width = (allocation->width + priv->day_width = (width - (inner_border * 2) - (CALENDAR_MARGIN * 2) - (DAY_XSEP * 6))/7; diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c index 6310cf78a9..00dacbc8b9 100644 --- a/gtk/gtkcellview.c +++ b/gtk/gtkcellview.c @@ -65,9 +65,10 @@ static void gtk_cell_view_set_property (GObject *obj GParamSpec *pspec); static void gtk_cell_view_finalize (GObject *object); static void gtk_cell_view_dispose (GObject *object); -static void gtk_cell_view_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_cell_view_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_cell_view_snapshot (GtkWidget *widget, GtkSnapshot *snapshot); static void gtk_cell_view_set_value (GtkCellView *cell_view, @@ -470,20 +471,18 @@ gtk_cell_view_dispose (GObject *object) } static void -gtk_cell_view_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_cell_view_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkCellView *cellview; GtkCellViewPrivate *priv; - gint alloc_width, alloc_height, width, height; + gint alloc_width, alloc_height; cellview = GTK_CELL_VIEW (widget); priv = cellview->priv; - width = allocation->width; - height = allocation->height; - gtk_cell_area_context_get_allocation (priv->context, &alloc_width, &alloc_height); /* The first cell view in context is responsible for allocating the context at @@ -495,9 +494,9 @@ gtk_cell_view_size_allocate (GtkWidget *widget, */ if (priv->fit_model) gtk_cell_area_context_allocate (priv->context, width, height); - else if (alloc_width != allocation->width && priv->orientation == GTK_ORIENTATION_HORIZONTAL) + else if (alloc_width != width && priv->orientation == GTK_ORIENTATION_HORIZONTAL) gtk_cell_area_context_allocate (priv->context, width, -1); - else if (alloc_height != allocation->height && priv->orientation == GTK_ORIENTATION_VERTICAL) + else if (alloc_height != height && priv->orientation == GTK_ORIENTATION_VERTICAL) gtk_cell_area_context_allocate (priv->context, -1, height); } diff --git a/gtk/gtkcenterbox.c b/gtk/gtkcenterbox.c index b57f766684..c99d71e262 100644 --- a/gtk/gtkcenterbox.c +++ b/gtk/gtkcenterbox.c @@ -386,9 +386,10 @@ gtk_center_box_measure (GtkWidget *widget, } static void -gtk_center_box_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_center_box_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkCenterBox *self = GTK_CENTER_BOX (widget); GtkAllocation child_allocation; @@ -402,13 +403,13 @@ gtk_center_box_size_allocate (GtkWidget *widget, if (self->orientation == GTK_ORIENTATION_HORIZONTAL) { - size = allocation->width; - for_size = allocation->height; + size = width; + for_size = height; } else { - size = allocation->height; - for_size = allocation->width; + size = height; + for_size = width; baseline = -1; } @@ -485,10 +486,10 @@ gtk_center_box_size_allocate (GtkWidget *widget, baseline = min_above; break; case GTK_BASELINE_POSITION_CENTER: - baseline = min_above + (allocation->height - (min_above + min_below)) / 2; + baseline = min_above + (height - (min_above + min_below)) / 2; break; case GTK_BASELINE_POSITION_BOTTOM: - baseline = allocation->height - min_below; + baseline = height - min_below; break; } } @@ -509,7 +510,7 @@ gtk_center_box_size_allocate (GtkWidget *widget, child_pos[1] = size - child_size[1] - child_size[2]; } - child_allocation = *allocation; + child_allocation = (GtkAllocation) { 0, 0, width, height }; for (i = 0; i < 3; i++) { @@ -518,20 +519,20 @@ gtk_center_box_size_allocate (GtkWidget *widget, if (self->orientation == GTK_ORIENTATION_HORIZONTAL) { - child_allocation.x = allocation->x + child_pos[i]; - child_allocation.y = allocation->y; + child_allocation.x = child_pos[i]; + child_allocation.y = 0; child_allocation.width = child_size[i]; - child_allocation.height = allocation->height; + child_allocation.height = height; } else { - child_allocation.x = allocation->x; - child_allocation.y = allocation->y + child_pos[i]; - child_allocation.width = allocation->width; + child_allocation.x = 0; + child_allocation.y = child_pos[i]; + child_allocation.width = width; child_allocation.height = child_size[i]; } - gtk_widget_size_allocate (child[i], &child_allocation, allocation->y + baseline); + gtk_widget_size_allocate (child[i], &child_allocation, baseline); } } diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index c91a4c8bd0..09cecb126b 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -75,11 +75,6 @@ * in this case. */ - -static void gtk_check_button_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); - typedef struct { GtkWidget *indicator_widget; @@ -213,6 +208,54 @@ gtk_check_button_measure (GtkWidget *widget, } } +static void +gtk_check_button_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) +{ + GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget)); + GtkAllocation child_alloc = { 0 }; + GtkWidget *child; + gboolean is_rtl = _gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; + int x = 0; + + if (priv->draw_indicator) + { + child_alloc.y = 0; + child_alloc.height = height; + + gtk_widget_measure (priv->indicator_widget, GTK_ORIENTATION_HORIZONTAL, -1, + &child_alloc.width, NULL, NULL, NULL); + + if (is_rtl) + { + x = 0; + child_alloc.x = width - child_alloc.width; + } + else + { + x = child_alloc.width; + child_alloc.x = 0; + } + + gtk_widget_size_allocate (priv->indicator_widget, &child_alloc, baseline); + } + + child = gtk_bin_get_child (GTK_BIN (widget)); + if (child) + { + child_alloc.x = x; + child_alloc.y = 0; + child_alloc.width = width - child_alloc.width; /* Indicator width */ + child_alloc.height = height; + + gtk_widget_size_allocate (child, &child_alloc, baseline); + } +} + + + static void gtk_check_button_set_property (GObject *object, guint prop_id, @@ -421,51 +464,6 @@ gtk_check_button_new_with_mnemonic (const gchar *label) NULL); } -static void -gtk_check_button_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) -{ - GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (GTK_CHECK_BUTTON (widget)); - GtkAllocation child_alloc = { 0 }; - GtkWidget *child; - gboolean is_rtl = _gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; - int x = 0; - - if (priv->draw_indicator) - { - child_alloc.y = allocation->y; - child_alloc.height = allocation->height; - - gtk_widget_measure (priv->indicator_widget, GTK_ORIENTATION_HORIZONTAL, -1, - &child_alloc.width, NULL, NULL, NULL); - - if (is_rtl) - { - x = 0; - child_alloc.x = allocation->x + allocation->width - child_alloc.width; - } - else - { - x = child_alloc.width; - child_alloc.x = allocation->x; - } - - gtk_widget_size_allocate (priv->indicator_widget, &child_alloc, baseline); - } - - child = gtk_bin_get_child (GTK_BIN (widget)); - if (child) - { - child_alloc.x = allocation->x + x; - child_alloc.y = allocation->y; - child_alloc.width = allocation->width - child_alloc.width; /* Indicator width */ - child_alloc.height = allocation->height; - - gtk_widget_size_allocate (child, &child_alloc, baseline); - } -} - GtkCssNode * gtk_check_button_get_indicator_node (GtkCheckButton *check_button) { diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c index 3d9c8954d3..8e75d6e884 100644 --- a/gtk/gtkcheckmenuitem.c +++ b/gtk/gtkcheckmenuitem.c @@ -104,9 +104,10 @@ G_DEFINE_TYPE_WITH_CODE (GtkCheckMenuItem, gtk_check_menu_item, GTK_TYPE_MENU_IT G_ADD_PRIVATE (GtkCheckMenuItem)) static void -gtk_check_menu_item_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_check_menu_item_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkAllocation indicator_alloc; GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (widget); @@ -114,7 +115,8 @@ gtk_check_menu_item_size_allocate (GtkWidget *widget, gint toggle_size; GTK_WIDGET_CLASS (gtk_check_menu_item_parent_class)->size_allocate (widget, - allocation, + width, + height, baseline); gtk_widget_measure (priv->indicator_widget, @@ -132,10 +134,10 @@ gtk_check_menu_item_size_allocate (GtkWidget *widget, if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) indicator_alloc.x = (toggle_size - indicator_alloc.width) / 2; else - indicator_alloc.x = allocation->width - toggle_size + + indicator_alloc.x = width - toggle_size + (toggle_size - indicator_alloc.width) / 2; - indicator_alloc.y = (allocation->height - indicator_alloc.height) / 2; + indicator_alloc.y = (height - indicator_alloc.height) / 2; gtk_widget_size_allocate (priv->indicator_widget, &indicator_alloc, diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c index 9091b65c65..7b764d9957 100644 --- a/gtk/gtkcolorbutton.c +++ b/gtk/gtkcolorbutton.c @@ -163,14 +163,20 @@ gtk_color_button_snapshot (GtkWidget *widget, } static void -gtk_color_button_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_color_button_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkColorButton *button = GTK_COLOR_BUTTON (widget); GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button); - gtk_widget_size_allocate (priv->button, allocation, baseline); + gtk_widget_size_allocate (priv->button, + &(GtkAllocation) { + 0, 0, + width, height + }, + baseline); } static void diff --git a/gtk/gtkcolorplane.c b/gtk/gtkcolorplane.c index e9adcc31f2..1eedf04f66 100644 --- a/gtk/gtkcolorplane.c +++ b/gtk/gtkcolorplane.c @@ -169,9 +169,10 @@ create_texture (GtkColorPlane *plane) } static void -plane_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +plane_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkColorPlane *plane = GTK_COLOR_PLANE (widget); diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c index 2318f46948..b1678fefe6 100644 --- a/gtk/gtkcolorswatch.c +++ b/gtk/gtkcolorswatch.c @@ -357,14 +357,19 @@ tap_action (GtkGestureMultiPress *gesture, } static void -swatch_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +swatch_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget); GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch); - gtk_widget_size_allocate (priv->overlay_widget, allocation, -1); + gtk_widget_size_allocate (priv->overlay_widget, + &(GtkAllocation) { + 0, 0, + width, height + }, -1); } static void diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index 0799aff93e..153cdd4c5b 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -361,14 +361,19 @@ gtk_combo_box_measure (GtkWidget *widget, } static void -gtk_combo_box_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_combo_box_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkComboBox *combo_box = GTK_COMBO_BOX (widget); GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box); - gtk_widget_size_allocate (priv->box, allocation, baseline); + gtk_widget_size_allocate (priv->box, + &(GtkAllocation) { + 0, 0, + width, height + }, baseline); if (gtk_widget_get_visible (priv->popup_widget)) { @@ -386,7 +391,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget, NULL, &menu_width, NULL, NULL); gtk_widget_set_size_request (priv->popup_widget, - MAX (allocation->width, menu_width), -1); + MAX (width, menu_width), -1); } /* reposition the menu after giving it a new width */ diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index cd4ef3ca11..f5c3bb0df9 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -410,9 +410,10 @@ static void gtk_entry_destroy (GtkWidget *widget); static void gtk_entry_realize (GtkWidget *widget); static void gtk_entry_unrealize (GtkWidget *widget); static void gtk_entry_unmap (GtkWidget *widget); -static void gtk_entry_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_entry_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_entry_snapshot (GtkWidget *widget, GtkSnapshot *snapshot); static void gtk_entry_focus_in (GtkWidget *widget); @@ -3088,7 +3089,7 @@ gtk_entry_unmap (GtkWidget *widget) GTK_WIDGET_CLASS (gtk_entry_parent_class)->unmap (widget); } -static void +static void gtk_entry_get_text_allocation (GtkEntry *entry, GdkRectangle *allocation) { @@ -3253,9 +3254,10 @@ gtk_entry_measure (GtkWidget *widget, } static void -gtk_entry_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_entry_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkEntry *entry = GTK_ENTRY (widget); GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry); @@ -3263,13 +3265,13 @@ gtk_entry_size_allocate (GtkWidget *widget, priv->text_baseline = baseline; priv->text_x = 0; - priv->text_width = allocation->width; + priv->text_width = width; for (i = 0; i < MAX_ICONS; i++) { EntryIconInfo *icon_info = priv->icons[i]; GtkAllocation icon_alloc; - int width; + int icon_width; if (!icon_info) continue; @@ -3277,23 +3279,23 @@ gtk_entry_size_allocate (GtkWidget *widget, gtk_widget_measure (icon_info->widget, GTK_ORIENTATION_HORIZONTAL, -1, - NULL, &width, + NULL, &icon_width, NULL, NULL); if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL && i == GTK_ENTRY_ICON_PRIMARY) || (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR && i == GTK_ENTRY_ICON_SECONDARY)) { - icon_alloc.x = allocation->x + priv->text_x + priv->text_width - width; + icon_alloc.x = priv->text_x + priv->text_width - icon_width; } else { - icon_alloc.x = allocation->x + priv->text_x; - priv->text_x += width; + icon_alloc.x = priv->text_x; + priv->text_x += icon_width; } icon_alloc.y = 0; - icon_alloc.width = width; - icon_alloc.height = allocation->height; - priv->text_width -= width; + icon_alloc.width = icon_width; + icon_alloc.height = height; + priv->text_width -= icon_width; gtk_widget_size_allocate (icon_info->widget, &icon_alloc, baseline); } @@ -3309,8 +3311,8 @@ gtk_entry_size_allocate (GtkWidget *widget, &min, &nat, NULL, NULL); progress_alloc.x = 0; - progress_alloc.y = allocation->height - nat; - progress_alloc.width = allocation->width; + progress_alloc.y = height - nat; + progress_alloc.width = width; progress_alloc.height = nat; gtk_widget_size_allocate (priv->progress_widget, &progress_alloc, -1); diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c index 31bd9b7ce1..fa412f8cf1 100644 --- a/gtk/gtkexpander.c +++ b/gtk/gtkexpander.c @@ -173,9 +173,10 @@ static void gtk_expander_get_property (GObject *object, GParamSpec *pspec); static void gtk_expander_destroy (GtkWidget *widget); -static void gtk_expander_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_expander_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static gboolean gtk_expander_focus (GtkWidget *widget, GtkDirectionType direction); static gboolean gtk_expander_drag_motion (GtkWidget *widget, @@ -493,13 +494,18 @@ gtk_expander_destroy (GtkWidget *widget) } static void -gtk_expander_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_expander_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkExpanderPrivate *priv = gtk_expander_get_instance_private (GTK_EXPANDER (widget)); - gtk_widget_size_allocate (priv->box, allocation, baseline); + gtk_widget_size_allocate (priv->box, + &(GtkAllocation) { + 0, 0, + width, height + }, baseline); } static void diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c index 1d00bd2054..0a0f0a6540 100644 --- a/gtk/gtkfilechooserbutton.c +++ b/gtk/gtkfilechooserbutton.c @@ -360,14 +360,19 @@ gtk_file_chooser_button_measure (GtkWidget *widget, } static void -gtk_file_chooser_button_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_file_chooser_button_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (widget); GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button); - gtk_widget_size_allocate (priv->child, allocation, baseline); + gtk_widget_size_allocate (priv->child, + &(GtkAllocation) { + 0, 0, + width, height + }, baseline); } static void diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c index 9858414228..5c9daeb66a 100644 --- a/gtk/gtkfilechooserdialog.c +++ b/gtk/gtkfilechooserdialog.c @@ -230,8 +230,9 @@ static void gtk_file_chooser_dialog_notify (GObject *obj static void gtk_file_chooser_dialog_map (GtkWidget *widget); static void gtk_file_chooser_dialog_unmap (GtkWidget *widget); -static void gtk_file_chooser_dialog_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, +static void gtk_file_chooser_dialog_size_allocate (GtkWidget *widget, + int width, + int height, int baseline); static void file_chooser_widget_file_activated (GtkFileChooser *chooser, GtkFileChooserDialog *dialog); @@ -617,12 +618,14 @@ gtk_file_chooser_dialog_unmap (GtkWidget *widget) } static void -gtk_file_chooser_dialog_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_file_chooser_dialog_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->size_allocate (widget, - allocation, + width, + height, baseline); if (gtk_widget_is_drawable (widget)) save_dialog_geometry (GTK_FILE_CHOOSER_DIALOG (widget)); diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 21d3df7a09..ca23ce38da 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -7963,18 +7963,19 @@ gtk_file_chooser_widget_measure (GtkWidget *widget, } static void -gtk_file_chooser_widget_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_file_chooser_widget_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkFileChooserWidget *self = GTK_FILE_CHOOSER_WIDGET (widget); GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (self); - GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->size_allocate (widget, - allocation, - baseline); - - gtk_widget_size_allocate (priv->box, allocation, -1); + gtk_widget_size_allocate (priv->box, + &(GtkAllocation) { + 0, 0, + width, height + },-1); } static void diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c index e490041445..aaac22cc49 100644 --- a/gtk/gtkfixed.c +++ b/gtk/gtkfixed.c @@ -103,9 +103,10 @@ static void gtk_fixed_measure (GtkWidget *widget, int *natural_baseline); -static void gtk_fixed_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_fixed_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_fixed_add (GtkContainer *container, GtkWidget *widget); static void gtk_fixed_remove (GtkContainer *container, @@ -371,9 +372,10 @@ gtk_fixed_measure (GtkWidget *widget, } static void -gtk_fixed_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_fixed_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkWidget *child; GtkFixedChild *child_info; diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c index f9391ec8f8..bfc21b5c4b 100644 --- a/gtk/gtkflowbox.c +++ b/gtk/gtkflowbox.c @@ -413,40 +413,6 @@ gtk_flow_box_child_get_request_mode (GtkWidget *widget) return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH; } -static void -gtk_flow_box_child_measure (GtkWidget *widget, - GtkOrientation orientation, - int for_size, - int *minimum, - int *natural, - int *minimum_baseline, - int *natural_baseline) -{ - GtkWidget *child; - - child = gtk_bin_get_child (GTK_BIN (widget)); - if (!child || ! gtk_widget_get_visible (child)) - { - *minimum = *natural = 0; - return; - } - - gtk_widget_measure (child, orientation, for_size, - minimum, natural, minimum_baseline, natural_baseline); -} - -static void -gtk_flow_box_child_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) -{ - GtkWidget *child; - - child = gtk_bin_get_child (GTK_BIN (widget)); - if (child && gtk_widget_get_visible (child)) - gtk_widget_size_allocate (child, allocation, -1); -} - /* GObject implementation {{{2 */ static void @@ -456,8 +422,6 @@ gtk_flow_box_child_class_init (GtkFlowBoxChildClass *class) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); widget_class->get_request_mode = gtk_flow_box_child_get_request_mode; - widget_class->measure = gtk_flow_box_child_measure; - widget_class->size_allocate = gtk_flow_box_child_size_allocate; widget_class->focus = gtk_flow_box_child_focus; class->activate = gtk_flow_box_child_activate; @@ -1387,9 +1351,10 @@ get_offset_pixels (GtkAlign align, } static void -gtk_flow_box_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_flow_box_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkFlowBox *box = GTK_FLOW_BOX (widget); GtkFlowBoxPrivate *priv = BOX_PRIV (box); @@ -1413,14 +1378,14 @@ gtk_flow_box_size_allocate (GtkWidget *widget, if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { - avail_size = allocation->width; - avail_other_size = allocation->height; + avail_size = width; + avail_other_size = height; item_spacing = priv->column_spacing; line_spacing = priv->row_spacing; } else /* GTK_ORIENTATION_VERTICAL */ { - avail_size = allocation->height; - avail_other_size = allocation->width; + avail_size = height; + avail_other_size = width; item_spacing = priv->row_spacing; line_spacing = priv->column_spacing; } @@ -1720,7 +1685,7 @@ gtk_flow_box_size_allocate (GtkWidget *widget, } if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->width - child_allocation.x - child_allocation.width; + child_allocation.x = width - child_allocation.x - child_allocation.width; gtk_widget_size_allocate (child, &child_allocation, -1); diff --git a/gtk/gtkfontbutton.c b/gtk/gtkfontbutton.c index 11443932cc..4617ed12d3 100644 --- a/gtk/gtkfontbutton.c +++ b/gtk/gtkfontbutton.c @@ -487,14 +487,20 @@ gtk_font_button_measure (GtkWidget *widget, } static void -gtk_font_button_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, +gtk_font_button_size_allocate (GtkWidget *widget, + int width, + int height, int baseline) { GtkFontButton *button = GTK_FONT_BUTTON (widget); GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (button); - gtk_widget_size_allocate (priv->button, allocation, baseline); + gtk_widget_size_allocate (priv->button, + &(GtkAllocation) { + 0, 0, + width, height + }, + baseline); } static void diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c index 1b1be3d9a2..ae9bc75756 100644 --- a/gtk/gtkfontchooserwidget.c +++ b/gtk/gtkfontchooserwidget.c @@ -647,16 +647,20 @@ gtk_font_chooser_widget_measure (GtkWidget *widget, } static void -gtk_font_chooser_widget_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_font_chooser_widget_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) + { GtkFontChooserWidget *self = GTK_FONT_CHOOSER_WIDGET (widget); GtkFontChooserWidgetPrivate *priv = gtk_font_chooser_widget_get_instance_private (self); - GTK_WIDGET_CLASS (gtk_font_chooser_widget_parent_class)->size_allocate (widget, allocation, -1); - - gtk_widget_size_allocate (priv->stack, allocation, -1); + gtk_widget_size_allocate (priv->stack, + &(GtkAllocation) { + 0, 0, + width, height + }, -1); } static void diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c index 62a8428dc6..b5a2aa8a6e 100644 --- a/gtk/gtkframe.c +++ b/gtk/gtkframe.c @@ -115,9 +115,10 @@ static void gtk_frame_get_property (GObject *object, guint param_id, GValue *value, GParamSpec *pspec); -static void gtk_frame_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_frame_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_frame_remove (GtkContainer *container, GtkWidget *child); static void gtk_frame_forall (GtkContainer *container, @@ -564,9 +565,10 @@ gtk_frame_get_shadow_type (GtkFrame *frame) } static void -gtk_frame_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_frame_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkFrame *frame = GTK_FRAME (widget); GtkFramePrivate *priv = gtk_frame_get_instance_private (frame); @@ -579,7 +581,7 @@ gtk_frame_size_allocate (GtkWidget *widget, gtk_widget_get_visible (priv->label_widget)) { GtkAllocation label_allocation; - int nat_width, width, height; + int nat_width, label_width, label_height; float xalign; if (_gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) @@ -589,14 +591,14 @@ gtk_frame_size_allocate (GtkWidget *widget, gtk_widget_measure (priv->label_widget, GTK_ORIENTATION_HORIZONTAL, -1, NULL, &nat_width, NULL, NULL); - width = MIN (new_allocation.width, nat_width); + label_width = MIN (new_allocation.width, nat_width); gtk_widget_measure (priv->label_widget, GTK_ORIENTATION_VERTICAL, width, - &height, NULL, NULL, NULL); + &label_height, NULL, NULL, NULL); label_allocation.x = new_allocation.x + (new_allocation.width - width) * xalign; - label_allocation.y = new_allocation.y - height; - label_allocation.height = height; - label_allocation.width = width; + label_allocation.y = new_allocation.y - label_height; + label_allocation.height = label_height; + label_allocation.width = label_width; gtk_widget_size_allocate (priv->label_widget, &label_allocation, -1); } diff --git a/gtk/gtkgizmo.c b/gtk/gtkgizmo.c index 7d03d556ba..305e0b524e 100644 --- a/gtk/gtkgizmo.c +++ b/gtk/gtkgizmo.c @@ -23,16 +23,15 @@ gtk_gizmo_measure (GtkWidget *widget, } static void -gtk_gizmo_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_gizmo_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkGizmo *self = GTK_GIZMO (widget); if (self->allocate_func) - self->allocate_func (self, - allocation, - baseline); + self->allocate_func (self, width, height, baseline); } static void diff --git a/gtk/gtkgizmoprivate.h b/gtk/gtkgizmoprivate.h index 1e59eefa66..8a99f924e7 100644 --- a/gtk/gtkgizmoprivate.h +++ b/gtk/gtkgizmoprivate.h @@ -21,9 +21,10 @@ typedef void (* GtkGizmoMeasureFunc) (GtkGizmo *gizmo, int *natural, int *minimum_baseline, int *natural_baseline); -typedef void (* GtkGizmoAllocateFunc) (GtkGizmo *gizmo, - const GtkAllocation *allocation, - int baseline); +typedef void (* GtkGizmoAllocateFunc) (GtkGizmo *gizmo, + int width, + int height, + int baseline); typedef gboolean (* GtkGizmoSnapshotFunc) (GtkGizmo *gizmo, GtkSnapshot *snapshot); diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c index 6f98415d47..3c1965f674 100644 --- a/gtk/gtkglarea.c +++ b/gtk/gtkglarea.c @@ -630,14 +630,15 @@ gtk_gl_area_unrealize (GtkWidget *widget) } static void -gtk_gl_area_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_gl_area_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkGLArea *area = GTK_GL_AREA (widget); GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); - GTK_WIDGET_CLASS (gtk_gl_area_parent_class)->size_allocate (widget, allocation, baseline); + GTK_WIDGET_CLASS (gtk_gl_area_parent_class)->size_allocate (widget, width, height, baseline); if (gtk_widget_get_realized (widget)) priv->needs_resize = TRUE; diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c index 18c7c21431..553dc485e2 100644 --- a/gtk/gtkgrid.c +++ b/gtk/gtkgrid.c @@ -1519,8 +1519,9 @@ allocate_child (GtkGridRequest *request, } static void -gtk_grid_request_allocate_children (GtkGridRequest *request, - const GtkAllocation *allocation) +gtk_grid_request_allocate_children (GtkGridRequest *request, + int grid_width, + int grid_height) { GtkWidget *child; GtkAllocation child_allocation; @@ -1545,19 +1546,19 @@ gtk_grid_request_allocate_children (GtkGridRequest *request, child_allocation.height = height; if (_gtk_widget_get_direction (GTK_WIDGET (request->grid)) == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + allocation->width - - (child_allocation.x - allocation->x) - child_allocation.width; + child_allocation.x = grid_width - child_allocation.x - child_allocation.width; gtk_widget_size_allocate (child, &child_allocation, baseline); } } -#define GET_SIZE(allocation, orientation) (orientation == GTK_ORIENTATION_HORIZONTAL ? allocation->width : allocation->height) +#define GET_SIZE(width, height, orientation) (orientation == GTK_ORIENTATION_HORIZONTAL ? width : height) static void -gtk_grid_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_grid_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkGrid *grid = GTK_GRID (widget); GtkGridRequest request; @@ -1583,15 +1584,15 @@ gtk_grid_size_allocate (GtkWidget *widget, orientation = GTK_ORIENTATION_VERTICAL; gtk_grid_request_run (&request, 1 - orientation, FALSE); - gtk_grid_request_allocate (&request, 1 - orientation, GET_SIZE (allocation, 1 - orientation)); + gtk_grid_request_allocate (&request, 1 - orientation, GET_SIZE (width, height, 1 - orientation)); gtk_grid_request_run (&request, orientation, TRUE); - gtk_grid_request_allocate (&request, orientation, GET_SIZE (allocation, orientation)); + gtk_grid_request_allocate (&request, orientation, GET_SIZE (width, height, orientation)); gtk_grid_request_position (&request, 0); gtk_grid_request_position (&request, 1); - gtk_grid_request_allocate_children (&request, allocation); + gtk_grid_request_allocate_children (&request, width, height); } static void diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c index ceb6506106..d4b500c6c2 100644 --- a/gtk/gtkheaderbar.c +++ b/gtk/gtkheaderbar.c @@ -894,9 +894,10 @@ gtk_header_bar_measure (GtkWidget *widget, } static void -gtk_header_bar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_header_bar_size_allocate (GtkWidget *widget, + int widget_width, + int widget_height, + int baseline) { GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (GTK_HEADER_BAR (widget)); GtkWidget *title_widget; @@ -925,8 +926,8 @@ gtk_header_bar_size_allocate (GtkWidget *widget, nvis_children = count_visible_children (bar); sizes = g_newa (GtkRequestedSize, nvis_children); - width = allocation->width - nvis_children * priv->spacing; - height = allocation->height; + width = widget_width - nvis_children * priv->spacing; + height = widget_height; i = 0; for (l = priv->children; l; l = l->next) @@ -1025,7 +1026,7 @@ gtk_header_bar_size_allocate (GtkWidget *widget, { gint side_free_space; - side_free_space = allocation->width / 2 - title_natural_size / 2 - side[packing]; + side_free_space = widget_width / 2 - title_natural_size / 2 - side[packing]; if (side_free_space > 0 && nexpand_children[packing] > 0) { @@ -1043,12 +1044,12 @@ gtk_header_bar_size_allocate (GtkWidget *widget, /* allocate the children on both sides of the title */ for (packing = GTK_PACK_START; packing <= GTK_PACK_END; packing++) { - child_allocation.y = allocation->y; + child_allocation.y = 0; child_allocation.height = height; if (packing == GTK_PACK_START) - x = allocation->x + start_width; + x = start_width; else - x = allocation->x + allocation->width - end_width; + x = widget_width - end_width; i = 0; for (l = priv->children; l != NULL; l = l->next) @@ -1094,7 +1095,7 @@ gtk_header_bar_size_allocate (GtkWidget *widget, } if (direction == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; + child_allocation.x = widget_width - child_allocation.x - child_allocation.width; gtk_widget_size_allocate (child->widget, &child_allocation, baseline); @@ -1106,12 +1107,12 @@ gtk_header_bar_size_allocate (GtkWidget *widget, /* We don't enforce css borders on the center widget, to make * title/subtitle combinations fit without growing the header */ - child_allocation.y = allocation->y; - child_allocation.height = allocation->height; + child_allocation.y = 0; + child_allocation.height = widget_height; - child_size = MIN (allocation->width - side[0] - side[1], title_natural_size); + child_size = MIN (widget_width - side[0] - side[1], title_natural_size); - child_allocation.x = allocation->x + (allocation->width - child_size) / 2; + child_allocation.x = (widget_width - child_size) / 2; child_allocation.width = child_size; /* if the title widget is expanded, then grow it by all the available @@ -1123,29 +1124,29 @@ gtk_header_bar_size_allocate (GtkWidget *widget, child_allocation.x -= width / 2; } - if (allocation->x + side[0] > child_allocation.x) - child_allocation.x = allocation->x + side[0]; - else if (allocation->x + allocation->width - side[1] < child_allocation.x + child_allocation.width) - child_allocation.x = allocation->x + allocation->width - side[1] - child_allocation.width; + if (side[0] > child_allocation.x) + child_allocation.x = side[0]; + else if (widget_width - side[1] < child_allocation.x + child_allocation.width) + child_allocation.x = widget_width - side[1] - child_allocation.width; if (direction == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; + child_allocation.x = widget_width - (child_allocation.x) - child_allocation.width; if (title_widget != NULL) { gtk_widget_size_allocate (title_widget, &child_allocation, baseline); } - child_allocation.y = allocation->y; + child_allocation.y = 0; child_allocation.height = height; if (priv->titlebar_start_box) { gboolean left = (direction == GTK_TEXT_DIR_LTR); if (left) - child_allocation.x = allocation->x; + child_allocation.x = 0; else - child_allocation.x = allocation->x + allocation->width - start_width + priv->spacing; + child_allocation.x = widget_width - start_width + priv->spacing; child_allocation.width = start_width - priv->spacing; gtk_widget_size_allocate (priv->titlebar_start_box, &child_allocation, baseline); } @@ -1154,9 +1155,9 @@ gtk_header_bar_size_allocate (GtkWidget *widget, { gboolean left = (direction != GTK_TEXT_DIR_LTR); if (left) - child_allocation.x = allocation->x; + child_allocation.x = 0; else - child_allocation.x = allocation->x + allocation->width - end_width + priv->spacing; + child_allocation.x = widget_width - end_width + priv->spacing; child_allocation.width = end_width - priv->spacing; gtk_widget_size_allocate (priv->titlebar_end_box, &child_allocation, baseline); } diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 45f37b347e..b92747bb88 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -153,9 +153,10 @@ static void gtk_icon_view_measure (GtkWidget *widget, int *natural, int *minimum_baseline, int *natural_baseline); -static void gtk_icon_view_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_icon_view_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_icon_view_snapshot (GtkWidget *widget, GtkSnapshot *snapshot); static void gtk_icon_view_motion (GtkEventController *controller, @@ -1616,9 +1617,10 @@ gtk_icon_view_allocate_children (GtkIconView *icon_view) } static void -gtk_icon_view_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_icon_view_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkIconView *icon_view = GTK_ICON_VIEW (widget); diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 967e4f46ab..7ca9ad7cf3 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -404,9 +404,10 @@ static void gtk_label_get_property (GObject *object, GParamSpec *pspec); static void gtk_label_finalize (GObject *object); static void gtk_label_destroy (GtkWidget *widget); -static void gtk_label_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_label_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_label_state_flags_changed (GtkWidget *widget, GtkStateFlags prev_state); static void gtk_label_style_updated (GtkWidget *widget); @@ -3649,9 +3650,10 @@ get_layout_location (GtkLabel *label, } static void -gtk_label_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_label_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkLabel *label = GTK_LABEL (widget); GtkLabelPrivate *priv = gtk_label_get_instance_private (label); @@ -3659,8 +3661,7 @@ gtk_label_size_allocate (GtkWidget *widget, if (priv->layout) { if (priv->ellipsize || priv->wrap) - pango_layout_set_width (priv->layout, - allocation->width * PANGO_SCALE); + pango_layout_set_width (priv->layout, width * PANGO_SCALE); else pango_layout_set_width (priv->layout, -1); } diff --git a/gtk/gtklayout.c b/gtk/gtklayout.c index cbe9b42113..0ecc6d6666 100644 --- a/gtk/gtklayout.c +++ b/gtk/gtklayout.c @@ -115,9 +115,10 @@ static void gtk_layout_measure (GtkWidget *widget, int *natural, int *minimum_baseline, int *natural_baseline); -static void gtk_layout_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_layout_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_layout_add (GtkContainer *container, GtkWidget *widget); static void gtk_layout_remove (GtkContainer *container, @@ -707,9 +708,10 @@ gtk_layout_measure (GtkWidget *widget, static void -gtk_layout_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_layout_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkLayout *layout = GTK_LAYOUT (widget); GtkLayoutPrivate *priv = gtk_layout_get_instance_private (layout); diff --git a/gtk/gtklevelbar.c b/gtk/gtklevelbar.c index af61eeaeb1..1402e4dddf 100644 --- a/gtk/gtklevelbar.c +++ b/gtk/gtklevelbar.c @@ -427,9 +427,10 @@ gtk_level_bar_measure (GtkWidget *widget, } static void -gtk_level_bar_allocate_trough_continuous (GtkLevelBar *self, - const GtkAllocation *allocation, - int baseline) +gtk_level_bar_allocate_trough_continuous (GtkLevelBar *self, + int width, + int height, + int baseline) { GtkLevelBarPrivate *priv = gtk_level_bar_get_instance_private (self); GtkAllocation block_area; @@ -441,14 +442,14 @@ gtk_level_bar_allocate_trough_continuous (GtkLevelBar *self, /* allocate the empty (unfilled) part */ gtk_widget_size_allocate (priv->block_widget[inverted ? 0 : 1], - allocation, + &(GtkAllocation) {0, 0, width, height}, baseline); if (priv->cur_value == 0) return; /* now allocate the filled part */ - block_area = *allocation; + block_area = (GtkAllocation) {0, 0, width, height}; fill_percentage = (priv->cur_value - priv->min_value) / (priv->max_value - priv->min_value); @@ -463,7 +464,7 @@ gtk_level_bar_allocate_trough_continuous (GtkLevelBar *self, block_area.width = MAX (block_area.width, block_min); if (inverted) - block_area.x += allocation->width - block_area.width; + block_area.x += width - block_area.width; } else { @@ -471,7 +472,7 @@ gtk_level_bar_allocate_trough_continuous (GtkLevelBar *self, block_area.height = MAX (block_area.height, block_min); if (inverted) - block_area.y += allocation->height - block_area.height; + block_area.y += height - block_area.height; } gtk_widget_size_allocate (priv->block_widget[inverted ? 1 : 0], @@ -481,8 +482,9 @@ gtk_level_bar_allocate_trough_continuous (GtkLevelBar *self, static void gtk_level_bar_allocate_trough_discrete (GtkLevelBar *self, - const GtkAllocation *allocation, - int baseline) + int width, + int height, + int baseline) { GtkLevelBarPrivate *priv = gtk_level_bar_get_instance_private (self); GtkAllocation block_area; @@ -497,17 +499,17 @@ gtk_level_bar_allocate_trough_discrete (GtkLevelBar *self, if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { - block_width = MAX (block_width, (gint) floor (allocation->width / num_blocks)); - block_height = allocation->height; + block_width = MAX (block_width, (gint) floor (width / num_blocks)); + block_height = height; } else { - block_width = allocation->width; - block_height = MAX (block_height, (gint) floor (allocation->height / num_blocks)); + block_width = width; + block_height = MAX (block_height, (gint) floor (height / num_blocks)); } - block_area.x = allocation->x; - block_area.y = allocation->y; + block_area.x = 0; + block_area.y = 0; block_area.width = block_width; block_area.height = block_height; @@ -525,28 +527,34 @@ gtk_level_bar_allocate_trough_discrete (GtkLevelBar *self, } static void -gtk_level_bar_allocate_trough (GtkGizmo *gizmo, - const GtkAllocation *allocation, - int baseline) +gtk_level_bar_allocate_trough (GtkGizmo *gizmo, + int width, + int height, + int baseline) { GtkWidget *widget = GTK_WIDGET (gizmo); GtkLevelBar *self = GTK_LEVEL_BAR (gtk_widget_get_parent (widget)); GtkLevelBarPrivate *priv = gtk_level_bar_get_instance_private (self); if (priv->bar_mode == GTK_LEVEL_BAR_MODE_CONTINUOUS) - gtk_level_bar_allocate_trough_continuous (self, allocation, baseline); + gtk_level_bar_allocate_trough_continuous (self, width, height, baseline); else - gtk_level_bar_allocate_trough_discrete (self, allocation, baseline); + gtk_level_bar_allocate_trough_discrete (self, width, height, baseline); } static void -gtk_level_bar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_level_bar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkLevelBarPrivate *priv = gtk_level_bar_get_instance_private (GTK_LEVEL_BAR (widget)); - gtk_widget_size_allocate (priv->trough_widget, allocation, baseline); + gtk_widget_size_allocate (priv->trough_widget, + &(GtkAllocation) { + 0, 0, + width, height + }, baseline); } static void diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c index 8702c5086f..dc470ebce7 100644 --- a/gtk/gtklistbox.c +++ b/gtk/gtklistbox.c @@ -227,7 +227,8 @@ static void gtk_list_box_compute_expand (GtkWidget static GType gtk_list_box_child_type (GtkContainer *container); static GtkSizeRequestMode gtk_list_box_get_request_mode (GtkWidget *widget); static void gtk_list_box_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, + int width, + int height, int baseline); static void gtk_list_box_drag_leave (GtkWidget *widget, GdkDrop *drop); @@ -2504,9 +2505,10 @@ gtk_list_box_measure (GtkWidget *widget, } static void -gtk_list_box_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_list_box_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkListBoxPrivate *priv = BOX_PRIV (widget); GtkAllocation child_allocation; @@ -2516,22 +2518,22 @@ gtk_list_box_size_allocate (GtkWidget *widget, int child_min; - child_allocation.x = allocation->x; - child_allocation.y = allocation->y; - child_allocation.width = allocation->width; + child_allocation.x = 0; + child_allocation.y = 0; + child_allocation.width = width; child_allocation.height = 0; - header_allocation.x = allocation->x; - header_allocation.y = allocation->y; - header_allocation.width = allocation->width; + header_allocation.x = 0; + header_allocation.y = 0; + header_allocation.width = width; header_allocation.height = 0; if (priv->placeholder && gtk_widget_get_child_visible (priv->placeholder)) { gtk_widget_measure (priv->placeholder, GTK_ORIENTATION_VERTICAL, - allocation->width, + width, &child_min, NULL, NULL, NULL); - header_allocation.height = allocation->height; + header_allocation.height = height; header_allocation.y = child_allocation.y; gtk_widget_size_allocate (priv->placeholder, &header_allocation, -1); child_allocation.y += child_min; @@ -2552,7 +2554,7 @@ gtk_list_box_size_allocate (GtkWidget *widget, if (ROW_PRIV (row)->header != NULL) { gtk_widget_measure (ROW_PRIV (row)->header, GTK_ORIENTATION_VERTICAL, - allocation->width, + width, &child_min, NULL, NULL, NULL); header_allocation.height = child_min; header_allocation.y = child_allocation.y; diff --git a/gtk/gtkmediacontrols.c b/gtk/gtkmediacontrols.c index 22d1852b48..146d21eaf7 100644 --- a/gtk/gtkmediacontrols.c +++ b/gtk/gtkmediacontrols.c @@ -185,13 +185,18 @@ gtk_media_controls_measure (GtkWidget *widget, } static void -gtk_media_controls_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_media_controls_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkMediaControls *controls = GTK_MEDIA_CONTROLS (widget); - gtk_widget_size_allocate (controls->box, allocation, baseline); + gtk_widget_size_allocate (controls->box, + &(GtkAllocation) { + 0, 0, + width, height + }, baseline); } static void diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index b28732f3a0..b5419955c4 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -219,9 +219,10 @@ static void gtk_menu_get_child_property(GtkContainer *container, static void gtk_menu_destroy (GtkWidget *widget); static void gtk_menu_realize (GtkWidget *widget); static void gtk_menu_unrealize (GtkWidget *widget); -static void gtk_menu_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_menu_size_allocate (GtkWidget *widget, + int widget_width, + int widget_height, + int baseline); static void gtk_menu_show (GtkWidget *widget); static void gtk_menu_snapshot (GtkWidget *widget, GtkSnapshot *snapshot); @@ -2490,9 +2491,10 @@ calculate_line_heights (GtkMenu *menu, } static void -gtk_menu_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_menu_size_allocate (GtkWidget *widget, + int widget_width, + int widget_height, + int baseline) { GtkMenu *menu; GtkMenuPrivate *priv; @@ -2506,7 +2508,6 @@ gtk_menu_size_allocate (GtkWidget *widget, int base_width; g_return_if_fail (GTK_IS_MENU (widget)); - g_return_if_fail (allocation != NULL); menu = GTK_MENU (widget); menu_shell = GTK_MENU_SHELL (widget); @@ -2514,7 +2515,7 @@ gtk_menu_size_allocate (GtkWidget *widget, g_free (priv->heights); priv->heights_length = calculate_line_heights (menu, - allocation->width, + widget_width, &priv->heights, NULL); @@ -2525,7 +2526,7 @@ gtk_menu_size_allocate (GtkWidget *widget, /* Show scroll arrows if necessary */ - if (priv->requested_height > allocation->height) + if (priv->requested_height > widget_height) { gtk_widget_set_child_visible (priv->top_arrow_widget, TRUE); gtk_widget_set_child_visible (priv->bottom_arrow_widget, TRUE); @@ -2536,10 +2537,10 @@ gtk_menu_size_allocate (GtkWidget *widget, gtk_widget_set_child_visible (priv->bottom_arrow_widget, FALSE); } - x = allocation->x; - y = allocation->y; - width = allocation->width; - height = allocation->height; + x = 0; + y = 0; + width = widget_width; + height = widget_height; if (menu_shell->priv->active) gtk_menu_scroll_to (menu, priv->scroll_offset); diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index 6be6f6c5cc..ce5e1388b9 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -87,9 +87,10 @@ static void gtk_menu_bar_measure (GtkWidget *widget, int *natural, int *minimum_baseline, int *natural_baseline); -static void gtk_menu_bar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_menu_bar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget, GtkWidget *old_toplevel); static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell); @@ -338,9 +339,10 @@ gtk_menu_bar_measure (GtkWidget *widget, } static void -gtk_menu_bar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_menu_bar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkMenuBar *menu_bar = GTK_MENU_BAR (widget); GtkMenuBarPrivate *priv = menu_bar->priv; @@ -357,7 +359,7 @@ gtk_menu_bar_size_allocate (GtkWidget *widget, if (!menu_shell->priv->children) return; - remaining_space = *allocation; + remaining_space = (GtkAllocation) {0, 0, width, height}; requested_sizes = g_array_new (FALSE, FALSE, sizeof (GtkRequestedSize)); if (priv->pack_direction == GTK_PACK_DIRECTION_LTR || diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index 23c366f19e..34642a6cac 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -251,9 +251,10 @@ gtk_menu_item_actionable_interface_init (GtkActionableInterface *iface) } static void -gtk_menu_item_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_menu_item_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkMenuItem *menu_item = GTK_MENU_ITEM (widget); GtkMenuItemPrivate *priv = menu_item->priv; @@ -264,7 +265,6 @@ gtk_menu_item_size_allocate (GtkWidget *widget, GtkWidget *parent; g_return_if_fail (GTK_IS_MENU_ITEM (widget)); - g_return_if_fail (allocation != NULL); direction = gtk_widget_get_direction (widget); @@ -281,7 +281,7 @@ gtk_menu_item_size_allocate (GtkWidget *widget, child = gtk_bin_get_child (GTK_BIN (widget)); if (child) { - child_allocation = *allocation; + child_allocation = (GtkAllocation) {0, 0, width, height}; if (child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL) diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c index 29ff7bd21e..16cf8b1c75 100644 --- a/gtk/gtkmodelbutton.c +++ b/gtk/gtkmodelbutton.c @@ -778,14 +778,16 @@ gtk_model_button_measure (GtkWidget *widget, } static void -gtk_model_button_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_model_button_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { if (GTK_MODEL_BUTTON (widget)->iconic) { GTK_WIDGET_CLASS (gtk_model_button_parent_class)->size_allocate (widget, - allocation, + width, + height, baseline); } else @@ -813,10 +815,10 @@ gtk_model_button_size_allocate (GtkWidget *widget, NULL, NULL); if (indicator_is_left (widget)) - child_allocation.x = allocation->x; + child_allocation.x = 0; else - child_allocation.x = allocation->x + allocation->width - check_nat_width; - child_allocation.y = allocation->y + (allocation->height - check_nat_height) / 2; + child_allocation.x = width - check_nat_width; + child_allocation.y = (height - check_nat_height) / 2; child_allocation.width = check_nat_width; child_allocation.height = check_nat_height; @@ -839,10 +841,10 @@ gtk_model_button_size_allocate (GtkWidget *widget, border.right += check_nat_width; } - child_allocation.x = allocation->x + border.left; - child_allocation.y = allocation->y + border.top; - child_allocation.width = allocation->width - border.left - border.right; - child_allocation.height = allocation->height - border.top - border.bottom; + child_allocation.x = border.left; + child_allocation.y = border.top; + child_allocation.width = width - border.left - border.right; + child_allocation.height = height - border.top - border.bottom; if (baseline != -1) baseline -= border.top; diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 6b8ccad3b7..c873ec3b23 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -367,7 +367,8 @@ static void gtk_notebook_measure (GtkWidget *widget, int *minimum_baseline, int *natural_baseline); static void gtk_notebook_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, + int width, + int height, int baseline); static gboolean gtk_notebook_popup_menu (GtkWidget *widget); static void gtk_notebook_motion (GtkEventController *controller, @@ -447,8 +448,9 @@ static void gtk_notebook_measure_tabs (GtkGizmo *gizmo, gint *natural, gint *minimum_baseline, gint *natural_baseline); -static void gtk_notebook_allocate_tabs (GtkGizmo *gizmo, - const GtkAllocation *allocation, +static void gtk_notebook_allocate_tabs (GtkGizmo *gizmo, + int width, + int height, int baseline); static gboolean gtk_notebook_snapshot_tabs (GtkGizmo *gizmo, GtkSnapshot *snapshot); @@ -472,7 +474,8 @@ static void gtk_notebook_child_reordered (GtkNotebook *notebook, /*** GtkNotebook Size Allocate Functions ***/ static void gtk_notebook_pages_allocate (GtkNotebook *notebook, - const GtkAllocation *allocation); + int width, + int height); static void gtk_notebook_calc_tabs (GtkNotebook *notebook, GList *start, GList **end, @@ -2024,25 +2027,31 @@ gtk_notebook_measure (GtkWidget *widget, } static void -gtk_notebook_allocate_tabs (GtkGizmo *gizmo, - const GtkAllocation *allocation, - int baseline) +gtk_notebook_allocate_tabs (GtkGizmo *gizmo, + int width, + int height, + int baseline) { GtkWidget *widget = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (gizmo))); GtkNotebook *notebook = GTK_NOTEBOOK (gtk_widget_get_parent (widget)); - gtk_notebook_pages_allocate (notebook, allocation); + gtk_notebook_pages_allocate (notebook, width, height); } static void -gtk_notebook_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_notebook_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); GtkNotebookPrivate *priv = notebook->priv; - gtk_widget_size_allocate (priv->box, allocation, -1); + gtk_widget_size_allocate (priv->box, + &(GtkAllocation) { + 0, 0, + width, height + }, -1); } static gboolean @@ -3872,9 +3881,10 @@ measure_tab (GtkGizmo *gizmo, } static void -allocate_tab (GtkGizmo *gizmo, - const GtkAllocation *allocation, - int baseline) +allocate_tab (GtkGizmo *gizmo, + int width, + int height, + int baseline) { GtkNotebook *notebook = g_object_get_data (G_OBJECT (gizmo), "notebook"); GtkNotebookPrivate *priv = notebook->priv; @@ -3894,30 +3904,29 @@ allocate_tab (GtkGizmo *gizmo, g_assert (page != NULL); - - child_allocation = *allocation; + child_allocation = (GtkAllocation) {0, 0, width, height}; if (!page->fill) { if (priv->tab_pos == GTK_POS_TOP || priv->tab_pos == GTK_POS_BOTTOM) { - gtk_widget_measure (page->tab_label, GTK_ORIENTATION_HORIZONTAL, allocation->height, + gtk_widget_measure (page->tab_label, GTK_ORIENTATION_HORIZONTAL, height, NULL, &child_allocation.width, NULL, NULL); - if (child_allocation.width > allocation->width) - child_allocation.width = allocation->width; + if (child_allocation.width > width) + child_allocation.width = width; else - child_allocation.x += (allocation->width - child_allocation.width) / 2; + child_allocation.x += (width - child_allocation.width) / 2; } else { - gtk_widget_measure (page->tab_label, GTK_ORIENTATION_VERTICAL, allocation->width, + gtk_widget_measure (page->tab_label, GTK_ORIENTATION_VERTICAL, width, NULL, &child_allocation.height, NULL, NULL); - if (child_allocation.height > allocation->height) - child_allocation.height = allocation->height; + if (child_allocation.height > height) + child_allocation.height = height; else - child_allocation.y += (allocation->height - child_allocation.height) / 2; + child_allocation.y += (height - child_allocation.height) / 2; } } @@ -4562,11 +4571,12 @@ gtk_notebook_allocate_arrows (GtkNotebook *notebook, static void -gtk_notebook_tab_space (GtkNotebook *notebook, - const GtkAllocation *allocation, - gboolean *show_arrows, - GtkAllocation *tabs_allocation, - gint *tab_space) +gtk_notebook_tab_space (GtkNotebook *notebook, + int notebook_width, + int notebook_height, + gboolean *show_arrows, + GtkAllocation *tabs_allocation, + gint *tab_space) { GtkNotebookPrivate *priv = notebook->priv; GList *children; @@ -4574,7 +4584,7 @@ gtk_notebook_tab_space (GtkNotebook *notebook, children = priv->children; - *tabs_allocation = *allocation; + *tabs_allocation = (GtkAllocation) {0, 0, notebook_width, notebook_height}; switch (tab_pos) { @@ -5176,8 +5186,9 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook, } static void -gtk_notebook_pages_allocate (GtkNotebook *notebook, - const GtkAllocation *allocation) +gtk_notebook_pages_allocate (GtkNotebook *notebook, + int width, + int height) { GtkNotebookPrivate *priv = notebook->priv; GList *children = NULL; @@ -5193,7 +5204,7 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook, tab_space = remaining_space = 0; expanded_tabs = 1; - gtk_notebook_tab_space (notebook, allocation, + gtk_notebook_tab_space (notebook, width, height, &showarrow, &tabs_allocation, &tab_space); gtk_notebook_calculate_shown_tabs (notebook, showarrow, diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c index a52d8179d3..10fc2a8250 100644 --- a/gtk/gtkoverlay.c +++ b/gtk/gtkoverlay.c @@ -300,9 +300,10 @@ gtk_overlay_child_allocate (GtkOverlay *overlay, } static void -gtk_overlay_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_overlay_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkOverlay *overlay = GTK_OVERLAY (widget); GtkWidget *child; @@ -310,7 +311,11 @@ gtk_overlay_size_allocate (GtkWidget *widget, main_widget = gtk_bin_get_child (GTK_BIN (overlay)); if (main_widget && gtk_widget_get_visible (main_widget)) - gtk_widget_size_allocate (main_widget, allocation, -1); + gtk_widget_size_allocate (main_widget, + &(GtkAllocation) { + 0, 0, + width, height + }, -1); for (child = gtk_widget_get_first_child (widget); child != NULL; diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index 464110ce98..a95c18bcb4 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -216,7 +216,8 @@ static void gtk_paned_measure (GtkWidget *widget, int *minimum_baseline, int *natural_baseline); static void gtk_paned_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, + int width, + int height, int baseline); static void gtk_paned_unrealize (GtkWidget *widget); static void gtk_paned_snapshot (GtkWidget *widget, @@ -1183,13 +1184,9 @@ gtk_paned_measure (GtkWidget *widget, } static void -flip_child (const GtkAllocation *allocation, - GtkAllocation *child_pos) +flip_child (int width, + GtkAllocation *child_pos) { - int width; - - width = allocation->width; - child_pos->x = width - child_pos->x - child_pos->width; } @@ -1210,9 +1207,10 @@ gtk_paned_set_child_visible (GtkPaned *paned, } static void -gtk_paned_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_paned_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkPaned *paned = GTK_PANED (widget); GtkPanedPrivate *priv = gtk_paned_get_instance_private (paned); @@ -1236,14 +1234,14 @@ gtk_paned_size_allocate (GtkWidget *widget, gint child1_width, child2_width; gtk_widget_measure (priv->child1, GTK_ORIENTATION_HORIZONTAL, - allocation->height, + height, &child1_width, NULL, NULL, NULL); gtk_widget_measure (priv->child2, GTK_ORIENTATION_HORIZONTAL, - allocation->height, + height, &child2_width, NULL, NULL, NULL); gtk_paned_calc_position (paned, - MAX (1, allocation->width - handle_size), + MAX (1, width - handle_size), child1_width, child2_width); @@ -1251,22 +1249,22 @@ gtk_paned_size_allocate (GtkWidget *widget, priv->child1_size, 0, handle_size, - allocation->height + height }; - child1_allocation.height = child2_allocation.height = allocation->height; + child1_allocation.height = child2_allocation.height = height; child1_allocation.width = MAX (1, priv->child1_size); child1_allocation.x = 0; child1_allocation.y = child2_allocation.y = 0; child2_allocation.x = child1_allocation.x + priv->child1_size + handle_size; - child2_allocation.width = MAX (1, allocation->width - priv->child1_size - handle_size); + child2_allocation.width = MAX (1, width - priv->child1_size - handle_size); if (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_RTL) { - flip_child (allocation, &(child2_allocation)); - flip_child (allocation, &(child1_allocation)); - flip_child (allocation, &(handle_allocation)); + flip_child (width, &(child2_allocation)); + flip_child (width, &(child1_allocation)); + flip_child (width, &(handle_allocation)); } if (child1_width > child1_allocation.width) @@ -1288,31 +1286,31 @@ gtk_paned_size_allocate (GtkWidget *widget, gint child1_height, child2_height; gtk_widget_measure (priv->child1, GTK_ORIENTATION_VERTICAL, - allocation->width, + width, &child1_height, NULL, NULL, NULL); gtk_widget_measure (priv->child2, GTK_ORIENTATION_VERTICAL, - allocation->width, + width, &child2_height, NULL, NULL, NULL); gtk_paned_calc_position (paned, - MAX (1, allocation->height - handle_size), + MAX (1, height - handle_size), child1_height, child2_height); handle_allocation = (GdkRectangle){ 0, priv->child1_size, - allocation->width, + width, handle_size, }; - child1_allocation.width = child2_allocation.width = allocation->width; + child1_allocation.width = child2_allocation.width = width; child1_allocation.height = MAX (1, priv->child1_size); child1_allocation.x = child2_allocation.x = 0; child1_allocation.y = 0; child2_allocation.y = child1_allocation.y + priv->child1_size + handle_size; - child2_allocation.height = MAX (1, allocation->height - child2_allocation.y); + child2_allocation.height = MAX (1, height - child2_allocation.y); if (child1_height > child1_allocation.height) { @@ -1335,14 +1333,17 @@ gtk_paned_size_allocate (GtkWidget *widget, gtk_paned_set_child_visible (paned, CHILD1, TRUE); gtk_paned_set_child_visible (paned, CHILD2, FALSE); - gtk_widget_size_allocate (priv->child1, allocation, -1); + gtk_widget_size_allocate (priv->child1, + &(GtkAllocation) {0, 0, width, height}, -1); } else if (priv->child2 && gtk_widget_get_visible (priv->child2)) { gtk_paned_set_child_visible (paned, CHILD1, FALSE); gtk_paned_set_child_visible (paned, CHILD2, TRUE); - gtk_widget_size_allocate (priv->child2, allocation, -1); + gtk_widget_size_allocate (priv->child2, + &(GtkAllocation) {0, 0, width, height}, -1); + } else { diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c index 5c1f7620d9..e3e91a21a9 100644 --- a/gtk/gtkpathbar.c +++ b/gtk/gtkpathbar.c @@ -132,7 +132,8 @@ static void gtk_path_bar_measure (GtkWidget *widget, int *minimum_baseline, int *natural_baseline); static void gtk_path_bar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, + int width, + int height, int baseline); static void gtk_path_bar_add (GtkContainer *container, GtkWidget *widget); @@ -485,9 +486,10 @@ gtk_path_bar_update_slider_buttons (GtkPathBar *path_bar) /* This is a tad complicated */ static void -gtk_path_bar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_path_bar_size_allocate (GtkWidget *widget, + int widget_width, + int widget_height, + int baseline) { GtkPathBar *path_bar = GTK_PATH_BAR (widget); GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (path_bar); @@ -507,7 +509,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget, return; direction = gtk_widget_get_direction (widget); - allocation_width = allocation->width; + allocation_width = widget_width; /* First, we check to see if we need the scrollbars. */ if (priv->fake_root) @@ -593,21 +595,21 @@ gtk_path_bar_size_allocate (GtkWidget *widget, } /* Now, we allocate space to the buttons */ - child_allocation.y = allocation->y; - child_allocation.height = allocation->height; + child_allocation.y = 0; + child_allocation.height = widget_height; if (direction == GTK_TEXT_DIR_RTL) { - child_allocation.x = allocation->x + allocation->width; + child_allocation.x = widget_width; if (need_sliders || priv->fake_root) { child_allocation.x -= priv->slider_width; - up_slider_offset = allocation->width - priv->slider_width; + up_slider_offset = widget_width - priv->slider_width; } } else { - child_allocation.x = allocation->x; + child_allocation.x = 0; if (need_sliders || priv->fake_root) { up_slider_offset = 0; @@ -659,7 +661,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget, if (direction == GTK_TEXT_DIR_RTL) { - down_slider_offset = child_allocation.x - allocation->x - priv->slider_width; + down_slider_offset = child_allocation.x - priv->slider_width; } else { @@ -683,7 +685,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget, if (need_sliders || priv->fake_root) { child_allocation.width = priv->slider_width; - child_allocation.x = up_slider_offset + allocation->x; + child_allocation.x = up_slider_offset; gtk_widget_size_allocate (priv->up_slider_button, &child_allocation, -1); @@ -702,7 +704,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget, if (need_sliders) { child_allocation.width = priv->slider_width; - child_allocation.x = down_slider_offset + allocation->x; + child_allocation.x = down_slider_offset; gtk_widget_size_allocate (priv->down_slider_button, &child_allocation, diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index 94f234c223..36c2db858e 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -246,15 +246,20 @@ measure_contents (GtkGizmo *gizmo, } static void -allocate_contents (GtkGizmo *gizmo, - const GtkAllocation *allocation, - int baseline) +allocate_contents (GtkGizmo *gizmo, + int width, + int height, + int baseline) { GtkPopover *popover = GTK_POPOVER (gtk_widget_get_parent (GTK_WIDGET (gizmo))); GtkWidget *child = gtk_bin_get_child (GTK_BIN (popover)); if (child) - gtk_widget_size_allocate (child, allocation, -1); + gtk_widget_size_allocate (child, + &(GtkAllocation) { + 0, 0, + width, height + }, -1); } static void @@ -1389,13 +1394,14 @@ gtk_popover_measure (GtkWidget *widget, } static void -gtk_popover_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_popover_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkPopover *popover = GTK_POPOVER (widget); GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover); - GtkAllocation child_alloc = *allocation; + GtkAllocation child_alloc = (GtkAllocation) {0, 0, width, height}; /* Note that we in measure() we add TAIL_HEIGHT in both directions, regardless * of the popovers position. This is to ensure that we get enough space @@ -1781,10 +1787,11 @@ _gtk_popover_parent_unmap (GtkWidget *widget, } static void -gtk_popover_parent_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline, - GtkPopover *popover) +gtk_popover_parent_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline, + GtkPopover *popover) { gtk_popover_update_position (popover); } diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c index 2a4292306c..3a53471cf7 100644 --- a/gtk/gtkprogressbar.c +++ b/gtk/gtkprogressbar.c @@ -142,9 +142,10 @@ static void gtk_progress_bar_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void gtk_progress_bar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_progress_bar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_progress_bar_act_mode_enter (GtkProgressBar *progress); static void gtk_progress_bar_act_mode_leave (GtkProgressBar *progress); @@ -370,15 +371,16 @@ update_node_classes (GtkProgressBar *pbar) } static void -allocate_trough (GtkGizmo *gizmo, - const GtkAllocation *allocation, - int baseline) +allocate_trough (GtkGizmo *gizmo, + int width, + int height, + int baseline) { GtkProgressBar *pbar = GTK_PROGRESS_BAR (gtk_widget_get_parent (GTK_WIDGET (gizmo))); GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (pbar); GtkAllocation alloc; - gint width, height; + int progress_width, progress_height; gboolean inverted; inverted = priv->inverted; @@ -389,58 +391,58 @@ allocate_trough (GtkGizmo *gizmo, } gtk_widget_measure (priv->progress_widget, GTK_ORIENTATION_VERTICAL, -1, - &height, NULL, + &progress_height, NULL, NULL, NULL); gtk_widget_measure (priv->progress_widget, GTK_ORIENTATION_HORIZONTAL, -1, - &width, NULL, + &progress_width, NULL, NULL, NULL); if (priv->activity_mode) { if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { - alloc.width = width + (allocation->width - width) / priv->activity_blocks; - alloc.x = allocation->x + priv->activity_pos * (allocation->width - alloc.width); - alloc.y = allocation->y + (allocation->height - height) / 2; - alloc.height = height; + alloc.width = progress_width + (width - progress_width) / priv->activity_blocks; + alloc.x = priv->activity_pos * (width - alloc.width); + alloc.y = (height - progress_height) / 2; + alloc.height = progress_height; } else { - alloc.height = height + (allocation->height - height) / priv->activity_blocks; - alloc.y = allocation->y + priv->activity_pos * (allocation->height - alloc.height); - alloc.x = allocation->x + (allocation->width - width) / 2; - alloc.width = width; + alloc.height = progress_height + (height - progress_height) / priv->activity_blocks; + alloc.y = priv->activity_pos * (height - alloc.height); + alloc.x = (width - progress_width) / 2; + alloc.width = progress_width; } } else { if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { - alloc.width = width + (allocation->width - width) * priv->fraction; - alloc.height = height; - alloc.y = allocation->y + (allocation->height - height) / 2; + alloc.width = progress_width + (width - progress_width) * priv->fraction; + alloc.height = progress_height; + alloc.y = (height - progress_height) / 2; if (!inverted) - alloc.x = allocation->x; + alloc.x = 0; else - alloc.x = allocation->x + allocation->width - alloc.width; + alloc.x = width - alloc.width; } else { - alloc.width = width; - alloc.height = height + (allocation->height - height) * priv->fraction; - alloc.x = allocation->x + (allocation->width - width) / 2; + alloc.width = progress_width; + alloc.height = progress_height + (height - progress_height) * priv->fraction; + alloc.x = (width - progress_width) / 2; if (!inverted) - alloc.y = allocation->y; + alloc.y = 0; else - alloc.y = allocation->y + allocation->height - alloc.height; + alloc.y = height - alloc.height; } } - gtk_widget_size_allocate (priv->progress_widget, &alloc,-1); + gtk_widget_size_allocate (priv->progress_widget, &alloc, -1); } @@ -616,9 +618,10 @@ get_current_text (GtkProgressBar *pbar) } static void -gtk_progress_bar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_progress_bar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkProgressBarPrivate *priv = gtk_progress_bar_get_instance_private (GTK_PROGRESS_BAR (widget)); gint bar_width, bar_height; @@ -630,18 +633,18 @@ gtk_progress_bar_size_allocate (GtkWidget *widget, gtk_widget_measure (priv->trough_widget, GTK_ORIENTATION_VERTICAL, -1, &bar_height, NULL, NULL, NULL); - bar_width = allocation->width; + bar_width = width; } else { gtk_widget_measure (priv->trough_widget, GTK_ORIENTATION_HORIZONTAL, -1, &bar_width, NULL, NULL, NULL); - bar_height = allocation->height; + bar_height = height; } - alloc.x = allocation->x + allocation->width - bar_width; - alloc.y = allocation->y + allocation->height - bar_height; + alloc.x = width - bar_width; + alloc.y = height - bar_height; alloc.width = bar_width; alloc.height = bar_height; @@ -657,19 +660,19 @@ gtk_progress_bar_size_allocate (GtkWidget *widget, &text_height, NULL, NULL, NULL); - text_width = CLAMP (text_nat, text_min, allocation->width); + text_width = CLAMP (text_nat, text_min, width); if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { - alloc.x = allocation->x + (allocation->width - text_width) / 2; - alloc.y = allocation->y; + alloc.x = (width - text_width) / 2; + alloc.y = 0; alloc.width = text_width; alloc.height = text_height; } else { - alloc.x = allocation->x + allocation->width - text_width; - alloc.y = allocation->y + (allocation->height - text_height) / 2; + alloc.x = width - text_width; + alloc.y = (height - text_height) / 2; alloc.width = text_width; alloc.height = text_height; } diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index b5985de420..26fd7d8a7f 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -156,9 +156,10 @@ static void gtk_range_measure (GtkWidget *widget, int *natural, int *minimum_baseline, int *natural_baseline); -static void gtk_range_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_range_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_range_unmap (GtkWidget *widget); static void gtk_range_multipress_gesture_pressed (GtkGestureMultiPress *gesture, @@ -230,7 +231,8 @@ static void gtk_range_measure_trough (GtkGizmo *gizmo, gint *minimum_baseline, gint *natural_baseline); static void gtk_range_allocate_trough (GtkGizmo *gizmo, - const GtkAllocation *allocation, + int width, + int height, int baseline); static gboolean gtk_range_render_trough (GtkGizmo *gizmo, GtkSnapshot *snapshot); @@ -1388,9 +1390,10 @@ gtk_range_measure (GtkWidget *widget, } static void -gtk_range_allocate_trough (GtkGizmo *gizmo, - const GtkAllocation *allocation, - int baseline) +gtk_range_allocate_trough (GtkGizmo *gizmo, + int width, + int height, + int baseline) { GtkWidget *widget = gtk_widget_get_parent (GTK_WIDGET (gizmo)); GtkRange *range = GTK_RANGE (widget); @@ -1423,7 +1426,7 @@ gtk_range_allocate_trough (GtkGizmo *gizmo, double level, fill; GtkAllocation fill_alloc; - fill_alloc = *allocation; + fill_alloc = (GtkAllocation) {0, 0, width, height}; level = CLAMP (priv->fill_level, lower, upper - page_size); @@ -1434,14 +1437,14 @@ gtk_range_allocate_trough (GtkGizmo *gizmo, fill_alloc.width *= fill; if (should_invert (range)) - fill_alloc.x += allocation->width - fill_alloc.width; + fill_alloc.x += width - fill_alloc.width; } else { fill_alloc.height *= fill; if (should_invert (range)) - fill_alloc.y += allocation->height - fill_alloc.height; + fill_alloc.y += height - fill_alloc.height; } gtk_widget_size_allocate (priv->fill_widget, &fill_alloc, -1); @@ -1459,27 +1462,27 @@ gtk_range_allocate_trough (GtkGizmo *gizmo, if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { - highlight_alloc.y = allocation->y; - highlight_alloc.height = allocation->height; + highlight_alloc.y = 0; + highlight_alloc.height = height; if (!should_invert (range)) - highlight_alloc.x = allocation->x; + highlight_alloc.x = 0; else - highlight_alloc.x = allocation->x + (allocation->width * (1 - value)); + highlight_alloc.x = (width * (1 - value)); - highlight_alloc.width = MAX (min, allocation->width * value); + highlight_alloc.width = MAX (min, width * value); } else { - highlight_alloc.x = allocation->x; - highlight_alloc.width = allocation->width; + highlight_alloc.x = 0; + highlight_alloc.width = width; if (!should_invert (range)) - highlight_alloc.y = allocation->y; + highlight_alloc.y = 0; else - highlight_alloc.y = allocation->y + (allocation->height * (1 - value)); + highlight_alloc.y = (height * (1 - value)); - highlight_alloc.height = MAX (min, allocation->height* value); + highlight_alloc.height = MAX (min, height * value); } gtk_widget_size_allocate (priv->highlight_widget, &highlight_alloc, -1); @@ -1491,16 +1494,17 @@ gtk_range_allocate_trough (GtkGizmo *gizmo, * give space to border over dimensions in one direction. */ static void -clamp_dimensions (const GtkAllocation *allocation, - int *width, - int *height, - GtkBorder *border, - gboolean border_expands_horizontally) +clamp_dimensions (int range_width, + int range_height, + int *width, + int *height, + GtkBorder *border, + gboolean border_expands_horizontally) { gint extra, shortage; /* Width */ - extra = allocation->width - border->left - border->right - *width; + extra = range_width - border->left - border->right - *width; if (extra > 0) { if (border_expands_horizontally) @@ -1515,10 +1519,10 @@ clamp_dimensions (const GtkAllocation *allocation, } /* See if we can fit rect, if not kill the border */ - shortage = *width - allocation->width; + shortage = *width - range_width; if (shortage > 0) { - *width = allocation->width; + *width = range_width; /* lose the border */ border->left = 0; border->right = 0; @@ -1526,7 +1530,7 @@ clamp_dimensions (const GtkAllocation *allocation, else { /* See if we can fit rect with borders */ - shortage = *width + border->left + border->right - allocation->width; + shortage = *width + border->left + border->right - range_width; if (shortage > 0) { /* Shrink borders */ @@ -1536,7 +1540,7 @@ clamp_dimensions (const GtkAllocation *allocation, } /* Height */ - extra = allocation->height - border->top - border->bottom - *height; + extra = range_height - border->top - border->bottom - *height; if (extra > 0) { if (border_expands_horizontally) @@ -1552,10 +1556,10 @@ clamp_dimensions (const GtkAllocation *allocation, } /* See if we can fit rect, if not kill the border */ - shortage = *height - allocation->height; + shortage = *height - range_height; if (shortage > 0) { - *height = allocation->height; + *height = range_height; /* lose the border */ border->top = 0; border->bottom = 0; @@ -1563,7 +1567,7 @@ clamp_dimensions (const GtkAllocation *allocation, else { /* See if we can fit rect with borders */ - shortage = *height + border->top + border->bottom - allocation->height; + shortage = *height + border->top + border->bottom - range_height; if (shortage > 0) { /* Shrink borders */ @@ -1574,9 +1578,10 @@ clamp_dimensions (const GtkAllocation *allocation, } static void -gtk_range_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_range_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkRange *range = GTK_RANGE (widget); GtkRangePrivate *priv = gtk_range_get_instance_private (range); @@ -1597,9 +1602,9 @@ gtk_range_size_allocate (GtkWidget *widget, NULL, NULL); if (priv->orientation == GTK_ORIENTATION_VERTICAL) - clamp_dimensions (allocation, &box_min_width, &box_min_height, &border, TRUE); + clamp_dimensions (width, height, &box_min_width, &box_min_height, &border, TRUE); else - clamp_dimensions (allocation, &box_min_width, &box_min_height, &border, FALSE); + clamp_dimensions (width, height, &box_min_width, &box_min_height, &border, FALSE); box_alloc.x = border.left; box_alloc.y = border.top; diff --git a/gtk/gtkrevealer.c b/gtk/gtkrevealer.c index b0dfc0c691..92a33da868 100644 --- a/gtk/gtkrevealer.c +++ b/gtk/gtkrevealer.c @@ -97,9 +97,10 @@ static GParamSpec *props[LAST_PROP] = { NULL, }; static void gtk_revealer_real_add (GtkContainer *widget, GtkWidget *child); -static void gtk_revealer_real_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_revealer_real_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_revealer_measure (GtkWidget *widget, GtkOrientation orientation, int for_size, @@ -337,9 +338,10 @@ get_child_size_scale (GtkRevealer *revealer, } static void -gtk_revealer_real_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_revealer_real_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkRevealer *revealer = GTK_REVEALER (widget); GtkWidget *child; @@ -347,11 +349,9 @@ gtk_revealer_real_size_allocate (GtkWidget *widget, child = gtk_bin_get_child (GTK_BIN (revealer)); if (child != NULL && gtk_widget_get_visible (child)) { - GtkAllocation child_allocation; + GtkAllocation child_allocation = {0, 0, width, height}; double hscale, vscale; - child_allocation = *allocation; - hscale = get_child_size_scale (revealer, GTK_ORIENTATION_HORIZONTAL); vscale = get_child_size_scale (revealer, GTK_ORIENTATION_VERTICAL); @@ -364,15 +364,15 @@ gtk_revealer_real_size_allocate (GtkWidget *widget, else if (hscale < 1.0) { g_assert (vscale == 1.0); - child_allocation.width = MIN (G_MAXINT, ceil (child_allocation.width / hscale)); + child_allocation.width = MIN (G_MAXINT, ceil (width / hscale)); if (effective_transition (revealer) == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT) - child_allocation.x = allocation->width - child_allocation.width; + child_allocation.x = width - child_allocation.width; } else if (vscale < 1.0) { - child_allocation.height = MIN (G_MAXINT, ceil (child_allocation.height / vscale)); + child_allocation.height = MIN (G_MAXINT, ceil (height / vscale)); if (effective_transition (revealer) == GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN) - child_allocation.y = allocation->height - child_allocation.height; + child_allocation.y = height - child_allocation.height; } gtk_widget_size_allocate (child, &child_allocation, -1); } diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c index ca0ef436c6..ed2debbea7 100644 --- a/gtk/gtkscale.c +++ b/gtk/gtkscale.c @@ -409,9 +409,10 @@ gtk_scale_allocate_value (GtkScale *scale) } static void -gtk_scale_allocate_mark (GtkGizmo *gizmo, - const GtkAllocation *allocation, - int baseline) +gtk_scale_allocate_mark (GtkGizmo *gizmo, + int width, + int height, + int baseline) { GtkWidget *widget = GTK_WIDGET (gizmo); GtkScale *scale = GTK_SCALE (gtk_widget_get_parent (gtk_widget_get_parent (widget))); @@ -432,21 +433,22 @@ gtk_scale_allocate_mark (GtkGizmo *gizmo, if (orientation == GTK_ORIENTATION_HORIZONTAL) { - indicator_alloc.x = (allocation->width - indicator_width) / 2; + indicator_alloc.x = (width - indicator_width) / 2; if (mark->position == GTK_POS_TOP) - indicator_alloc.y = allocation->y + allocation->height - indicator_height; + indicator_alloc.y = height - indicator_height; else - indicator_alloc.y = allocation->y; + indicator_alloc.y = 0; + indicator_alloc.width = indicator_width; indicator_alloc.height = indicator_height; } else { if (mark->position == GTK_POS_TOP) - indicator_alloc.x = allocation->x + allocation->width - indicator_width; + indicator_alloc.x = width - indicator_width; else - indicator_alloc.x = allocation->x; - indicator_alloc.y = (allocation->height - indicator_height) / 2; + indicator_alloc.x = 0; + indicator_alloc.y = (height - indicator_height) / 2; indicator_alloc.width = indicator_width; indicator_alloc.height = indicator_height; } @@ -457,17 +459,17 @@ gtk_scale_allocate_mark (GtkGizmo *gizmo, { GtkAllocation label_alloc; - label_alloc = *allocation; + label_alloc = (GtkAllocation) {0, 0, width, height}; if (orientation == GTK_ORIENTATION_HORIZONTAL) { - label_alloc.height = allocation->height - indicator_alloc.height; + label_alloc.height = height - indicator_alloc.height; if (mark->position == GTK_POS_BOTTOM) label_alloc.y = indicator_alloc.y + indicator_alloc.height; } else { - label_alloc.width = allocation->width - indicator_alloc.width; + label_alloc.width = width - indicator_alloc.width; if (mark->position == GTK_POS_BOTTOM) label_alloc.x = indicator_alloc.x + indicator_alloc.width; } @@ -477,9 +479,10 @@ gtk_scale_allocate_mark (GtkGizmo *gizmo, } static void -gtk_scale_allocate_marks (GtkGizmo *gizmo, - const GtkAllocation *allocation, - int baseline) +gtk_scale_allocate_marks (GtkGizmo *gizmo, + int width, + int height, + int baseline) { GtkWidget *widget = GTK_WIDGET (gizmo); GtkScale *scale = GTK_SCALE (gtk_widget_get_parent (widget)); @@ -511,17 +514,17 @@ gtk_scale_allocate_marks (GtkGizmo *gizmo, if (orientation == GTK_ORIENTATION_HORIZONTAL) { mark_alloc.x = mark->stop_position; - mark_alloc.y = allocation->y; + mark_alloc.y = 0; mark_alloc.width = mark_size; - mark_alloc.height = allocation->height; + mark_alloc.height = height; mark_alloc.x -= mark_size / 2; } else { - mark_alloc.x = allocation->x; + mark_alloc.x = 0; mark_alloc.y = mark->stop_position; - mark_alloc.width = allocation->width; + mark_alloc.width = width; mark_alloc.height = mark_size; mark_alloc.y -= mark_size / 2; @@ -534,16 +537,17 @@ gtk_scale_allocate_marks (GtkGizmo *gizmo, } static void -gtk_scale_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_scale_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkScale *scale = GTK_SCALE (widget); GtkScalePrivate *priv = gtk_scale_get_instance_private (scale); GtkAllocation range_rect, marks_rect; GtkOrientation orientation; - GTK_WIDGET_CLASS (gtk_scale_parent_class)->size_allocate (widget, allocation, baseline); + GTK_WIDGET_CLASS (gtk_scale_parent_class)->size_allocate (widget, width, height, baseline); orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)); gtk_range_get_range_rect (GTK_RANGE (scale), &range_rect); diff --git a/gtk/gtkscrollbar.c b/gtk/gtkscrollbar.c index bb5076cc88..3c4be33b7a 100644 --- a/gtk/gtkscrollbar.c +++ b/gtk/gtkscrollbar.c @@ -120,14 +120,19 @@ gtk_scrollbar_measure (GtkWidget *widget, } static void -gtk_scrollbar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_scrollbar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkScrollbar *self = GTK_SCROLLBAR (widget); GtkScrollbarPrivate *priv = gtk_scrollbar_get_instance_private (self); - gtk_widget_size_allocate (priv->box, allocation, -1); + gtk_widget_size_allocate (priv->box, + &(GtkAllocation) { + 0, 0, + width, height + }, -1); } static void diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 61089c8268..3df15e3f4f 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -327,9 +327,10 @@ static void gtk_scrolled_window_get_property (GObject *objec static void gtk_scrolled_window_destroy (GtkWidget *widget); static void gtk_scrolled_window_snapshot (GtkWidget *widget, GtkSnapshot *snapshot); -static void gtk_scrolled_window_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_scrolled_window_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static gboolean gtk_scrolled_window_focus (GtkWidget *widget, GtkDirectionType direction); static void gtk_scrolled_window_add (GtkContainer *container, @@ -350,7 +351,8 @@ static void gtk_scrolled_window_allocate_scrollbar (GtkScrolledWindow *scrol GtkWidget *scrollbar, GtkAllocation *allocation); static void gtk_scrolled_window_allocate_child (GtkScrolledWindow *swindow, - const GtkAllocation *content_allocation); + int width, + int height); static void gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment, gpointer data); static void gtk_scrolled_window_adjustment_value_changed (GtkAdjustment *adjustment, @@ -1399,9 +1401,10 @@ gtk_scrolled_window_update_scrollbar_visibility_flags (GtkScrolledWindow *scroll } static void -gtk_scrolled_window_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_scrolled_window_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget); GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window); @@ -1459,41 +1462,38 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, * given the extra width of the scrollbar */ if (vscroll_policy == GTK_SCROLL_MINIMUM) gtk_widget_measure (child, GTK_ORIENTATION_VERTICAL, - MAX (allocation->width, child_scroll_width), + MAX (width, child_scroll_width), &child_scroll_height, NULL, NULL, NULL); else gtk_widget_measure (child, GTK_ORIENTATION_VERTICAL, - MAX (allocation->width, child_scroll_width), + MAX (width, child_scroll_width), NULL, &child_scroll_height, NULL, NULL); if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC) { /* Does the content height fit the allocation height ? */ - priv->vscrollbar_visible = child_scroll_height > allocation->height; + priv->vscrollbar_visible = child_scroll_height > height; /* Does the content width fit the allocation with minus a possible scrollbar ? */ - priv->hscrollbar_visible = - child_scroll_width > allocation->width - + priv->hscrollbar_visible = child_scroll_width > width - (priv->vscrollbar_visible && !priv->use_indicators ? sb_width : 0); /* Now that we've guessed the hscrollbar, does the content height fit * the possible new allocation height ? */ - priv->vscrollbar_visible = - child_scroll_height > allocation->height - + priv->vscrollbar_visible = child_scroll_height > height - (priv->hscrollbar_visible && !priv->use_indicators ? sb_height : 0); /* Now that we've guessed the vscrollbar, does the content width fit * the possible new allocation width ? */ - priv->hscrollbar_visible = - child_scroll_width > allocation->width - + priv->hscrollbar_visible = child_scroll_width > width - (priv->vscrollbar_visible && !priv->use_indicators ? sb_width : 0); } else /* priv->hscrollbar_policy != GTK_POLICY_AUTOMATIC */ { priv->hscrollbar_visible = policy_may_be_visible (priv->hscrollbar_policy); - priv->vscrollbar_visible = child_scroll_height > allocation->height - + priv->vscrollbar_visible = child_scroll_height > height - (priv->hscrollbar_visible && !priv->use_indicators ? sb_height : 0); } } @@ -1502,8 +1502,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, priv->vscrollbar_visible = policy_may_be_visible (priv->vscrollbar_policy); if (priv->hscrollbar_policy == GTK_POLICY_AUTOMATIC) - priv->hscrollbar_visible = - child_scroll_width > allocation->width - + priv->hscrollbar_visible = child_scroll_width > width - (priv->vscrollbar_visible && !priv->use_indicators ? 0 : sb_width); else priv->hscrollbar_visible = policy_may_be_visible (priv->hscrollbar_policy); @@ -1524,41 +1523,38 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, * given the extra height of the scrollbar */ if (hscroll_policy == GTK_SCROLL_MINIMUM) gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, - MAX (allocation->height, child_scroll_height), + MAX (height, child_scroll_height), &child_scroll_width, NULL, NULL, NULL); else gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, - MAX (allocation->height, child_scroll_height), + MAX (height, child_scroll_height), NULL, &child_scroll_width, NULL, NULL); if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC) { /* Does the content width fit the allocation width ? */ - priv->hscrollbar_visible = child_scroll_width > allocation->width; + priv->hscrollbar_visible = child_scroll_width > width; /* Does the content height fit the allocation with minus a possible scrollbar ? */ - priv->vscrollbar_visible = - child_scroll_height > allocation->height - + priv->vscrollbar_visible = child_scroll_height > height - (priv->hscrollbar_visible && !priv->use_indicators ? sb_height : 0); /* Now that we've guessed the vscrollbar, does the content width fit * the possible new allocation width ? */ - priv->hscrollbar_visible = - child_scroll_width > allocation->width - + priv->hscrollbar_visible = child_scroll_width > width - (priv->vscrollbar_visible && !priv->use_indicators ? sb_width : 0); /* Now that we've guessed the hscrollbar, does the content height fit * the possible new allocation height ? */ - priv->vscrollbar_visible = - child_scroll_height > allocation->height - + priv->vscrollbar_visible = child_scroll_height > height - (priv->hscrollbar_visible && !priv->use_indicators ? sb_height : 0); } else /* priv->vscrollbar_policy != GTK_POLICY_AUTOMATIC */ { priv->vscrollbar_visible = policy_may_be_visible (priv->vscrollbar_policy); - priv->hscrollbar_visible = child_scroll_width > allocation->width - + priv->hscrollbar_visible = child_scroll_width > width - (priv->vscrollbar_visible && !priv->use_indicators ? sb_width : 0); } } @@ -1567,8 +1563,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, priv->hscrollbar_visible = policy_may_be_visible (priv->hscrollbar_policy); if (priv->vscrollbar_policy == GTK_POLICY_AUTOMATIC) - priv->vscrollbar_visible = - child_scroll_height > allocation->height - + priv->vscrollbar_visible = child_scroll_height > height - (priv->hscrollbar_visible && !priv->use_indicators ? sb_height : 0); else priv->vscrollbar_visible = policy_may_be_visible (priv->vscrollbar_policy); @@ -1584,7 +1579,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, previous_hvis = priv->hscrollbar_visible; previous_vvis = priv->vscrollbar_visible; - gtk_scrolled_window_allocate_child (scrolled_window, allocation); + gtk_scrolled_window_allocate_child (scrolled_window, width, height); /* Explicitly force scrollbar visibility checks. * @@ -1611,7 +1606,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, priv->hscrollbar_visible = TRUE; priv->vscrollbar_visible = TRUE; - gtk_scrolled_window_allocate_child (scrolled_window, allocation); + gtk_scrolled_window_allocate_child (scrolled_window, width, height); break; } @@ -3037,7 +3032,8 @@ _gtk_scrolled_window_get_overshoot (GtkScrolledWindow *scrolled_window, static void gtk_scrolled_window_allocate_child (GtkScrolledWindow *swindow, - const GtkAllocation *content_allocation) + int width, + int height) { GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (swindow); GtkWidget *widget = GTK_WIDGET (swindow), *child; @@ -3047,7 +3043,7 @@ gtk_scrolled_window_allocate_child (GtkScrolledWindow *swindow, child = gtk_bin_get_child (GTK_BIN (widget)); - child_allocation = *content_allocation; + child_allocation = (GtkAllocation) {0, 0, width, height}; /* Get possible scrollbar dimensions */ gtk_widget_measure (priv->vscrollbar, GTK_ORIENTATION_HORIZONTAL, -1, diff --git a/gtk/gtksearchbar.c b/gtk/gtksearchbar.c index df91d8ef31..6ccd1ca0f0 100644 --- a/gtk/gtksearchbar.c +++ b/gtk/gtksearchbar.c @@ -392,14 +392,19 @@ gtk_search_bar_measure (GtkWidget *widget, } static void -gtk_search_bar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_search_bar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkSearchBar *bar = GTK_SEARCH_BAR (widget); GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); - gtk_widget_size_allocate (priv->revealer, allocation, baseline); + gtk_widget_size_allocate (priv->revealer, + &(GtkAllocation) { + 0, 0, + width, height + }, baseline); } static void diff --git a/gtk/gtkshortcutsshortcut.c b/gtk/gtkshortcutsshortcut.c index d1c222b32d..3e923a34e1 100644 --- a/gtk/gtkshortcutsshortcut.c +++ b/gtk/gtkshortcutsshortcut.c @@ -517,13 +517,18 @@ gtk_shortcuts_shortcut_snapshot (GtkWidget *widget, } static void -gtk_shortcuts_shortcut_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_shortcuts_shortcut_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { - GTK_WIDGET_CLASS (gtk_shortcuts_shortcut_parent_class)->size_allocate (widget, allocation, baseline); + GTK_WIDGET_CLASS (gtk_shortcuts_shortcut_parent_class)->size_allocate (widget, width, height, baseline); - gtk_widget_size_allocate (GTK_WIDGET (GTK_SHORTCUTS_SHORTCUT (widget)->box), allocation, -1); + gtk_widget_size_allocate (GTK_WIDGET (GTK_SHORTCUTS_SHORTCUT (widget)->box), + &(GtkAllocation) { + 0, 0, + width, height + }, -1); } static void diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index b891bec711..5bf431ee8e 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -258,9 +258,10 @@ static void gtk_spin_button_measure (GtkWidget *widget, int *natural, int *minimum_baseline, int *natural_baseline); -static void gtk_spin_button_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_spin_button_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_spin_button_grab_notify (GtkWidget *widget, gboolean was_grabbed); static void gtk_spin_button_state_flags_changed (GtkWidget *widget, @@ -1093,13 +1094,19 @@ gtk_spin_button_measure (GtkWidget *widget, } static void -gtk_spin_button_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_spin_button_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (GTK_SPIN_BUTTON (widget)); - gtk_widget_size_allocate (priv->box, allocation, baseline); + gtk_widget_size_allocate (priv->box, + &(GtkAllocation) { + 0, 0, + width, height + }, + baseline); } static void diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c index f74894b8e1..6017104be6 100644 --- a/gtk/gtkstack.c +++ b/gtk/gtkstack.c @@ -168,9 +168,10 @@ static void gtk_stack_forall (GtkContainer *contain static void gtk_stack_compute_expand (GtkWidget *widget, gboolean *hexpand, gboolean *vexpand); -static void gtk_stack_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_stack_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_stack_snapshot (GtkWidget *widget, GtkSnapshot *snapshot); static void gtk_stack_measure (GtkWidget *widget, @@ -2001,9 +2002,10 @@ gtk_stack_snapshot (GtkWidget *widget, } static void -gtk_stack_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_stack_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkStack *stack = GTK_STACK (widget); GtkStackPrivate *priv = gtk_stack_get_instance_private (stack); @@ -2019,11 +2021,11 @@ gtk_stack_size_allocate (GtkWidget *widget, gtk_widget_measure (priv->last_visible_child->widget, GTK_ORIENTATION_HORIZONTAL, -1, &min, &nat, NULL, NULL); - child_allocation.width = MAX (min, allocation->width); + child_allocation.width = MAX (min, width); gtk_widget_measure (priv->last_visible_child->widget, GTK_ORIENTATION_VERTICAL, child_allocation.width, &min, &nat, NULL, NULL); - child_allocation.height = MAX (min, allocation->height); + child_allocation.height = MAX (min, height); gtk_widget_size_allocate (priv->last_visible_child->widget, &child_allocation, -1); @@ -2034,8 +2036,8 @@ gtk_stack_size_allocate (GtkWidget *widget, } } - child_allocation.width = allocation->width; - child_allocation.height = allocation->height; + child_allocation.width = width; + child_allocation.height = height; if (priv->visible_child) { @@ -2043,31 +2045,31 @@ gtk_stack_size_allocate (GtkWidget *widget, int min_height; gtk_widget_measure (priv->visible_child->widget, GTK_ORIENTATION_HORIZONTAL, - allocation->height, &min_width, NULL, NULL, NULL); + height, &min_width, NULL, NULL, NULL); child_allocation.width = MAX (child_allocation.width, min_width); gtk_widget_measure (priv->visible_child->widget, GTK_ORIENTATION_VERTICAL, child_allocation.width, &min_height, NULL, NULL, NULL); child_allocation.height = MAX (child_allocation.height, min_height); - if (child_allocation.width > allocation->width) + if (child_allocation.width > width) { GtkAlign halign = gtk_widget_get_halign (priv->visible_child->widget); if (halign == GTK_ALIGN_CENTER || halign == GTK_ALIGN_FILL) - child_allocation.x = (allocation->width - child_allocation.width) / 2; + child_allocation.x = (width - child_allocation.width) / 2; else if (halign == GTK_ALIGN_END) - child_allocation.x = (allocation->width - child_allocation.width); + child_allocation.x = (width - child_allocation.width); } - if (child_allocation.height > allocation->height) + if (child_allocation.height > height) { GtkAlign valign = gtk_widget_get_valign (priv->visible_child->widget); if (valign == GTK_ALIGN_CENTER || valign == GTK_ALIGN_FILL) - child_allocation.y = (allocation->height - child_allocation.height) / 2; + child_allocation.y = (height - child_allocation.height) / 2; else if (valign == GTK_ALIGN_END) - child_allocation.y = (allocation->height - child_allocation.height); + child_allocation.y = (height - child_allocation.height); } gtk_widget_size_allocate (priv->visible_child->widget, &child_allocation, -1); diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c index ce4cada87f..ebf682c3d5 100644 --- a/gtk/gtkstatusbar.c +++ b/gtk/gtkstatusbar.c @@ -147,13 +147,18 @@ gtk_statusbar_measure (GtkWidget *widget, } static void -gtk_statusbar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_statusbar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkStatusbarPrivate *priv = gtk_statusbar_get_instance_private (GTK_STATUSBAR (widget)); - gtk_widget_size_allocate (priv->frame, allocation, baseline); + gtk_widget_size_allocate (priv->frame, + &(GtkAllocation) { + 0, 0, + width, height + }, baseline); } static void diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c index b02c7fdd04..f8c235fe69 100644 --- a/gtk/gtkswitch.c +++ b/gtk/gtkswitch.c @@ -316,9 +316,10 @@ gtk_switch_measure (GtkWidget *widget, } static void -gtk_switch_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_switch_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkSwitch *self = GTK_SWITCH (widget); GtkSwitchPrivate *priv = gtk_switch_get_instance_private (self); @@ -326,29 +327,29 @@ gtk_switch_size_allocate (GtkWidget *widget, GtkAllocation slider_alloc; int min; - slider_alloc.x = round (priv->handle_pos * (allocation->width / 2)); + slider_alloc.x = round (priv->handle_pos * (width / 2)); slider_alloc.y = 0; - slider_alloc.width = allocation->width / 2; - slider_alloc.height = allocation->height; + slider_alloc.width = width / 2; + slider_alloc.height = height; gtk_widget_size_allocate (priv->slider, &slider_alloc, -1); /* Center ON label in left half */ gtk_widget_measure (priv->on_label, GTK_ORIENTATION_HORIZONTAL, -1, &min, NULL, NULL, NULL); - child_alloc.x = ((allocation->width / 2) - min) / 2; + child_alloc.x = ((width / 2) - min) / 2; child_alloc.width = min; gtk_widget_measure (priv->on_label, GTK_ORIENTATION_VERTICAL, min, &min, NULL, NULL, NULL); - child_alloc.y = (allocation->height - min) / 2; + child_alloc.y = (height - min) / 2; child_alloc.height = min; gtk_widget_size_allocate (priv->on_label, &child_alloc, -1); /* Center OFF label in right half */ gtk_widget_measure (priv->off_label, GTK_ORIENTATION_HORIZONTAL, -1, &min, NULL, NULL, NULL); - child_alloc.x = (allocation->width / 2) + ((allocation->width / 2) - min) / 2; + child_alloc.x = (width / 2) + ((width / 2) - min) / 2; child_alloc.width = min; gtk_widget_measure (priv->off_label, GTK_ORIENTATION_VERTICAL, min, &min, NULL, NULL, NULL); - child_alloc.y = (allocation->height - min) / 2; + child_alloc.y = (height - min) / 2; child_alloc.height = min; gtk_widget_size_allocate (priv->off_label, &child_alloc, -1); } diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 357a7cb3b7..39063355ec 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -366,7 +366,8 @@ static void gtk_text_view_measure (GtkWidget *widget, int *minimum_baseline, int *natural_baseline); static void gtk_text_view_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, + int width, + int height, int baseline); static void gtk_text_view_realize (GtkWidget *widget); static void gtk_text_view_unrealize (GtkWidget *widget); @@ -4082,9 +4083,10 @@ gtk_text_view_allocate_children (GtkTextView *text_view) } static void -gtk_text_view_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_text_view_size_allocate (GtkWidget *widget, + int widget_width, + int widget_height, + int baseline) { GtkTextView *text_view; GtkTextViewPrivate *priv; @@ -4105,14 +4107,14 @@ gtk_text_view_size_allocate (GtkWidget *widget, */ left_rect.width = priv->border_window_size.left; right_rect.width = priv->border_window_size.right; - width = allocation->width - left_rect.width - right_rect.width; + width = widget_width - left_rect.width - right_rect.width; text_rect.width = MAX (1, width); top_rect.width = text_rect.width; bottom_rect.width = text_rect.width; top_rect.height = priv->border_window_size.top; bottom_rect.height = priv->border_window_size.bottom; - height = allocation->height - top_rect.height - bottom_rect.height; + height = widget_height - top_rect.height - bottom_rect.height; text_rect.height = MAX (1, height); left_rect.height = text_rect.height; right_rect.height = text_rect.height; diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index fdc4331157..3e1a1ee3c9 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -185,7 +185,8 @@ static void gtk_toolbar_get_property (GObject *object, static void gtk_toolbar_snapshot (GtkWidget *widget, GtkSnapshot *snapshot); static void gtk_toolbar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, + int width, + int height, int baseline); static void gtk_toolbar_style_updated (GtkWidget *widget); static gboolean gtk_toolbar_focus (GtkWidget *widget, @@ -1195,9 +1196,10 @@ rebuild_menu (GtkToolbar *toolbar) } static void -gtk_toolbar_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_toolbar_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkToolbar *toolbar = GTK_TOOLBAR (widget); GtkToolbarPrivate *priv = toolbar->priv; @@ -1223,14 +1225,14 @@ gtk_toolbar_size_allocate (GtkWidget *widget, if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { - available_size = size = allocation->width; - short_size = allocation->height; + available_size = size = width; + short_size = height; arrow_size = arrow_requisition.width; } else { - available_size = size = allocation->height; - short_size = allocation->width; + available_size = size = height; + short_size = width; arrow_size = arrow_requisition.height; } @@ -1393,22 +1395,6 @@ gtk_toolbar_size_allocate (GtkWidget *widget, fixup_allocation_for_rtl (available_size, &item_area); } - /* translate the items by allocation->(x,y) */ - for (i = 0; i < n_items; ++i) - { - allocations[i].x += allocation->x; - allocations[i].y += allocation->y; - } - - if (need_arrow) - { - arrow_allocation.x += allocation->x; - arrow_allocation.y += allocation->y; - } - - item_area.x += allocation->x; - item_area.y += allocation->y; - /* did anything change? */ for (list = priv->content, i = 0; list != NULL; list = list->next, i++) { diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 0926b0622f..036e66cbdc 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -592,9 +592,10 @@ static void gtk_tree_view_measure (GtkWidget *widget, int *natural, int *minimum_baseline, int *natural_baseline); -static void gtk_tree_view_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_tree_view_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_tree_view_snapshot (GtkWidget *widget, GtkSnapshot *snapshot); @@ -2540,9 +2541,10 @@ gtk_tree_view_size_allocate_drag_column (GtkWidget *widget) } static void -gtk_tree_view_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_tree_view_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkTreeView *tree_view = GTK_TREE_VIEW (widget); GList *tmp_list; @@ -2557,14 +2559,14 @@ gtk_tree_view_size_allocate (GtkWidget *widget, page_size = gtk_adjustment_get_page_size (tree_view->priv->vadjustment); gtk_adjustment_configure (tree_view->priv->hadjustment, gtk_adjustment_get_value (tree_view->priv->hadjustment) + - (_gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL ? allocation->width - page_size : 0), + (_gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL ? width - page_size : 0), 0, - MAX (allocation->width, tree_view->priv->width), - allocation->width * 0.1, - allocation->width * 0.9, - allocation->width); + MAX (width, tree_view->priv->width), + width * 0.1, + width * 0.9, + width); - page_size = allocation->height - gtk_tree_view_get_effective_header_height (tree_view); + page_size = height - gtk_tree_view_get_effective_header_height (tree_view); gtk_adjustment_configure (tree_view->priv->vadjustment, gtk_adjustment_get_value (tree_view->priv->vadjustment), 0, @@ -2654,9 +2656,9 @@ gtk_tree_view_size_allocate (GtkWidget *widget, * or top right corner (for LTR) */ min_x = gtk_adjustment_get_value (tree_view->priv->hadjustment); - max_x = min_x + allocation->width - child_rect.width; + max_x = min_x + width - child_rect.width; min_y = 0; - max_y = min_y + allocation->height - gtk_tree_view_get_effective_header_height (tree_view) - child_rect.height; + max_y = min_y + height - gtk_tree_view_get_effective_header_height (tree_view) - child_rect.height; if (direction == GTK_TEXT_DIR_LTR) /* Ensure that child's right edge is not sticking to the right diff --git a/gtk/gtkvideo.c b/gtk/gtkvideo.c index aa7a8869fd..3e46b4ec6d 100644 --- a/gtk/gtkvideo.c +++ b/gtk/gtkvideo.c @@ -119,13 +119,18 @@ gtk_video_measure (GtkWidget *widget, } static void -gtk_video_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_video_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkVideo *self = GTK_VIDEO (widget); - gtk_widget_size_allocate (self->box, allocation, baseline); + gtk_widget_size_allocate (self->box, + &(GtkAllocation) { + 0, 0, + width, height + }, baseline); } static void diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index 166ec771c1..d1f33c46fa 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -96,9 +96,10 @@ static void gtk_viewport_get_property (GObject *object, static void gtk_viewport_destroy (GtkWidget *widget); static void gtk_viewport_snapshot (GtkWidget *widget, GtkSnapshot *snapshot); -static void gtk_viewport_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_viewport_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment, gpointer data); static void viewport_set_adjustment (GtkViewport *viewport, @@ -521,9 +522,10 @@ gtk_viewport_snapshot (GtkWidget *widget, } static void -gtk_viewport_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_viewport_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkViewport *viewport = GTK_VIEWPORT (widget); GtkViewportPrivate *priv = gtk_viewport_get_instance_private (viewport); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 0ca54c1b3f..5ceda15ab5 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -574,9 +574,10 @@ static void gtk_widget_real_map (GtkWidget *widget); static void gtk_widget_real_unmap (GtkWidget *widget); static void gtk_widget_real_realize (GtkWidget *widget); static void gtk_widget_real_unrealize (GtkWidget *widget); -static void gtk_widget_real_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline); +static void gtk_widget_real_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline); static void gtk_widget_real_direction_changed(GtkWidget *widget, GtkTextDirection previous_direction); @@ -1477,8 +1478,9 @@ gtk_widget_class_init (GtkWidgetClass *klass) G_STRUCT_OFFSET (GtkWidgetClass, size_allocate), NULL, NULL, NULL, - G_TYPE_NONE, 2, - GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE, + G_TYPE_NONE, 3, + G_TYPE_INT, + G_TYPE_INT, G_TYPE_INT); /** @@ -4260,11 +4262,13 @@ gtk_widget_size_allocate (GtkWidget *widget, if (g_signal_has_handler_pending (widget, widget_signals[SIZE_ALLOCATE], 0, FALSE)) g_signal_emit (widget, widget_signals[SIZE_ALLOCATE], 0, - &real_allocation, + real_allocation.width, + real_allocation.height, baseline); else GTK_WIDGET_GET_CLASS (widget)->size_allocate (widget, - &real_allocation, + real_allocation.width, + real_allocation.height, baseline); /* Size allocation is god... after consulting god, no further requests or allocations are needed */ @@ -4520,9 +4524,10 @@ gtk_widget_translate_coordinatesf (GtkWidget *src_widget, } static void -gtk_widget_real_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_widget_real_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index b92ba1229d..44e779c71a 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -250,7 +250,8 @@ struct _GtkWidgetClass void (* realize) (GtkWidget *widget); void (* unrealize) (GtkWidget *widget); void (* size_allocate) (GtkWidget *widget, - const GtkAllocation *allocation, + int width, + int height, int baseline); void (* state_flags_changed) (GtkWidget *widget, GtkStateFlags previous_state_flags); diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index cffe43e686..1ae9f36a72 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -425,8 +425,9 @@ static void gtk_window_map (GtkWidget *widget); static void gtk_window_unmap (GtkWidget *widget); static void gtk_window_realize (GtkWidget *widget); static void gtk_window_unrealize (GtkWidget *widget); -static void gtk_window_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, +static void gtk_window_size_allocate (GtkWidget *widget, + int width, + int height, int baseline); static gboolean gtk_window_close_request (GtkWindow *window); static void gtk_window_focus_in (GtkWidget *widget); @@ -7136,7 +7137,8 @@ popover_size_allocate (GtkWindowPopover *popover, */ void _gtk_window_set_allocation (GtkWindow *window, - const GtkAllocation *allocation, + int width, + int height, GtkAllocation *allocation_out) { GtkWidget *widget = (GtkWidget *)window; @@ -7145,13 +7147,12 @@ _gtk_window_set_allocation (GtkWindow *window, GtkBorder window_border = { 0 }; GList *link; - g_assert (allocation != NULL); g_assert (allocation_out != NULL); child_allocation.x = 0; child_allocation.y = 0; - child_allocation.width = allocation->width; - child_allocation.height = allocation->height; + child_allocation.width = width; + child_allocation.height = height; get_shadow_width (window, &window_border); @@ -7170,9 +7171,7 @@ _gtk_window_set_allocation (GtkWindow *window, title_allocation.x = window_border.left; title_allocation.y = window_border.top; - title_allocation.width = - MAX (1, (gint) allocation->width - - window_border.left - window_border.right); + title_allocation.width = MAX (1, width - window_border.left - window_border.right); gtk_widget_measure (priv->title_box, GTK_ORIENTATION_VERTICAL, title_allocation.width, @@ -7196,9 +7195,7 @@ _gtk_window_set_allocation (GtkWindow *window, if (!_gtk_widget_is_toplevel (widget) && _gtk_widget_get_realized (widget)) { - gdk_surface_move_resize (_gtk_widget_get_surface (widget), - allocation->x, allocation->y, - allocation->width, allocation->height); + gdk_surface_move_resize (_gtk_widget_get_surface (widget), 0, 0, width, height); } *allocation_out = child_allocation; @@ -7212,15 +7209,16 @@ _gtk_window_set_allocation (GtkWindow *window, } static void -gtk_window_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_window_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkWindow *window = GTK_WINDOW (widget); GtkWidget *child; GtkAllocation child_allocation; - _gtk_window_set_allocation (window, allocation, &child_allocation); + _gtk_window_set_allocation (window, width, height, &child_allocation); child = gtk_bin_get_child (GTK_BIN (window)); if (child && gtk_widget_get_visible (child)) diff --git a/gtk/gtkwindowprivate.h b/gtk/gtkwindowprivate.h index d4fad9346c..1de4e0bedb 100644 --- a/gtk/gtkwindowprivate.h +++ b/gtk/gtkwindowprivate.h @@ -50,9 +50,10 @@ void _gtk_window_unset_focus_and_default (GtkWindow *window, void _gtk_window_set_is_active (GtkWindow *window, gboolean is_active); -void _gtk_window_set_allocation (GtkWindow *window, - const GtkAllocation *allocation, - GtkAllocation *allocation_out); +void _gtk_window_set_allocation (GtkWindow *window, + int width, + int height, + GtkAllocation *allocation_out); typedef void (*GtkWindowKeysForeachFunc) (GtkWindow *window, guint keyval, diff --git a/gtk/inspector/gtkstackcombo.c b/gtk/inspector/gtkstackcombo.c index cb837a6d09..451863ddca 100644 --- a/gtk/inspector/gtkstackcombo.c +++ b/gtk/inspector/gtkstackcombo.c @@ -240,12 +240,18 @@ gtk_stack_combo_measure (GtkWidget *widget, } static void -gtk_stack_combo_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_stack_combo_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkStackCombo *self = GTK_STACK_COMBO (widget); - gtk_widget_size_allocate (GTK_WIDGET (self->combo), allocation, baseline); + + gtk_widget_size_allocate (GTK_WIDGET (self->combo), + &(GtkAllocation) { + 0, 0, + width, height + }, baseline); } static void diff --git a/gtk/inspector/misc-info.c b/gtk/inspector/misc-info.c index 37aa839904..fc522ea6b1 100644 --- a/gtk/inspector/misc-info.c +++ b/gtk/inspector/misc-info.c @@ -134,7 +134,8 @@ state_flags_changed (GtkWidget *w, GtkStateFlags old_flags, GtkInspectorMiscInfo static void allocation_changed (GtkWidget *w, - GdkRectangle *allocation, + int width, + int height, int baseline, GtkInspectorMiscInfo *sl) { @@ -442,7 +443,7 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl, state_flags_changed (GTK_WIDGET (sl->priv->object), 0, sl); g_signal_connect_object (object, "size-allocate", G_CALLBACK (allocation_changed), sl, 0); - allocation_changed (GTK_WIDGET (sl->priv->object), NULL, -1, sl); + allocation_changed (GTK_WIDGET (sl->priv->object), 0, 0, -1, sl); } else { diff --git a/tests/testwidgetfocus.c b/tests/testwidgetfocus.c index de179d4b35..323050e461 100644 --- a/tests/testwidgetfocus.c +++ b/tests/testwidgetfocus.c @@ -88,13 +88,14 @@ GType gtk_focus_widget_get_type (void) G_GNUC_CONST; G_DEFINE_TYPE(GtkFocusWidget, gtk_focus_widget, GTK_TYPE_WIDGET) static void -gtk_focus_widget_size_allocate (GtkWidget *widget, - const GtkAllocation *allocation, - int baseline) +gtk_focus_widget_size_allocate (GtkWidget *widget, + int width, + int height, + int baseline) { GtkFocusWidget *self = GTK_FOCUS_WIDGET (widget); - int child_width = (allocation->width) / 2; - int child_height = (allocation->height) / 2; + int child_width = width / 2; + int child_height = height / 2; GtkAllocation child_alloc; child_alloc.x = 0;