Revert "Add scaling adjustment for touch dragging a scrolled window"

This reverts commit d4943ef2fb.

This commit has broken scrolling in GtkTreeView. VTE has
`scroll-unit-pixels` property now, so the original issue is fixed
separately.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3707
This commit is contained in:
Alexander Mikhaylenko 2021-03-03 15:04:32 +05:00
parent 48de9796c2
commit d0cf3007c6

View File

@ -1005,9 +1005,7 @@ scrolled_window_drag_update_cb (GtkScrolledWindow *scrolled_window,
GtkScrolledWindowPrivate *priv = scrolled_window->priv; GtkScrolledWindowPrivate *priv = scrolled_window->priv;
GtkAdjustment *hadjustment; GtkAdjustment *hadjustment;
GtkAdjustment *vadjustment; GtkAdjustment *vadjustment;
GtkScrollable *child; gdouble dx, dy;
GtkBorder border;
double dx, dy, scale, size;
gtk_scrolled_window_invalidate_overshoot (scrolled_window); gtk_scrolled_window_invalidate_overshoot (scrolled_window);
@ -1020,25 +1018,10 @@ scrolled_window_drag_update_cb (GtkScrolledWindow *scrolled_window,
GTK_EVENT_SEQUENCE_CLAIMED); GTK_EVENT_SEQUENCE_CLAIMED);
} }
child = GTK_SCROLLABLE (gtk_bin_get_child (GTK_BIN (scrolled_window)));
hadjustment = gtk_range_get_adjustment (GTK_RANGE (priv->hscrollbar)); hadjustment = gtk_range_get_adjustment (GTK_RANGE (priv->hscrollbar));
if (hadjustment && may_hscroll (scrolled_window)) if (hadjustment && may_hscroll (scrolled_window))
{ {
if (child && gtk_widget_get_visible (child)) dx = priv->drag_start_x - offset_x;
{
size = gtk_widget_get_allocated_width (GTK_WIDGET (child));
if (gtk_scrollable_get_border (child, &border))
size -= border.left + border.right;
scale = gtk_adjustment_get_page_size (hadjustment) / size;
}
else
{
scale = 1.0;
}
dx = priv->drag_start_x - offset_x * scale;
_gtk_scrolled_window_set_adjustment_value (scrolled_window, _gtk_scrolled_window_set_adjustment_value (scrolled_window,
hadjustment, dx); hadjustment, dx);
} }
@ -1046,20 +1029,7 @@ scrolled_window_drag_update_cb (GtkScrolledWindow *scrolled_window,
vadjustment = gtk_range_get_adjustment (GTK_RANGE (priv->vscrollbar)); vadjustment = gtk_range_get_adjustment (GTK_RANGE (priv->vscrollbar));
if (vadjustment && may_vscroll (scrolled_window)) if (vadjustment && may_vscroll (scrolled_window))
{ {
if (child && gtk_widget_get_visible (child)) dy = priv->drag_start_y - offset_y;
{
size = gtk_widget_get_allocated_height (GTK_WIDGET (child));
if (gtk_scrollable_get_border (child, &border))
size -= border.top + border.bottom;
scale = gtk_adjustment_get_page_size (vadjustment) / size;
}
else
{
scale = 1.0;
}
dy = priv->drag_start_y - offset_y * scale;
_gtk_scrolled_window_set_adjustment_value (scrolled_window, _gtk_scrolled_window_set_adjustment_value (scrolled_window,
vadjustment, dy); vadjustment, dy);
} }