Stabilize tst_TouchMouse::hoverEnabled; add cat. logging

Behavior has changed since fd70c80fe1
Particularly, the "hoverID" concept from
bbcc2657fa basically ensures that items
that no longer contain the current position are no longer hovered.
The current position might come from an actual event, or from
QQuickDeliveryAgentPrivate::flushFrameSynchronousEvents() which uses
lastMousePosition. So currently we can't have mouseArea1 hovered because
of a previous mouse move and simultaneously hover mouseArea2 because of
the most-recent touch tap. lastMousePosition can in turn get updated in
various ways; a mouse event synthesized from touch is one of them.

Pick-to: 6.5 6.6
Task-number: QTBUG-40856
Task-number: QTBUG-86729
Change-Id: I4e70b67813a58de973b2be46a03312417f2da32e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Shawn Rutledge 2023-06-28 18:41:44 +02:00
parent 6362da5870
commit 204720cb55
3 changed files with 13 additions and 7 deletions

View File

@ -909,6 +909,7 @@ void QQuickMouseArea::ungrabMouse()
emit pressedButtonsChanged();
if (d->hovered && !isUnderMouse()) {
qCDebug(lcHoverTrace) << "losing hover: not under the mouse";
d->hovered = false;
emit hoveredChanged();
}
@ -973,6 +974,7 @@ bool QQuickMouseArea::sendMouseEvent(QMouseEvent *event)
emit pressedChanged();
emit containsPressChanged();
if (d->hovered) {
qCDebug(lcHoverTrace) << "losing hover: button released";
d->hovered = false;
emit hoveredChanged();
}

View File

@ -8,6 +8,3 @@ windows gcc developer-build
# QTBUG-74517
[touchButtonOnFlickable]
windows gcc developer-build
[hoverEnabled]
* # QTBUG-86729

View File

@ -1440,6 +1440,7 @@ void tst_TouchMouse::hoverEnabled() // QTBUG-40856
QQuickView window;
QVERIFY(QQuickTest::showView(window, testFileUrl("hoverMouseAreas.qml")));
QQuickItem *root = window.rootObject();
auto deliveryAgent = QQuickWindowPrivate::get(&window)->deliveryAgentPrivate();
QQuickMouseArea *mouseArea1 = root->findChild<QQuickMouseArea*>("mouseArea1");
QVERIFY(mouseArea1 != nullptr);
@ -1467,6 +1468,7 @@ void tst_TouchMouse::hoverEnabled() // QTBUG-40856
// ------------------------- Touch click on mouseArea1
QTest::touchEvent(&window, device).press(0, p1, &window);
deliveryAgent->flushFrameSynchronousEvents(&window);
QCOMPARE(enterSpy1.size(), 1);
QCOMPARE(enterSpy2.size(), 0);
@ -1475,37 +1477,42 @@ void tst_TouchMouse::hoverEnabled() // QTBUG-40856
QVERIFY(!mouseArea2->hovered());
QTest::touchEvent(&window, device).release(0, p1, &window);
deliveryAgent->flushFrameSynchronousEvents(&window);
QVERIFY(clickSpy1.size() == 1);
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea2->hovered());
// ------------------------- Touch click on mouseArea2
QTest::touchEvent(&window, device).press(0, p2, &window);
deliveryAgent->flushFrameSynchronousEvents(&window);
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea1->hovered());
QVERIFY(mouseArea2->hovered());
QVERIFY(mouseArea2->isPressed());
QCOMPARE(enterSpy1.size(), 1);
QCOMPARE(enterSpy2.size(), 1);
QTest::touchEvent(&window, device).release(0, p2, &window);
deliveryAgent->flushFrameSynchronousEvents(&window);
QVERIFY(clickSpy2.size() == 1);
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea1->hovered());
QVERIFY(!mouseArea2->hovered());
QCOMPARE(exitSpy1.size(), 0);
QCOMPARE(exitSpy1.size(), 1);
QCOMPARE(exitSpy2.size(), 1);
// ------------------------- Another touch click on mouseArea1
QTest::touchEvent(&window, device).press(0, p1, &window);
deliveryAgent->flushFrameSynchronousEvents(&window);
QCOMPARE(enterSpy1.size(), 1);
QCOMPARE(enterSpy1.size(), 2);
QCOMPARE(enterSpy2.size(), 1);
QVERIFY(mouseArea1->isPressed());
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea2->hovered());
QTest::touchEvent(&window, device).release(0, p1, &window);
deliveryAgent->flushFrameSynchronousEvents(&window);
QCOMPARE(clickSpy1.size(), 2);
QVERIFY(mouseArea1->hovered());
QVERIFY(!mouseArea1->isPressed());