diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-11-17 21:38:47 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-11-18 13:23:56 +0000 |
commit | 0ca06764dc1a75ab7702a9d798d23717599284f3 (patch) | |
tree | fffb787a3409ecc5b57107204e04c7f619a66216 /src | |
parent | 65be41fc38a20fa8a1e19b2f2492baa9d0680b1f (diff) |
Don't clearPassiveGrabbers() after MouseEventSynthesizedBySystem
Windows sends synth mouse events after touch events. We avoid delivery
of them in QQuickDeliveryAgentPrivate::handleMouseEvent(), but we need
to avoid reacting to them here too. If the touchpoint already had
a passive grabber, and the mouse event comes from the same device,
then clearing the mouse passive grabbers is identical to clearing the
touchpoint's passive grabbers, which we don't want to do.
Amends 48b1c59b65332b773eb51d25c422b53dbd3d6762
Fixes: QTBUG-104890
Change-Id: I4c3e18fc834c7bfcba7037548c7e42627e319bda
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit 0b7ee7a48f5f32fc916cc1914b110bdf68e37486)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 7 | ||||
-rw-r--r-- | src/quick/util/qquickdeliveryagent.cpp | 5 | ||||
-rw-r--r-- | src/quick/util/qquickdeliveryagent_p_p.h | 1 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 6c62a6c9ee..02f8539c86 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -1386,6 +1386,7 @@ bool QQuickWindow::event(QEvent *event) for (pt : pe->points()) would only iterate once, so we might as well skip that logic. */ if (pe->pointCount()) { + const bool synthMouse = QQuickDeliveryAgentPrivate::isSynthMouse(pe); if (QQuickDeliveryAgentPrivate::subsceneAgentsExist) { bool ret = false; // Split up the multi-point event according to the relevant QQuickDeliveryAgent that should deliver to each existing grabber @@ -1394,7 +1395,7 @@ bool QQuickWindow::event(QEvent *event) QEventPoint::States eventStates; auto insert = [&](QQuickDeliveryAgent *ptda, const QEventPoint &pt) { - if (pt.state() == QEventPoint::Pressed) + if (pt.state() == QEventPoint::Pressed && !synthMouse) pe->clearPassiveGrabbers(pt); auto &ptList = deliveryAgentsNeedingPoints[ptda]; auto idEquals = [](auto id) { return [id] (const auto &e) { return e.id() == id; }; }; @@ -1457,7 +1458,9 @@ bool QQuickWindow::event(QEvent *event) if (ret) return true; - } else { + } else if (!synthMouse) { + // clear passive grabbers unless it's a system synth-mouse event + // QTBUG-104890: Windows sends synth mouse events (which should be ignored) after touch events for (const auto &pt : pe->points()) { if (pt.state() == QEventPoint::Pressed) pe->clearPassiveGrabbers(pt); diff --git a/src/quick/util/qquickdeliveryagent.cpp b/src/quick/util/qquickdeliveryagent.cpp index b1ed646638..dcea1e815f 100644 --- a/src/quick/util/qquickdeliveryagent.cpp +++ b/src/quick/util/qquickdeliveryagent.cpp @@ -1417,6 +1417,11 @@ bool QQuickDeliveryAgentPrivate::isEventFromMouseOrTouchpad(const QPointerEvent devType == QInputDevice::DeviceType::TouchPad; } +bool QQuickDeliveryAgentPrivate::isSynthMouse(const QPointerEvent *ev) +{ + return (!isEventFromMouseOrTouchpad(ev) && isMouseEvent(ev)); +} + QQuickPointingDeviceExtra *QQuickDeliveryAgentPrivate::deviceExtra(const QInputDevice *device) { QInputDevicePrivate *devPriv = QInputDevicePrivate::get(const_cast<QInputDevice *>(device)); diff --git a/src/quick/util/qquickdeliveryagent_p_p.h b/src/quick/util/qquickdeliveryagent_p_p.h index 66249f69c8..efd3431817 100644 --- a/src/quick/util/qquickdeliveryagent_p_p.h +++ b/src/quick/util/qquickdeliveryagent_p_p.h @@ -143,6 +143,7 @@ public: static bool isTouchEvent(const QPointerEvent *ev); static bool isTabletEvent(const QPointerEvent *ev); static bool isEventFromMouseOrTouchpad(const QPointerEvent *ev); + static bool isSynthMouse(const QPointerEvent *ev); static QQuickPointingDeviceExtra *deviceExtra(const QInputDevice *device); // delivery of pointer events: |