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
Pick-to: 6.3 6.2 5.15
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>
This commit is contained in:
Tor Arne Vestbø 2022-01-05 15:34:58 +01:00
parent 00d197662d
commit 2e11918456

View File

@ -721,7 +721,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