rtgui/thumbbrowserbase - 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 thumbnails

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-27 17:44:35 -04:00
parent a5cba6261a
commit a060b57ff6

View File

@ -79,10 +79,19 @@ void ThumbBrowserBase::scroll (int direction, double deltaX, double deltaY)
delta = deltaY;
}
if (direction == GDK_SCROLL_SMOOTH && delta == 0.0) {
// sometimes this case happens. To avoid scrolling the wrong direction in this case, we just do nothing
// sometimes this case happens. To avoid scrolling the wrong direction in this case, we just do nothing
// This is probably no longer necessary now that coef is no longer quantized to +/-1.0 but why waste CPU cycles?
return;
}
double coef = direction == GDK_SCROLL_DOWN || (direction == GDK_SCROLL_SMOOTH && delta > 0.0) ? +1.0 : -1.0;
//GDK_SCROLL_SMOOTH can come in as many events with small deltas, don't quantize these to +/-1.0 so trackpads work well
double coef;
if(direction == GDK_SCROLL_SMOOTH) {
coef = delta;
} else if (direction == GDK_SCROLL_DOWN) {
coef = +1.0;
} else {
coef = -1.0;
}
// GUI already acquired when here
if (direction == GDK_SCROLL_UP || direction == GDK_SCROLL_DOWN || direction == GDK_SCROLL_SMOOTH) {