summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-01-05 15:34:58 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-01-07 08:38:00 +0000
commit58226a8b627bdb4d6faf43797623d4574ca1d561 (patch)
treec79c817188f0d062d38705ce2e3bdf78622ab9b2 /src
parentf9cd2235c374630fae8f45246ef11e255a97c023 (diff)
macOS: Handle momentum scroll NSEventPhaseBegan when scroll had ended
We use nextEventMatchingMask to look for future momentum scroll events when the non-momentum scroll ends, to continue the scroll uninterrupted from the perspective of client code. But we're not guaranteed to find a future momentum scroll event, as observed on macOS 12.1, so if we then see a momentum NSEventPhaseBegan we need to treat it as a scroll begin from Qt's perspective. Fixes: QTBUG-97841 Change-Id: I412abe0891660eda32a42a08d7dc7dee9eaa73aa Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 2e1191845679b937bed5f04979287c26e5578e76) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/cocoa/qnsview_mouse.mm6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm
index 106092750b..1b840ba2a9 100644
--- a/src/plugins/platforms/cocoa/qnsview_mouse.mm
+++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm
@@ -725,7 +725,11 @@ static const QPointingDevice *pointingDeviceFor(qint64 deviceID)
}
} else if (theEvent.momentumPhase == NSEventPhaseBegan) {
Q_ASSERT(!pixelDelta.isNull() && !angleDelta.isNull());
- phase = Qt::ScrollUpdate; // Send as update, it has a delta
+ // If we missed finding a momentum NSEventPhaseBegan when the non-momentum
+ // phase ended we need to treat this as a scroll begin, to not confuse client
+ // code. Otherwise we treat it as a continuation of the existing scroll.
+ phase = m_scrolling ? Qt::ScrollUpdate : Qt::ScrollBegin;
+ m_scrolling = true;
} else if (theEvent.momentumPhase == NSEventPhaseChanged) {
phase = Qt::ScrollMomentum;
} else if (theEvent.phase == NSEventPhaseCancelled