diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-03-23 21:06:47 +0200 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-03-23 21:06:47 +0200 |
commit | 42e4ae042a4c86e58bcb8b6d2d59ba4a988285b4 (patch) | |
tree | a7f25b1d335a834a7c3ae104cee913ef3a4dd4fb /src/plugins/platforms/cocoa/qnsview_mouse.mm | |
parent | 4ee4fc18b4067b90efa46ca9baba74f53b54d9ec (diff) | |
parent | 168ff3419f256fdb35b586275d293fc0cd773fe1 (diff) | |
download | qtbase-5.15.tar.gz |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.9' into tqtc/lts-5.15-opensourcev5.15.9-lts-lgpl5.15
Change-Id: Iaff6b55275e50d19973e1020853d8622587069f9
Diffstat (limited to 'src/plugins/platforms/cocoa/qnsview_mouse.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview_mouse.mm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm index ef80a47e0f..73995639aa 100644 --- a/src/plugins/platforms/cocoa/qnsview_mouse.mm +++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm @@ -678,7 +678,11 @@ } } 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 @@ -690,6 +694,16 @@ Q_ASSERT(theEvent.momentumPhase != NSEventPhaseStationary); } + // Sanitize deltas for events that should not result in scrolling. + // On macOS 12.1 this phase has been observed to report deltas. + if (theEvent.phase == NSEventPhaseCancelled) { + if (!pixelDelta.isNull() || !angleDelta.isNull()) { + qCInfo(lcQpaMouse) << "Ignoring unexpected delta for" << theEvent; + pixelDelta = QPoint(); + angleDelta = QPoint(); + } + } + // Prevent keyboard modifier state from changing during scroll event streams. // A two-finger trackpad flick generates a stream of scroll events. We want // the keyboard modifier state to be the state at the beginning of the |