[gtk/wip/carlosg/fixes: 8/8] gtkscrolledwindow: Add fixed multiplier to scroll events in surface units
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/fixes: 8/8] gtkscrolledwindow: Add fixed multiplier to scroll events in surface units
- Date: Sat, 6 Aug 2022 00:01:05 +0000 (UTC)
commit 1afe6b8fc6c8d677399dd68962af03fc8183982b
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Aug 5 17:13:28 2022 +0200
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
gtk/gtkscrolledwindow.c | 6 ++++++
1 file changed, 6 insertions(+)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index d2768d3ae0..1db8797d79 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -201,6 +201,8 @@
/* Scrolled off indication */
#define UNDERSHOOT_SIZE 40
+#define MAGIC_NUMBER 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_NUMBER;
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_NUMBER;
new_value = priv->unclamped_vadj_value + delta_y;
_gtk_scrolled_window_set_adjustment_value (scrolled_window, adj,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]