Skip to content

Commit 2cb75d3

Browse files
committed
Remove DA::deliverMatchingPointsToItem's second sendFilteredPointerEvent
a220969 added sendFilteredPointerEvent earlier in this function; it doesn't make sense to do it multiple times. Fixes: QTBUG-109995 Fixes: QTBUG-113653 Pick-to: 6.2 6.5 6.5.2 6.6 Change-Id: I9a9cb36ba060ec924ec3467fff0d7b0e3d474da3 Reviewed-by: Doris Verria <[email protected]>
1 parent 02c3fc4 commit 2cb75d3

File tree

4 files changed

+41
-50
lines changed

4 files changed

+41
-50
lines changed

src/quick/util/qquickdeliveryagent.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,11 +2170,6 @@ void QQuickDeliveryAgentPrivate::deliverMatchingPointsToItem(QQuickItem *item, b
21702170
if (item->acceptTouchEvents()) {
21712171
qCDebug(lcTouch) << "considering delivering" << &touchEvent << " to " << item;
21722172

2173-
// If any parent filters the event, we're done.
2174-
hasFiltered.clear();
2175-
if (sendFilteredPointerEvent(&touchEvent, item))
2176-
return;
2177-
21782173
// Deliver the touch event to the given item
21792174
qCDebug(lcTouch) << "actually delivering" << &touchEvent << " to " << item;
21802175
QCoreApplication::sendEvent(item, &touchEvent);

tests/auto/quick/qquicklistview2/tst_qquicklistview2.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,29 +384,31 @@ void tst_QQuickListView2::tapDelegateDuringFlicking_data()
384384
{
385385
QTest::addColumn<QByteArray>("qmlFile");
386386
QTest::addColumn<QQuickFlickable::BoundsBehavior>("boundsBehavior");
387+
QTest::addColumn<bool>("expectCanceled");
387388

388389
QTest::newRow("Button StopAtBounds") << QByteArray("buttonDelegate.qml")
389-
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::StopAtBounds);
390+
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::StopAtBounds) << false;
390391
QTest::newRow("MouseArea StopAtBounds") << QByteArray("mouseAreaDelegate.qml")
391-
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::StopAtBounds);
392+
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::StopAtBounds) << true;
392393
QTest::newRow("Button DragOverBounds") << QByteArray("buttonDelegate.qml")
393-
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::DragOverBounds);
394+
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::DragOverBounds) << false;
394395
QTest::newRow("MouseArea DragOverBounds") << QByteArray("mouseAreaDelegate.qml")
395-
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::DragOverBounds);
396+
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::DragOverBounds) << true;
396397
QTest::newRow("Button OvershootBounds") << QByteArray("buttonDelegate.qml")
397-
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::OvershootBounds);
398+
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::OvershootBounds) << false;
398399
QTest::newRow("MouseArea OvershootBounds") << QByteArray("mouseAreaDelegate.qml")
399-
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::OvershootBounds);
400+
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::OvershootBounds) << true;
400401
QTest::newRow("Button DragAndOvershootBounds") << QByteArray("buttonDelegate.qml")
401-
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
402+
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::DragAndOvershootBounds) << false;
402403
QTest::newRow("MouseArea DragAndOvershootBounds") << QByteArray("mouseAreaDelegate.qml")
403-
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
404+
<< QQuickFlickable::BoundsBehavior(QQuickFlickable::DragAndOvershootBounds) << true;
404405
}
405406

406407
void tst_QQuickListView2::tapDelegateDuringFlicking() // QTBUG-103832
407408
{
408409
QFETCH(QByteArray, qmlFile);
409410
QFETCH(QQuickFlickable::BoundsBehavior, boundsBehavior);
411+
QFETCH(bool, expectCanceled);
410412

411413
QQuickView window;
412414
QVERIFY(QQuickTest::showView(window, testFileUrl(qmlFile.constData())));
@@ -419,7 +421,16 @@ void tst_QQuickListView2::tapDelegateDuringFlicking() // QTBUG-103832
419421
QVERIFY(listView->isFlicking()); // we want to test the case when it's still moving while we tap
420422
// @y = 400 we pressed the 4th delegate; started flicking, and the press was canceled
421423
QCOMPARE(listView->property("pressedDelegates").toList().first(), 4);
422-
QCOMPARE(listView->property("canceledDelegates").toList().first(), 4);
424+
// At first glance one would expect MouseArea and Button would be consistent about this;
425+
// but in fact, before ListView takes over the grab via filtering,
426+
// Button.pressed transitions to false because QQuickAbstractButtonPrivate::handleMove
427+
// sees that the touchpoint has strayed outside its bounds, but it does NOT emit the canceled signal
428+
if (expectCanceled) {
429+
const QVariantList canceledDelegates = listView->property("canceledDelegates").toList();
430+
QCOMPARE(canceledDelegates.size(), 1);
431+
QCOMPARE(canceledDelegates.first(), 4);
432+
}
433+
QCOMPARE(listView->property("releasedDelegates").toList().size(), 0);
423434

424435
// press a delegate during flicking (at y > 501 + 100, so likely delegate 6)
425436
QTest::touchEvent(&window, touchDevice.data()).press(0, {100, 100});
@@ -442,7 +453,7 @@ void tst_QQuickListView2::tapDelegateDuringFlicking() // QTBUG-103832
442453
QVERIFY(lastPressed > 5);
443454
QCOMPARE(releasedDelegates.last(), lastPressed);
444455
QCOMPARE(tappedDelegates.last(), lastPressed);
445-
QCOMPARE(canceledDelegates.size(), 1); // only the first press was canceled, not the second
456+
QCOMPARE(canceledDelegates.size(), expectCanceled ? 1 : 0); // only the first press was canceled, not the second
446457
}
447458

448459
void tst_QQuickListView2::flickDuringFlicking_data()

tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -723,12 +723,16 @@ void tst_QQuickMultiPointTouchArea::inFlickable()
723723
// test that dragging out of a Flickable containing a MPTA doesn't harm Flickable's state.
724724
void tst_QQuickMultiPointTouchArea::inFlickable2()
725725
{
726+
const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
726727
QScopedPointer<QQuickView> window(createAndShowView("inFlickable2.qml"));
727728
QVERIFY(window->rootObject() != nullptr);
728729

729730
QQuickFlickable *flickable = window->rootObject()->findChild<QQuickFlickable*>("flickable");
730731
QVERIFY(flickable != nullptr);
731732

733+
QQuickMultiPointTouchArea *mpta = window->rootObject()->findChild<QQuickMultiPointTouchArea*>();
734+
QVERIFY(mpta);
735+
732736
QQuickTouchPoint *point11 = window->rootObject()->findChild<QQuickTouchPoint*>("point1");
733737
QVERIFY(point11);
734738

@@ -741,25 +745,12 @@ void tst_QQuickMultiPointTouchArea::inFlickable2()
741745
QQuickTouchUtils::flush(window.data());
742746
QTest::mousePress(window.data(), Qt::LeftButton, Qt::NoModifier, p1);
743747

744-
p1 += QPoint(15,0);
745-
QTest::touchEvent(window.data(), device).move(0, p1);
746-
QQuickTouchUtils::flush(window.data());
747-
QTest::mouseMove(window.data(), p1);
748-
749-
p1 += QPoint(15,0);
750-
QTest::touchEvent(window.data(), device).move(0, p1);
751-
QQuickTouchUtils::flush(window.data());
752-
QTest::mouseMove(window.data(), p1);
753-
754-
p1 += QPoint(15,0);
755-
QTest::touchEvent(window.data(), device).move(0, p1);
756-
QQuickTouchUtils::flush(window.data());
757-
QTest::mouseMove(window.data(), p1);
758-
759-
p1 += QPoint(15,0);
760-
QTest::touchEvent(window.data(), device).move(0, p1);
761-
QQuickTouchUtils::flush(window.data());
762-
QTest::mouseMove(window.data(), p1);
748+
for (int i = 0; i < 4; ++i) {
749+
p1 += QPoint(dragThreshold, 0);
750+
QTest::touchEvent(window.data(), device).move(0, p1);
751+
QQuickTouchUtils::flush(window.data());
752+
QTest::mouseMove(window.data(), p1);
753+
}
763754

764755
QVERIFY(!flickable->isMoving());
765756
QVERIFY(point11->pressed());
@@ -772,27 +763,21 @@ void tst_QQuickMultiPointTouchArea::inFlickable2()
772763
QTRY_VERIFY(!flickable->isMoving());
773764

774765
// Check that we can still move the Flickable
766+
QSignalSpy gestureStartedSpy(mpta, &QQuickMultiPointTouchArea::gestureStarted);
775767
p1 = QPoint(50,100);
776768
QTest::touchEvent(window.data(), device).press(0, p1);
777769
QQuickTouchUtils::flush(window.data());
778770

779771
QCOMPARE(point11->pressed(), true);
780772

781-
p1 += QPoint(0,15);
782-
QTest::touchEvent(window.data(), device).move(0, p1);
783-
QQuickTouchUtils::flush(window.data());
784-
785-
p1 += QPoint(0,15);
786-
QTest::touchEvent(window.data(), device).move(0, p1);
787-
QQuickTouchUtils::flush(window.data());
788-
789-
p1 += QPoint(0,15);
790-
QTest::touchEvent(window.data(), device).move(0, p1);
791-
QQuickTouchUtils::flush(window.data());
792-
793-
p1 += QPoint(0,15);
794-
QTest::touchEvent(window.data(), device).move(0, p1);
795-
QQuickTouchUtils::flush(window.data());
773+
for (int i = 0; i < 4; ++i) {
774+
p1 += QPoint(0, dragThreshold);
775+
QTest::touchEvent(window.data(), device).move(0, p1);
776+
QQuickTouchUtils::flush(window.data());
777+
// QTBUG-113653: gestureStarted is emitted when touch delta exceeds drag threshold,
778+
// regardless of the filtering Flickable parent
779+
QCOMPARE(gestureStartedSpy.size(), i > 0 ? 1 : 0);
780+
}
796781

797782
QVERIFY(flickable->contentY() < 0);
798783
QVERIFY(flickable->isMoving());

tests/auto/quick/touchmouse/tst_touchmouse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ void tst_TouchMouse::touchButtonOnFlickable()
713713

714714
QTRY_COMPARE(eventItem2->touchUngrabCount, 1);
715715
qCDebug(lcTests) << "expected delivered events: press(touch) move(touch)" << eventItem2->eventList;
716-
QCOMPARE(eventItem2->eventList.size(), 2);
716+
QCOMPARE(eventItem2->eventList.size(), 3);
717717
QCOMPARE(eventItem2->eventList.at(1).type, QEvent::TouchUpdate);
718718
QCOMPARE(grabMonitor.exclusiveGrabber, flickable);
719719
// both EventItem and Flickable handled the actual touch, so synth-mouse doesn't happen

0 commit comments

Comments
 (0)