From dadf01fe95b9f7ef61226703b1071e037dd553d1 Mon Sep 17 00:00:00 2001 From: Andy Dodd Date: Wed, 28 Aug 2019 18:19:53 -0400 Subject: [PATCH] rtgui/guiutils - Improve behavior with smooth scrolling devices Devices such as trackpads will emit smooth scrolling (GDK_SMOOTH_SCROLL) events with deltas smaller than +/-1.0 at high frequency. Quantizing these to +/-1.0 leads to significant amplification of scroll speed to the point of unusability Scroll by delta instead of +/-1.0 in these cases, permitting smooth scrolling through panels that use this code Some mice emit GDK_SMOOTH_SCROLL with deltas of +/-1.0 per detent. This patch will not change behavior with such devices. However, if any mice emit deltas of smaller magnitude, the per-detent behavior will change. --- rtgui/guiutils.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rtgui/guiutils.cc b/rtgui/guiutils.cc index ec0bf6588..19762fd92 100644 --- a/rtgui/guiutils.cc +++ b/rtgui/guiutils.cc @@ -971,9 +971,8 @@ bool MyScrolledWindow::on_scroll_event (GdkEventScroll* event) scroll->set_value(value2); } } else if (event->direction == GDK_SCROLL_SMOOTH) { - if (abs(event->delta_y) > 0.1) { - value2 = rtengine::LIM(value + (event->delta_y > 0 ? step : -step), lowerBound, upperBound); - } + value2 = rtengine::LIM(value + event->delta_y * step, lowerBound, upperBound); + if (value2 != value) { scroll->set_value(value2); }