diff --git a/README.in b/README.in index 2bc3209a91..9f8198bcdf 100644 --- a/README.in +++ b/README.in @@ -69,11 +69,15 @@ Release notes for 2.14 to GTK_SENSITIVITY_ON, so that the button is always sensitive or GTK_SENSITIVITY_OFF to make it insensitive respectively. -* GtkAdjustment now enforces that values are restricted to the - range [lower, upper - page_size]. This has always been the documented - behaviour, and the recommended practice is to set page_size to 0 - when using adjustments for simple scalar values, like in a slider - or spin button. +* In the early 2.14.x releases, GtkAdjustment was changed to enforce + that values are restricted to the range [lower, upper - page_size]. + This has always been the documented behaviour, and the recommended + practice is to set page_size to 0 when using adjustments for simple + scalar values, like in a slider or spin button. + Due to the large number of applications that are affected by this + change, the behaviour has been reverted to the old behaviour in + 2.14.3, with an explicit warning that this change will be + reintroduced in 2.90. * gdk-pixbuf will use GIO for mime type detection if possible. For this to work, shared-mime-info needs to be installed and XDG_DATA_DIRS diff --git a/gtk/gtkadjustment.c b/gtk/gtkadjustment.c index dd1b3f609d..49f5008ec2 100644 --- a/gtk/gtkadjustment.c +++ b/gtk/gtkadjustment.c @@ -359,11 +359,7 @@ gtk_adjustment_set_value (GtkAdjustment *adjustment, { g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); - /* don't use CLAMP() so we don't end up below lower if upper - page_size - * is smaller than lower - */ - value = MIN (value, adjustment->upper - adjustment->page_size); - value = MAX (value, adjustment->lower); + value = CLAMP (value, adjustment->lower, adjustment->upper); if (value != adjustment->value) { diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index 57a975d0ef..eb669a031a 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -4018,13 +4018,13 @@ gtk_combo_box_list_auto_scroll (GtkComboBox *combo_box, adj->lower < adj->value) { value = adj->value - (tree_view->allocation.x - x + 1); - gtk_adjustment_set_value (adj, value); + gtk_adjustment_set_value (adj, CLAMP (value, adj->lower, adj->upper - adj->page_size)); } else if (x >= tree_view->allocation.x + tree_view->allocation.width && adj->upper - adj->page_size > adj->value) { value = adj->value + (x - tree_view->allocation.x - tree_view->allocation.width + 1); - gtk_adjustment_set_value (adj, MAX (value, 0.0)); + gtk_adjustment_set_value (adj, CLAMP (value, 0.0, adj->upper - adj->page_size)); } } @@ -4035,13 +4035,13 @@ gtk_combo_box_list_auto_scroll (GtkComboBox *combo_box, adj->lower < adj->value) { value = adj->value - (tree_view->allocation.y - y + 1); - gtk_adjustment_set_value (adj, value); + gtk_adjustment_set_value (adj, CLAMP (value, adj->lower, adj->upper - adj->page_size)); } else if (y >= tree_view->allocation.height && adj->upper - adj->page_size > adj->value) { value = adj->value + (y - tree_view->allocation.height + 1); - gtk_adjustment_set_value (adj, MAX (value, 0.0)); + gtk_adjustment_set_value (adj, CLAMP (value, 0.0, adj->upper - adj->page_size)); } } } diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index aa1d16efc3..3a413f0ed2 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -1471,7 +1471,7 @@ gtk_icon_view_size_allocate (GtkWidget *widget, hadjustment->upper = MAX (allocation->width, icon_view->priv->width); if (hadjustment->value > hadjustment->upper - hadjustment->page_size) - gtk_adjustment_set_value (hadjustment, hadjustment->upper - hadjustment->page_size); + gtk_adjustment_set_value (hadjustment, MAX (0, hadjustment->upper - hadjustment->page_size)); vadjustment->page_size = allocation->height; vadjustment->page_increment = allocation->height * 0.9; @@ -1480,7 +1480,7 @@ gtk_icon_view_size_allocate (GtkWidget *widget, vadjustment->upper = MAX (allocation->height, icon_view->priv->height); if (vadjustment->value > vadjustment->upper - vadjustment->page_size) - gtk_adjustment_set_value (vadjustment, vadjustment->upper - vadjustment->page_size); + gtk_adjustment_set_value (vadjustment, MAX (0, vadjustment->upper - vadjustment->page_size)); if (GTK_WIDGET_REALIZED (widget) && icon_view->priv->scroll_to_path) @@ -1638,11 +1638,17 @@ gtk_icon_view_expose (GtkWidget *widget, static gboolean rubberband_scroll_timeout (gpointer data) { - GtkIconView *icon_view = data; + GtkIconView *icon_view; + gdouble value; - gtk_adjustment_set_value (icon_view->priv->vadjustment, - icon_view->priv->vadjustment->value + - icon_view->priv->scroll_value_diff); + icon_view = data; + + value = MIN (icon_view->priv->vadjustment->value + + icon_view->priv->scroll_value_diff, + icon_view->priv->vadjustment->upper - + icon_view->priv->vadjustment->page_size); + + gtk_adjustment_set_value (icon_view->priv->vadjustment, value); gtk_icon_view_update_rubberband (icon_view); @@ -4346,7 +4352,7 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view, { gint x, y; gint focus_width; - gfloat offset; + gfloat offset, value; gtk_widget_style_get (GTK_WIDGET (icon_view), "focus-line-width", &focus_width, @@ -4356,15 +4362,17 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view, offset = y + item->y - focus_width - row_align * (GTK_WIDGET (icon_view)->allocation.height - item->height); - - gtk_adjustment_set_value (icon_view->priv->vadjustment, - icon_view->priv->vadjustment->value + offset); + value = CLAMP (icon_view->priv->vadjustment->value + offset, + icon_view->priv->vadjustment->lower, + icon_view->priv->vadjustment->upper - icon_view->priv->vadjustment->page_size); + gtk_adjustment_set_value (icon_view->priv->vadjustment, value); offset = x + item->x - focus_width - col_align * (GTK_WIDGET (icon_view)->allocation.width - item->width); - - gtk_adjustment_set_value (icon_view->priv->hadjustment, - icon_view->priv->hadjustment->value + offset); + value = CLAMP (icon_view->priv->hadjustment->value + offset, + icon_view->priv->hadjustment->lower, + icon_view->priv->hadjustment->upper - icon_view->priv->hadjustment->page_size); + gtk_adjustment_set_value (icon_view->priv->hadjustment, value); gtk_adjustment_changed (icon_view->priv->hadjustment); gtk_adjustment_changed (icon_view->priv->vadjustment); @@ -6404,6 +6412,7 @@ gtk_icon_view_autoscroll (GtkIconView *icon_view) { gint px, py, x, y, width, height; gint hoffset, voffset; + gfloat value; gdk_window_get_pointer (GTK_WIDGET (icon_view)->window, &px, &py, NULL); gdk_window_get_geometry (GTK_WIDGET (icon_view)->window, &x, &y, &width, &height, NULL); @@ -6418,12 +6427,19 @@ gtk_icon_view_autoscroll (GtkIconView *icon_view) hoffset = MAX (px - (x + width - 2 * SCROLL_EDGE_SIZE), 0); if (voffset != 0) - gtk_adjustment_set_value (icon_view->priv->vadjustment, - icon_view->priv->vadjustment->value + voffset); - + { + value = CLAMP (icon_view->priv->vadjustment->value + voffset, + icon_view->priv->vadjustment->lower, + icon_view->priv->vadjustment->upper - icon_view->priv->vadjustment->page_size); + gtk_adjustment_set_value (icon_view->priv->vadjustment, value); + } if (hoffset != 0) - gtk_adjustment_set_value (icon_view->priv->hadjustment, - icon_view->priv->hadjustment->value + hoffset); + { + value = CLAMP (icon_view->priv->hadjustment->value + hoffset, + icon_view->priv->hadjustment->lower, + icon_view->priv->hadjustment->upper - icon_view->priv->hadjustment->page_size); + gtk_adjustment_set_value (icon_view->priv->hadjustment, value); + } } diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 0c1b313b5a..ce4e5e4282 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -990,6 +990,9 @@ gtk_range_set_range (GtkRange *range, value = MIN (value, MAX (range->adjustment->lower, range->layout->fill_level)); + value = CLAMP (value, range->adjustment->lower, + (range->adjustment->upper - range->adjustment->page_size)); + gtk_adjustment_set_value (range->adjustment, value); gtk_adjustment_changed (range->adjustment); } @@ -1014,6 +1017,9 @@ gtk_range_set_value (GtkRange *range, value = MIN (value, MAX (range->adjustment->lower, range->layout->fill_level)); + value = CLAMP (value, range->adjustment->lower, + (range->adjustment->upper - range->adjustment->page_size)); + gtk_adjustment_set_value (range->adjustment, value); } diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index b1b4184396..e1ef6333bb 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -1190,6 +1190,8 @@ gtk_scrolled_window_scroll_child (GtkScrolledWindow *scrolled_window, break; } + value = CLAMP (value, adjustment->lower, adjustment->upper - adjustment->page_size); + gtk_adjustment_set_value (adjustment, value); return TRUE; @@ -1573,11 +1575,13 @@ gtk_scrolled_window_scroll_event (GtkWidget *widget, if (range && GTK_WIDGET_VISIBLE (range)) { GtkAdjustment *adj = GTK_RANGE (range)->adjustment; - gdouble delta; + gdouble delta, new_value; delta = _gtk_range_get_wheel_delta (GTK_RANGE (range), event->direction); - gtk_adjustment_set_value (adj, adj->value + delta); + new_value = CLAMP (adj->value + delta, adj->lower, adj->upper - adj->page_size); + + gtk_adjustment_set_value (adj, new_value); return TRUE; } diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 836214b97b..a61ea841ec 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -1692,6 +1692,13 @@ gtk_spin_button_new_with_range (gdouble min, return GTK_WIDGET (spin); } +static void +warn_nonzero_page_size (GtkAdjustment *adjustment) +{ + if (gtk_adjustment_get_page_size (adjustment) != 0.0) + g_warning ("GtkSpinButton: setting an adjustment with non-zero page size is deprecated"); +} + /* Callback used when the spin button's adjustment changes. We need to redraw * the arrows when the adjustment's range changes, and reevaluate our size request. */ @@ -1703,6 +1710,7 @@ adjustment_changed_cb (GtkAdjustment *adjustment, gpointer data) spin_button = GTK_SPIN_BUTTON (data); spin_button->timer_step = spin_button->adjustment->step_increment; + warn_nonzero_page_size (adjustment); gtk_widget_queue_resize (GTK_WIDGET (spin_button)); } @@ -1742,6 +1750,7 @@ gtk_spin_button_set_adjustment (GtkSpinButton *spin_button, G_CALLBACK (adjustment_changed_cb), spin_button); spin_button->timer_step = spin_button->adjustment->step_increment; + warn_nonzero_page_size (adjustment); } gtk_widget_queue_resize (GTK_WIDGET (spin_button)); diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 5078cdb8dc..caa517c07a 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -3620,6 +3620,7 @@ gtk_tree_view_vertical_autoscroll (GtkTreeView *tree_view) GdkRectangle visible_rect; gint y; gint offset; + gfloat value; gdk_window_get_pointer (tree_view->priv->bin_window, NULL, &y, NULL); y += tree_view->priv->dy; @@ -3635,8 +3636,9 @@ gtk_tree_view_vertical_autoscroll (GtkTreeView *tree_view) return; } - gtk_adjustment_set_value (tree_view->priv->vadjustment, - MAX (tree_view->priv->vadjustment->value + offset, 0.0)); + value = CLAMP (tree_view->priv->vadjustment->value + offset, 0.0, + tree_view->priv->vadjustment->upper - tree_view->priv->vadjustment->page_size); + gtk_adjustment_set_value (tree_view->priv->vadjustment, value); } static gboolean @@ -3645,6 +3647,7 @@ gtk_tree_view_horizontal_autoscroll (GtkTreeView *tree_view) GdkRectangle visible_rect; gint x; gint offset; + gfloat value; gdk_window_get_pointer (tree_view->priv->bin_window, &x, NULL, NULL); @@ -3660,8 +3663,9 @@ gtk_tree_view_horizontal_autoscroll (GtkTreeView *tree_view) } offset = offset/3; - gtk_adjustment_set_value (tree_view->priv->hadjustment, - MAX (tree_view->priv->hadjustment->value + offset, 0.0)); + value = CLAMP (tree_view->priv->hadjustment->value + offset, + 0.0, tree_view->priv->hadjustment->upper - tree_view->priv->hadjustment->page_size); + gtk_adjustment_set_value (tree_view->priv->hadjustment, value); return TRUE; @@ -8964,7 +8968,11 @@ gtk_tree_view_clamp_column_visible (GtkTreeView *tree_view, } } - gtk_adjustment_set_value (tree_view->priv->hadjustment, x); + gtk_adjustment_set_value (tree_view->priv->hadjustment, + CLAMP (x, + tree_view->priv->hadjustment->lower, + tree_view->priv->hadjustment->upper + - tree_view->priv->hadjustment->page_size)); } else { @@ -11613,9 +11621,9 @@ gtk_tree_view_scroll_to_point (GtkTreeView *tree_view, vadj = tree_view->priv->vadjustment; if (tree_x != -1) - gtk_adjustment_set_value (hadj, tree_x); + gtk_adjustment_set_value (hadj, CLAMP (tree_x, hadj->lower, hadj->upper - hadj->page_size)); if (tree_y != -1) - gtk_adjustment_set_value (vadj, tree_y); + gtk_adjustment_set_value (vadj, CLAMP (tree_y, vadj->lower, vadj->upper - vadj->page_size)); } /**