diff options
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 |