summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qapplication_mac.mm26
-rw-r--r--src/gui/widgets/qabstractslider.cpp3
2 files changed, 23 insertions, 6 deletions
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index a95ae9d..f9c8aa3 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -1708,12 +1708,30 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
sizeof(axis), 0, &axis);
// The 'new' event has acceleration applied by the OS, while the old (on
- // Carbon only), has not. So we introduce acceleration here to be consistent:
- int scrollFactor = 120 * qMin(5, qAbs(mdelt));
+ // Carbon only), has not. So we introduce acceleration here to be consistent.
+ // The acceleration is trying to respect both pixel based and line scrolling,
+ // which turns out to be rather difficult.
+ int linesToScroll = mdelt > 0 ? 1 : -1;
+ static QTime t;
+ int elapsed = t.elapsed();
+ t.restart();
+ if (elapsed < 20)
+ linesToScroll *= 120;
+ else if (elapsed < 30)
+ linesToScroll *= 60;
+ else if (elapsed < 50)
+ linesToScroll *= 30;
+ else if (elapsed < 100)
+ linesToScroll *= 6;
+ else if (elapsed < 200)
+ linesToScroll *= 3;
+ else if (elapsed < 300)
+ linesToScroll *= 2;
+
if (axis == kEventMouseWheelAxisX)
- wheel_deltaX = mdelt * scrollFactor;
+ wheel_deltaX = linesToScroll * 120;
else
- wheel_deltaY = mdelt * scrollFactor;
+ wheel_deltaY = linesToScroll * 120;
}
}
diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp
index 19a8b63..588a48e 100644
--- a/src/gui/widgets/qabstractslider.cpp
+++ b/src/gui/widgets/qabstractslider.cpp
@@ -715,8 +715,7 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e)
#else
stepsToScroll = int(d->offset_accumulated) * QApplication::wheelScrollLines() * d->singleStep;
#endif
- if (qAbs(stepsToScroll) > d->pageStep)
- stepsToScroll = currentOffset > 0 ? d->pageStep : -d->pageStep;
+ stepsToScroll = qBound(-d->pageStep, stepsToScroll, d->pageStep);
}
if (d->invertedControls)