Commit ade171a2 authored by Timm Bäder's avatar Timm Bäder 🤔
Browse files

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.
parent 1f1306a5
Pipeline #40526 passed with stages
in 24 minutes and 29 seconds
......@@ -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)
......
......@@ -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;
......
......@@ -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
......
......@@ -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);
}
}
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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))
{
......
......@@ -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
......
......@@ -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) */
......
......@@ -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);
}