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.
This commit is contained in:
Andy Dodd
2019-08-28 18:19:53 -04:00
parent a060b57ff6
commit dadf01fe95

View File

@@ -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<double>(value + (event->delta_y > 0 ? step : -step), lowerBound, upperBound);
}
value2 = rtengine::LIM<double>(value + event->delta_y * step, lowerBound, upperBound);
if (value2 != value) {
scroll->set_value(value2);
}