diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-07-14 20:09:57 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-02-25 10:31:37 +0100 |
commit | f35afe3eeaa460cb5e96171fb8a43fdf52c8761c (patch) | |
tree | 32b5c087a30a5dc455b8505415b0372c661f24cd /tests/auto | |
parent | 4853b3a7d50c20ad00a2780b8d11a0f9c38462ae (diff) |
Move event delivery from QQWindow to QQuickDeliveryAgent
QQuickWindow owns QQuickRootItem which owns QQuickDeliveryAgent, so
for every window there's an object responsible for event delivery,
while the window itself is mainly responsible for rendering (separation
of concerns). However, QQuickRootItem and QQuickDeliveryAgent can now
be used in cases where the scene doesn't directly belong to a window,
such as when a Qt Quick sub-scene is mapped somewhere into a Qt Quick 3D
scene. In that case, we must remember which delivery agent was in use
at the time when a QEventPoint is grabbed and deliver subsequent updates
via the same DA. There's also a QQuickDeliveryAgent::Transform
abstraction which subscene-management code (such as QQuick3DViewport)
can implement, to provide a formula to map the window's scene
coordinates to subscene coordinates; if defined, it will be used
during delivery of subsequent updates to existing grabbers.
Task-number: QTBUG-84870
Change-Id: I70b433f7ebb05d2e60214ff3192e05da0aa84a42
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 68c103225f4e8bd6c1b18ef547108fd60f398c0f)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/quick/qquickitem/tst_qquickitem.cpp | 8 | ||||
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 8 | ||||
-rw-r--r-- | tests/auto/quick/shared/viewtestutil.cpp | 11 | ||||
-rw-r--r-- | tests/auto/quick/touchmouse/tst_touchmouse.cpp | 14 |
4 files changed, 25 insertions, 16 deletions
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index 7860f5677a..3d6044ee9b 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -1600,6 +1600,10 @@ void tst_qquickitem::hoverEvent() QQuickWindow *window = new QQuickWindow(); window->resize(200, 200); window->show(); + QTest::qWaitForWindowExposed(window); +#if QT_CONFIG(cursor) // Get the cursor out of the way. + QCursor::setPos(window->geometry().topRight() + QPoint(100, 100)); +#endif HoverItem *item = new HoverItem; item->setSize(QSizeF(100, 100)); @@ -1641,6 +1645,10 @@ void tst_qquickitem::hoverEventInParent() QQuickWindow window; window.resize(200, 200); window.show(); + QTest::qWaitForWindowExposed(&window); +#if QT_CONFIG(cursor) // Get the cursor out of the way. + QCursor::setPos(window.geometry().topRight() + QPoint(100, 100)); +#endif HoverItem *parentItem = new HoverItem(window.contentItem()); parentItem->setSize(QSizeF(200, 200)); diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 7fe8d94c74..05fda64654 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1137,7 +1137,7 @@ void tst_qquickwindow::mergeTouchPointLists() for (const auto &item : list2) b.append(item.get()); - auto targetList = windowPrivate->mergePointerTargets(a, b); + auto targetList = windowPrivate->deliveryAgentPrivate()->mergePointerTargets(a, b); QCOMPARE(targetList, expected); } @@ -1760,13 +1760,13 @@ void tst_qquickwindow::focusReason() secondItem->setParentItem(window->contentItem()); firstItem->forceActiveFocus(Qt::OtherFocusReason); - QCOMPARE(QQuickWindowPrivate::get(window)->lastFocusReason, Qt::OtherFocusReason); + QCOMPARE(QQuickWindowPrivate::get(window)->deliveryAgentPrivate()->lastFocusReason, Qt::OtherFocusReason); secondItem->forceActiveFocus(Qt::TabFocusReason); - QCOMPARE(QQuickWindowPrivate::get(window)->lastFocusReason, Qt::TabFocusReason); + QCOMPARE(QQuickWindowPrivate::get(window)->deliveryAgentPrivate()->lastFocusReason, Qt::TabFocusReason); firstItem->forceActiveFocus(Qt::BacktabFocusReason); - QCOMPARE(QQuickWindowPrivate::get(window)->lastFocusReason, Qt::BacktabFocusReason); + QCOMPARE(QQuickWindowPrivate::get(window)->deliveryAgentPrivate()->lastFocusReason, Qt::BacktabFocusReason); } diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index 5f84147792..5d9e6ba8dc 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -35,8 +35,9 @@ #include <QtTest/QTest> -#include <private/qquickwindow_p.h> -#include <private/qquickitemview_p_p.h> +#include <QtQuick/private/qquickdeliveryagent_p_p.h> +#include <QtQuick/private/qquickitemview_p_p.h> +#include <QtQuick/private/qquickwindow_p.h> QT_BEGIN_NAMESPACE @@ -460,10 +461,10 @@ namespace QQuickTouchUtils { void flush(QQuickWindow *window) { if (!window) return; - QQuickWindowPrivate *wd = QQuickWindowPrivate::get(window); - if (!wd || !wd->delayedTouch) + QQuickDeliveryAgentPrivate *da = QQuickWindowPrivate::get(window)->deliveryAgentPrivate(); + if (!da || !da->delayedTouch) return; - wd->deliverDelayedTouchEvent(); + da->deliverDelayedTouchEvent(); } } diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp index 33698b4141..ef0df0cddb 100644 --- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp +++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp @@ -194,7 +194,7 @@ public: switch (transition) { case QPointingDevice::GrabTransition::GrabExclusive: exclusiveGrabber = grabber; - fromMouseEvent = event && QQuickWindowPrivate::isMouseEvent(event); + fromMouseEvent = event && QQuickDeliveryAgentPrivate::isMouseEvent(event); canceled = false; break; case QPointingDevice::GrabTransition::UngrabExclusive: @@ -641,7 +641,7 @@ void tst_TouchMouse::buttonOnFlickable() QCOMPARE(eventItem1->eventList.at(0).type, QEvent::MouseButtonPress); QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(&window); - QVERIFY(windowPriv->touchMouseId != -1); + QVERIFY(windowPriv->deliveryAgentPrivate()->touchMouseId != -1); auto devPriv = QPointingDevicePrivate::get(device); QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, eventItem1); QCOMPARE(grabMonitor.exclusiveGrabber, eventItem1); @@ -662,7 +662,7 @@ void tst_TouchMouse::buttonOnFlickable() QCOMPARE(eventItem1->eventList.at(3).type, QEvent::UngrabMouse); QCOMPARE(grabMonitor.exclusiveGrabber, flickable); - QVERIFY(windowPriv->touchMouseId != -1); + QVERIFY(windowPriv->deliveryAgentPrivate()->touchMouseId != -1); QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, flickable); QTest::touchEvent(&window, device).release(0, p1, &window); @@ -696,7 +696,7 @@ void tst_TouchMouse::touchButtonOnFlickable() QCOMPARE(eventItem2->eventList.at(0).type, QEvent::TouchBegin); QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(&window); - QVERIFY(windowPriv->touchMouseId == -1); + QVERIFY(windowPriv->deliveryAgentPrivate()->touchMouseId == -1); auto devPriv = QPointingDevicePrivate::get(device); QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, eventItem2); QCOMPARE(grabMonitor.exclusiveGrabber, eventItem2); @@ -720,7 +720,7 @@ void tst_TouchMouse::touchButtonOnFlickable() QCOMPARE(eventItem2->eventList.at(1).type, QEvent::TouchUpdate); QCOMPARE(grabMonitor.exclusiveGrabber, flickable); // both EventItem and Flickable handled the actual touch, so synth-mouse doesn't happen - QCOMPARE(windowPriv->touchMouseId, -1); + QCOMPARE(windowPriv->deliveryAgentPrivate()->touchMouseId, -1); QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, flickable); QVERIFY(flickable->isMovingVertically()); @@ -783,7 +783,7 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable() // wait to avoid getting a double click event QTest::qWait(qApp->styleHints()->mouseDoubleClickInterval() + 10); QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(&window); - QCOMPARE(windowPriv->touchMouseId, -1); // no grabber + QCOMPARE(windowPriv->deliveryAgentPrivate()->touchMouseId, -1); // no grabber // touch press QPoint p1 = QPoint(10, 110); @@ -1535,7 +1535,7 @@ void tst_TouchMouse::implicitUngrab() QVERIFY(!eventItem->eventList.isEmpty()); QCOMPARE(eventItem->eventList.at(0).type, QEvent::UngrabMouse); QTest::touchEvent(&window, device).release(0, p1); // clean up potential state - QCOMPARE(windowPriv->touchMouseId, -1); + QCOMPARE(windowPriv->deliveryAgentPrivate()->touchMouseId, -1); eventItem->setEnabled(true); QTest::touchEvent(&window, device).press(0, p1); |