diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-11-23 11:47:29 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-11-23 15:02:25 +0100 |
commit | d15f6e0b237107d176a9790da609ff72ce3111f3 (patch) | |
tree | 2432cb45424e7dd67c7c784de075023a74607211 /tests/auto | |
parent | 0fdb3a01d3f2bba7d03ac0fa11d975f47d8ecdc7 (diff) |
Fix tst_PointHandler::pressedMultipleButtons
QQuickWindowPrivate::deliverPressOrReleaseEvent() calls
QPointerEvent::clearPassiveGrabbers() for every QEventPoint that has
the Pressed state. This is consistent with the idea that for every
press (a different mouse button or a different touchpoint), we start
over with event delivery so that different items and handlers can see
what's going on and decide whether it's relevant for them. But
QQuickPointerHandler::onGrabChanged() reacts with setActive(false).
So for example if we press left mouse button, then keep holding it
and press right mouse button, PointHandler changes its active state
twice, because its passive grab was cleared and then we visit it again;
it's still interested in tracking the mouse, so it takes another passive
grab and becomes active again. Avoiding emitting activeStateChanged
in this case would seem a bit contrived. As long as the release of
one button doesn't make PointHandler completely lose interest
prematurely, QTBUG-66360 can still be considered fixed, I think.
Pick-to: 6.0
Task-number: QTBUG-66360
Task-number: QTBUG-86729
Change-Id: I132a8c5d1878769481b8afcc62ba237b4498b069
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquickpointhandler/BLACKLIST | 2 | ||||
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickpointhandler/BLACKLIST b/tests/auto/quick/pointerhandlers/qquickpointhandler/BLACKLIST index 7dea82dc30..f4d271c230 100644 --- a/tests/auto/quick/pointerhandlers/qquickpointhandler/BLACKLIST +++ b/tests/auto/quick/pointerhandlers/qquickpointhandler/BLACKLIST @@ -1,4 +1,2 @@ -[pressedMultipleButtons] # QTBUG-86729 -* [tabletStylus] macos ci diff --git a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp index 900202f132..8e6f9deb7f 100644 --- a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp @@ -281,6 +281,7 @@ void tst_PointHandler::pressedMultipleButtons_data() QTest::addColumn<QList<bool> >("active"); QTest::addColumn<QList<Qt::MouseButtons> >("pressedButtons"); QTest::addColumn<int>("changeCount"); + QTest::addColumn<int>("activeChangeCount"); QList<Qt::MouseButtons> buttons; QList<bool> active; @@ -298,7 +299,7 @@ void tst_PointHandler::pressedMultipleButtons_data() << Qt::LeftButton << Qt::NoButton; QTest::newRow("Accept Left - Press left, Press Right, Release Right") - << Qt::MouseButtons(Qt::LeftButton) << buttons << active << pressedButtons << 4; + << Qt::MouseButtons(Qt::LeftButton) << buttons << active << pressedButtons << 4 << 4; buttons.clear(); active.clear(); @@ -316,7 +317,7 @@ void tst_PointHandler::pressedMultipleButtons_data() << Qt::NoButton // Not the "truth" but filtered according to this handler's acceptedButtons << Qt::NoButton; QTest::newRow("Accept Left - Press left, Press Right, Release Left") - << Qt::MouseButtons(Qt::LeftButton) << buttons << active << pressedButtons << 3; + << Qt::MouseButtons(Qt::LeftButton) << buttons << active << pressedButtons << 3 << 4; buttons.clear(); active.clear(); @@ -334,7 +335,7 @@ void tst_PointHandler::pressedMultipleButtons_data() << Qt::LeftButton << Qt::NoButton; QTest::newRow("Accept Left|Right - Press left, Press Right, Release Right") - << (Qt::LeftButton | Qt::RightButton) << buttons << active << pressedButtons << 4; + << (Qt::LeftButton | Qt::RightButton) << buttons << active << pressedButtons << 4 << 4; buttons.clear(); active.clear(); @@ -352,7 +353,7 @@ void tst_PointHandler::pressedMultipleButtons_data() << Qt::NoButton // Not the "truth" but filtered according to this handler's acceptedButtons << Qt::NoButton; QTest::newRow("Accept Right - Press Right, Press Left, Release Right") - << Qt::MouseButtons(Qt::RightButton) << buttons << active << pressedButtons << 3; + << Qt::MouseButtons(Qt::RightButton) << buttons << active << pressedButtons << 3 << 4; } void tst_PointHandler::pressedMultipleButtons() @@ -362,6 +363,7 @@ void tst_PointHandler::pressedMultipleButtons() QFETCH(QList<bool>, active); QFETCH(QList<Qt::MouseButtons>, pressedButtons); QFETCH(int, changeCount); + QFETCH(int, activeChangeCount); QScopedPointer<QQuickView> windowPtr; createView(windowPtr, "pointTracker.qml"); @@ -397,7 +399,7 @@ void tst_PointHandler::pressedMultipleButtons() QTest::mousePress(windowPtr.data(), Qt::NoButton, Qt::NoModifier, point); QCOMPARE(handler->active(), false); - QCOMPARE(activeSpy.count(), 2); + QCOMPARE(activeSpy.count(), activeChangeCount); QCOMPARE(pointSpy.count(), changeCount); } |