aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-10-29 17:53:09 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-10-29 19:47:01 +0100
commit5bbfd850d77c05e2d1ccf4d052e70240d5aae342 (patch)
treea003a017616ec08405c605166386c02ad0c7e69c
parentd723541d3fdfa2b77bfed3c214f26b0106c85576 (diff)
Don't send an item a mouse release with a button that it doesn't accept
In tst_qquickitem::ignoreButtonPressNotInAcceptedMouseButtons(), when the right mouse button release occurs, the item has a grab, but it's not interested in the right button, only the left. But of course we still want to deliver mouse drags, so if the button is NoButton and the item is the grabber, it gets the event. Task-number: QTBUG-31861 Task-number: QTBUG-86729 Change-Id: I952acc721a5f80a7fc5619c5fea640dae805e9c8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/quick/items/qquickwindow.cpp39
-rw-r--r--tests/auto/quick/qquickitem/BLACKLIST2
2 files changed, 21 insertions, 20 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index ccc79c5f56..3236ce3806 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -2865,26 +2865,29 @@ void QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem *item, bool isG
return;
// TODO: unite this mouse point delivery with the synthetic mouse event below
- if (isMouse && (isGrabber || (item->acceptedMouseButtons() & static_cast<QSinglePointEvent *>(pointerEvent)->button()))) {
- // The only reason to already have a mouse grabber here is
- // synthetic events - flickable sends one when setPressDelay is used.
- auto oldMouseGrabber = pointerEvent->exclusiveGrabber(pointerEvent->point(0));
- pointerEvent->accept();
- if (isGrabber && sendFilteredPointerEvent(pointerEvent, item))
- return;
- localizePointerEvent(pointerEvent, item);
- QCoreApplication::sendEvent(item, pointerEvent);
- if (pointerEvent->isAccepted()) {
- auto &point = pointerEvent->point(0);
- auto mouseGrabber = pointerEvent->exclusiveGrabber(point);
- if (mouseGrabber && mouseGrabber != item && mouseGrabber != oldMouseGrabber) {
- // we don't need item->mouseUngrabEvent() because QQuickWindowPrivate::onGrabChanged does it
- } else if (item->isEnabled() && item->isVisible()) {
- pointerEvent->setExclusiveGrabber(point, item);
+ if (isMouse) {
+ auto button = static_cast<QSinglePointEvent *>(pointerEvent)->button();
+ if ((isGrabber && button == Qt::NoButton) || item->acceptedMouseButtons().testFlag(button)) {
+ // The only reason to already have a mouse grabber here is
+ // synthetic events - flickable sends one when setPressDelay is used.
+ auto oldMouseGrabber = pointerEvent->exclusiveGrabber(pointerEvent->point(0));
+ pointerEvent->accept();
+ if (isGrabber && sendFilteredPointerEvent(pointerEvent, item))
+ return;
+ localizePointerEvent(pointerEvent, item);
+ QCoreApplication::sendEvent(item, pointerEvent);
+ if (pointerEvent->isAccepted()) {
+ auto &point = pointerEvent->point(0);
+ auto mouseGrabber = pointerEvent->exclusiveGrabber(point);
+ if (mouseGrabber && mouseGrabber != item && mouseGrabber != oldMouseGrabber) {
+ // we don't need item->mouseUngrabEvent() because QQuickWindowPrivate::onGrabChanged does it
+ } else if (item->isEnabled() && item->isVisible()) {
+ pointerEvent->setExclusiveGrabber(point, item);
+ }
+ point.setAccepted(true);
}
- point.setAccepted(true);
+ return;
}
- return;
}
if (!isTouchEvent(pointerEvent))
diff --git a/tests/auto/quick/qquickitem/BLACKLIST b/tests/auto/quick/qquickitem/BLACKLIST
index 917aa16ae6..6563bc8743 100644
--- a/tests/auto/quick/qquickitem/BLACKLIST
+++ b/tests/auto/quick/qquickitem/BLACKLIST
@@ -2,7 +2,5 @@
xcb
[qtBug60123]
* # QTBUG-86729
-[ignoreButtonPressNotInAcceptedMouseButtons]
-* # QTBUG-86729
[touchEventAcceptIgnore]
* # QTBUG-86729