[gtk/gtk-3-24] gtk: fix wheel scrolling for very small adjustment page_size
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-24] gtk: fix wheel scrolling for very small adjustment page_size
- Date: Tue, 12 Jun 2018 17:00:44 +0000 (UTC)
commit c0ba041c73214f82d2c32b2ca1fa8f3c388c6170
Author: Michael Natterer <mitch gimp org>
Date: Mon Jun 11 18:36:50 2018 +0200
gtk: fix wheel scrolling for very small adjustment page_size
For very small page sizes of < 1.0, the effect of pow() is the
opposite of what's intended and the scroll steps become unusably
large, make sure we never get a scroll_unit larger than page_size /
2.0, which used to be the default before the pow() magic was
introduced.
gtk/gtkrange.c | 12 +++++++++++-
gtk/gtkscrolledwindow.c | 6 +++++-
2 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index dc495631cb..c106102929 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -3061,7 +3061,17 @@ _gtk_range_get_wheel_delta (GtkRange *range,
page_increment = gtk_adjustment_get_page_increment (adjustment);
if (GTK_IS_SCROLLBAR (range))
- scroll_unit = pow (page_size, 2.0 / 3.0);
+ {
+ gdouble pow_unit = pow (page_size, 2.0 / 3.0);
+
+ /* for very small page sizes of < 1.0, the effect of pow() is
+ * the opposite of what's intended and the scroll steps become
+ * unusably large, make sure we never get a scroll_unit larger
+ * than page_size / 2.0, which used to be the default before the
+ * pow() magic was introduced.
+ */
+ scroll_unit = MIN (pow_unit, page_size / 2.0);
+ }
else
scroll_unit = page_increment;
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 8112cfd8e3..b390f9d42e 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1296,6 +1296,7 @@ get_scroll_unit (GtkScrolledWindow *sw,
GtkRange *scrollbar;
GtkAdjustment *adj;
gdouble page_size;
+ gdouble pow_unit;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
scrollbar = GTK_RANGE (priv->hscrollbar);
@@ -1307,7 +1308,10 @@ get_scroll_unit (GtkScrolledWindow *sw,
adj = gtk_range_get_adjustment (scrollbar);
page_size = gtk_adjustment_get_page_size (adj);
- scroll_unit = pow (page_size, 2.0 / 3.0);
+
+ /* see comment in _gtk_range_get_wheel_delta() */
+ pow_unit = pow (page_size, 2.0 / 3.0);
+ scroll_unit = MIN (pow_unit, page_size / 2.0);
#else
scroll_unit = 1;
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]