gtkscrolledwindow: Add fixed multiplier to scroll events in surface units

The expected configurability is not going to arrive yet from compositors, and
it is precipitate for GTK to gain any configurability. We do know a factor of 1
feels way too slow, and we do know a factor of page_size * pow (2 / 3) feels way
way too fast.

With the previous multiplier, gtk4-demo at its default size had a vertical textview
factor of 64.332901, and maximized on a 1920x1080 screen a factor of 97.585365.
Pick a magic multiplier that is both significantly below these values and above 1,
and stick to it.

Future work will add the configurability of smooth scroll events where it belongs.
At that point this commit may be reverted so we don't pile up on magic numbers again.

Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/4793
This commit is contained in:
Carlos Garnacho 2022-08-05 17:13:28 +02:00
parent adba0b972e
commit c68247f63b

View File

@ -201,6 +201,8 @@
/* Scrolled off indication */
#define UNDERSHOOT_SIZE 40
#define MAGIC_SCROLL_FACTOR (42 / 7 / 1.618033 * 2.718281)
typedef struct _GtkScrolledWindowClass GtkScrolledWindowClass;
struct _GtkScrolledWindow
@ -1376,6 +1378,8 @@ scrolled_window_scroll (GtkScrolledWindow *scrolled_window,
delta_x *= get_wheel_detent_scroll_step (scrolled_window,
GTK_ORIENTATION_HORIZONTAL);
}
else if (scroll_unit == GDK_SCROLL_UNIT_SURFACE)
delta_x *= MAGIC_SCROLL_FACTOR;
new_value = priv->unclamped_hadj_value + delta_x;
_gtk_scrolled_window_set_adjustment_value (scrolled_window, adj,
@ -1397,6 +1401,8 @@ scrolled_window_scroll (GtkScrolledWindow *scrolled_window,
delta_y *= get_wheel_detent_scroll_step (scrolled_window,
GTK_ORIENTATION_VERTICAL);
}
else if (scroll_unit == GDK_SCROLL_UNIT_SURFACE)
delta_y *= MAGIC_SCROLL_FACTOR;
new_value = priv->unclamped_vadj_value + delta_y;
_gtk_scrolled_window_set_adjustment_value (scrolled_window, adj,
@ -1471,6 +1477,11 @@ scroll_controller_decelerate (GtkEventControllerScroll *scroll,
initial_vel_y *= get_wheel_detent_scroll_step (scrolled_window,
GTK_ORIENTATION_VERTICAL);
}
else
{
initial_vel_x *= MAGIC_SCROLL_FACTOR;
initial_vel_y *= MAGIC_SCROLL_FACTOR;
}
gtk_scrolled_window_decelerate (scrolled_window,
initial_vel_x,