┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/private
diff options
context:
space:
mode:
authorKetal Wang <[email protected]>2026-05-29 18:14:59 +0800
committerketal yuni <[email protected]>2026-06-10 11:33:48 +0000
commit6eed05fd769b01c37530b8b62cdcd65933ea8d14 (patch)
tree40f3eb5a00704544bcfe652710644294ae6788a0 /src/kitemviews/private
parentb36ac352bf04b10db66864f107cbc2cdd4d8a217 (diff)
kitemviews: handle macOS pixel wheel scrolling immediately
Diffstat (limited to 'src/kitemviews/private')
-rw-r--r--src/kitemviews/private/kitemlistsmoothscroller.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp
index 915b6b3d5..7cedf9d94 100644
--- a/src/kitemviews/private/kitemlistsmoothscroller.cpp
+++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp
@@ -209,6 +209,32 @@ void KItemListSmoothScroller::handleWheelEvent(QWheelEvent *event)
{
const bool previous = m_smoothScrolling;
+#ifdef Q_OS_MACOS
+ if (event->hasPixelDelta()) {
+ const QPoint pixelDelta = event->pixelDelta();
+ const int scrollDelta = qAbs(pixelDelta.x()) > qAbs(pixelDelta.y()) ? pixelDelta.x() : pixelDelta.y();
+ const int oldValue = m_scrollBar->value();
+ const int newValue = qBound(m_scrollBar->minimum(), oldValue - scrollDelta, m_scrollBar->maximum());
+ if (newValue == oldValue) {
+ event->ignore();
+ return;
+ }
+
+ m_smoothScrolling = false;
+ if (m_animation->state() == QAbstractAnimation::Running) {
+ m_animation->stop();
+ }
+ if (QObject *target = targetObject()) {
+ target->setProperty(propertyName(), newValue);
+ }
+ m_scrollBar->setValue(newValue);
+ event->accept();
+
+ m_smoothScrolling = previous;
+ return;
+ }
+#endif
+
m_smoothScrolling = true;
QWheelEvent *copy = event->clone();