aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-07-23 13:56:26 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-09-18 20:56:25 +0200
commita97759a336c597327cb82eebc9f45c793aec32c9 (patch)
tree632bbee8568d38af56974e02df5810afcf48aedc /tests
parent39f4d687fc37f48cbc181f42797c42be91b4a345 (diff)
Remove QQuickPointerEvent etc.; deliver QPointerEvents directly
QEventPoint does not have an accessor to get the QPointerEvent that it came from, because that's inconsistent with the idea that QPointerEvent instances are temporary, stack-allocated and movable (the pointer would often be wrong or null, therefore could not be relied upon). So most functions that worked directly with QQuickEventPoint before (which fortunately are still private API) now need to receive the QPointerEvent too, which we choose to pass by pointer. QEventPoint is always passed by reference (const where possible) to be consistent with functions in QPointerEvent that take QEventPoint by reference. QEventPoint::velocity() should be always in scene coordinates now, which saves us the trouble of transforming it to each item's coordinate system during delivery, but means that it will need to be done in handlers or applications sometimes. If we were going to transform it, it would be important to also store the sceneVelocity separately in QEventPoint so that the transformation could be done repeatedly for different items. Task-number: QTBUG-72173 Change-Id: I7ee164d2e6893c4e407fb7d579c75aa32843933a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp14
-rw-r--r--tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp53
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp18
-rw-r--r--tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp97
-rw-r--r--tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp6
-rw-r--r--tests/auto/quick/qquickflickable/data/nestedPressDelay.qml1
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp11
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp16
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp112
-rw-r--r--tests/auto/quick/touchmouse/tst_touchmouse.cpp124
-rw-r--r--tests/manual/pointer/inputinspector.cpp42
-rw-r--r--tests/manual/pointer/inputinspector.h4
-rw-r--r--tests/manual/pointer/singlePointHandlerProperties.qml2
-rw-r--r--tests/manual/pointer/tapHandler.qml2
14 files changed, 250 insertions, 252 deletions
diff --git a/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp b/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp
index 26b6e0540b..44d0e9a27a 100644
--- a/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp
+++ b/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp
@@ -34,6 +34,7 @@
#include <QtQuick/private/qquickmousearea_p.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
+#include <QtGui/private/qpointingdevice_p.h>
#include "../../../shared/util.h"
#include "../../shared/viewtestutil.h"
@@ -76,7 +77,6 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaMouse
QScopedPointer<QQuickView> windowPtr;
createView(windowPtr, "dragTakeOverFromSibling.qml");
QQuickView * window = windowPtr.data();
- auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(QPointingDevice::primaryPointingDevice());
QPointer<QQuickPointerHandler> handler = window->rootObject()->findChild<QQuickPointerHandler*>();
QVERIFY(handler);
@@ -92,10 +92,12 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaMouse
// DragHandler keeps monitoring, due to its passive grab,
// and eventually steals the exclusive grab from MA
int dragStoleGrab = 0;
+ auto devPriv = QPointingDevicePrivate::get(QPointingDevice::primaryPointingDevice());
for (int i = 0; i < 4; ++i) {
p1 += QPoint(dragThreshold / 2, 0);
QTest::mouseMove(window, p1);
- if (!dragStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == handler)
+
+ if (!dragStoleGrab && devPriv->pointById(0)->exclusiveGrabber == handler)
dragStoleGrab = i;
}
if (dragStoleGrab)
@@ -124,7 +126,7 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch
QScopedPointer<QQuickView> windowPtr;
createView(windowPtr, "dragTakeOverFromSibling.qml");
QQuickView * window = windowPtr.data();
- auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchDevice);
+ auto devPriv = QPointingDevicePrivate::get(QPointingDevice::primaryPointingDevice());
QPointer<QQuickPointerHandler> handler = window->rootObject()->findChild<QQuickPointerHandler*>();
QVERIFY(handler);
@@ -137,8 +139,8 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch
touch.press(1, p1).commit();
QQuickTouchUtils::flush(window);
- QTRY_VERIFY(pointerEvent->point(0)->passiveGrabbers().contains(handler));
- QCOMPARE(pointerEvent->point(0)->grabberItem(), ma);
+ QTRY_VERIFY(devPriv->pointById(0)->passiveGrabbers.contains(handler.data()));
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, ma);
QCOMPARE(window->mouseGrabberItem(), ma);
QCOMPARE(ma->pressed(), true);
@@ -150,7 +152,7 @@ void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch
p1 += QPoint(dragThreshold / 2, 0);
touch.move(1, p1).commit();
QQuickTouchUtils::flush(window);
- if (!dragStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == handler)
+ if (!dragStoleGrab && devPriv->pointById(0)->exclusiveGrabber == handler)
dragStoleGrab = i;
}
if (dragStoleGrab)
diff --git a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
index 82e9b4e71f..9a278cd570 100644
--- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
+++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
@@ -35,6 +35,7 @@
#include <QtQuick/private/qquickpinchhandler_p.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
+#include <QtGui/private/qpointingdevice_p.h>
#include "../../../shared/util.h"
#include "../../shared/viewtestutil.h"
@@ -108,9 +109,9 @@ void tst_MptaInterop::touchDrag()
QPoint p1 = mpta->mapToScene(QPointF(20, 20)).toPoint();
touch.press(1, p1).commit();
QQuickTouchUtils::flush(window);
- auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchDevice);
+ auto devPriv = QPointingDevicePrivate::get(touchDevice);
QCOMPARE(tp.at(0)->property("pressed").toBool(), true);
- QTRY_VERIFY(pointerEvent->point(0)->passiveGrabbers().contains(drag));
+ QTRY_VERIFY(devPriv->pointById(0)->passiveGrabbers.contains(drag));
// Start moving
// DragHandler keeps monitoring, due to its passive grab,
@@ -120,7 +121,7 @@ void tst_MptaInterop::touchDrag()
p1 += QPoint(dragThreshold / 2, 0);
touch.move(1, p1).commit();
QQuickTouchUtils::flush(window);
- if (!dragStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == drag)
+ if (!dragStoleGrab && devPriv->pointById(0)->exclusiveGrabber == drag)
dragStoleGrab = i;
}
if (dragStoleGrab)
@@ -150,7 +151,7 @@ void tst_MptaInterop::touchesThenPinch()
QSignalSpy mptaReleasedSpy(mpta, SIGNAL(released(QList<QObject*>)));
QSignalSpy mptaCanceledSpy(mpta, SIGNAL(canceled(QList<QObject*>)));
QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchDevice);
- auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchDevice);
+ auto devPriv = QPointingDevicePrivate::get(touchDevice);
// Press one touchpoint:
// DragHandler gets a passive grab
@@ -159,8 +160,8 @@ void tst_MptaInterop::touchesThenPinch()
QPoint p1 = mpta->mapToScene(QPointF(20, 20)).toPoint();
touch.press(1, p1).commit();
QQuickTouchUtils::flush(window);
- QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
- QTRY_COMPARE(pointerEvent->point(0)->passiveGrabbers().first(), drag);
+ QTRY_COMPARE(devPriv->pointById(0)->exclusiveGrabber, mpta);
+ QTRY_COMPARE(devPriv->pointById(0)->passiveGrabbers.first(), drag);
// Press a second touchpoint: MPTA grabs it
QPoint p2 = mpta->mapToScene(QPointF(200, 30)).toPoint();
@@ -179,9 +180,9 @@ void tst_MptaInterop::touchesThenPinch()
QCOMPARE(tp.at(2)->property("pressed").toBool(), true);
QCOMPARE(mptaPressedSpy.count(), 3);
QCOMPARE(mptaCanceledSpy.count(), 0);
- QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
- QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta);
- QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta);
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, mpta);
+ QCOMPARE(devPriv->pointById(1)->exclusiveGrabber, mpta);
+ QCOMPARE(devPriv->pointById(2)->exclusiveGrabber, mpta);
QVERIFY(!pinch->active());
// Start moving: PinchHandler steals the exclusive grab from MPTA as soon as dragThreshold is exceeded
@@ -197,7 +198,7 @@ void tst_MptaInterop::touchesThenPinch()
p3 = xform.map(p3);
touch.move(1, p1).move(2, p2).move(3, p3).commit();
QQuickTouchUtils::flush(window);
- if (!pinchStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == pinch) {
+ if (!pinchStoleGrab && devPriv->pointById(0)->exclusiveGrabber == pinch) {
pinchStoleGrab = i;
QCOMPARE(tp.at(0)->property("pressed").toBool(), false);
QCOMPARE(tp.at(1)->property("pressed").toBool(), false);
@@ -212,10 +213,10 @@ void tst_MptaInterop::touchesThenPinch()
QPoint p4 = mpta->mapToScene(QPointF(300, 200)).toPoint();
touch.move(1, p1).move(2, p2).move(3, p3).press(4, p4).commit();
// PinchHandler deactivates, which lets MPTA grab all the points
- QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
- QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta);
- QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta);
- QCOMPARE(pointerEvent->point(3)->exclusiveGrabber(), mpta);
+ QTRY_COMPARE(devPriv->pointById(0)->exclusiveGrabber, mpta);
+ QCOMPARE(devPriv->pointById(1)->exclusiveGrabber, mpta);
+ QCOMPARE(devPriv->pointById(2)->exclusiveGrabber, mpta);
+ QCOMPARE(devPriv->pointById(3)->exclusiveGrabber, mpta);
// Move some more... MPTA keeps reacting
for (int i = 0; i < 8; ++i) {
p1 += QPoint(4, 4);
@@ -223,10 +224,10 @@ void tst_MptaInterop::touchesThenPinch()
p3 += QPoint(-4, 4);
p4 += QPoint(-4, -4);
touch.move(1, p1).move(2, p2).move(3, p3).move(4, p4).commit();
- QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
- QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta);
- QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta);
- QCOMPARE(pointerEvent->point(3)->exclusiveGrabber(), mpta);
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, mpta);
+ QCOMPARE(devPriv->pointById(1)->exclusiveGrabber, mpta);
+ QCOMPARE(devPriv->pointById(2)->exclusiveGrabber, mpta);
+ QCOMPARE(devPriv->pointById(3)->exclusiveGrabber, mpta);
QCOMPARE(tp.at(0)->property("pressed").toBool(), true);
QCOMPARE(tp.at(1)->property("pressed").toBool(), true);
QCOMPARE(tp.at(2)->property("pressed").toBool(), true);
@@ -241,9 +242,9 @@ void tst_MptaInterop::touchesThenPinch()
p2 += QPoint(4, 4);
p3 -= QPoint(-4, 4);
touch.move(1, p1).move(2, p2).move(3, p3).commit();
- QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), pinch);
- QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), pinch);
- QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), pinch);
+ QTRY_COMPARE(devPriv->pointById(0)->exclusiveGrabber, pinch);
+ QCOMPARE(devPriv->pointById(1)->exclusiveGrabber, pinch);
+ QCOMPARE(devPriv->pointById(2)->exclusiveGrabber, pinch);
}
// Release the first finger
@@ -267,12 +268,12 @@ void tst_MptaInterop::touchesThenPinch()
p2 += QPoint(8, -8);
touch.move(2, p2).commit();
QQuickTouchUtils::flush(window);
- QVERIFY(pointerEvent->point(0)->passiveGrabbers().contains(drag));
- if (!dragTookGrab && pointerEvent->point(0)->exclusiveGrabber() == drag)
+ QVERIFY(devPriv->pointById(0)->passiveGrabbers.contains(drag));
+ if (!dragTookGrab && devPriv->pointById(0)->exclusiveGrabber == drag)
dragTookGrab = i;
}
qCDebug(lcPointerTests) << "drag started after" << dragTookGrab << "moves; ended with translation" << drag->translation();
- QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), drag);
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, drag);
QTRY_VERIFY(drag->translation().x() > 0);
touch.release(2, p2).commit();
@@ -304,7 +305,7 @@ void tst_MptaInterop::dragHandlerInParentStealingGrabFromItem() // QTBUG-75025
QScopedPointer<QQuickView> windowPtr;
createView(windowPtr, "dragParentOfMPTA.qml");
QQuickView * window = windowPtr.data();
- auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(QPointingDevice::primaryPointingDevice());
+ auto devPriv = QPointingDevicePrivate::get(touchDevice);
QPointer<QQuickPointerHandler> handler = window->rootObject()->findChild<QQuickPointerHandler*>();
QVERIFY(handler);
@@ -326,7 +327,7 @@ void tst_MptaInterop::dragHandlerInParentStealingGrabFromItem() // QTBUG-75025
for (int i = 0; i < 4; ++i) {
point += QPoint(dragThreshold / 2, 0);
QTest::mouseMove(window, point);
- if (!dragStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == handler)
+ if (!dragStoleGrab && devPriv->pointById(0)->exclusiveGrabber == handler)
dragStoleGrab = i;
}
if (dragStoleGrab)
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
index a5884659b3..9c9ca2fe00 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
@@ -35,6 +35,7 @@
#include <QtQuick/private/qquicktaphandler_p.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
+#include <QtGui/private/qpointingdevice_p.h>
#include "../../../shared/util.h"
#include "../../shared/viewtestutil.h"
@@ -90,15 +91,14 @@ void tst_DragHandler::createView(QScopedPointer<QQuickView> &window, const char
QSet<QQuickPointerHandler*> tst_DragHandler::passiveGrabbers(QQuickWindow *window, int pointId /*= 0*/)
{
+ Q_UNUSED(window);
QSet<QQuickPointerHandler*> result;
- QQuickWindowPrivate *winp = QQuickWindowPrivate::get(window);
- QQuickPointerEvent *pointerEvent = winp->pointerEventInstance(touchDevice);
- for (int i = 0; i < pointerEvent->pointCount(); ++i) {
- QQuickEventPoint *eventPoint = pointerEvent->point(i);
- QVector<QPointer <QQuickPointerHandler> > passives = eventPoint->passiveGrabbers();
- if (!pointId || eventPoint->pointId() == pointId) {
+ auto devPriv = QPointingDevicePrivate::get(touchDevice);
+ for (auto &epd : devPriv->activePoints.values()) {
+ auto passives = epd.passiveGrabbers;
+ if (!pointId || epd.eventPoint.id() == pointId) {
for (auto it = passives.constBegin(); it != passives.constEnd(); ++it)
- result << it->data();
+ result << qobject_cast<QQuickPointerHandler *>(it->data());
}
}
return result;
@@ -263,7 +263,7 @@ void tst_DragHandler::mouseDrag()
p1 += QPoint(dragThreshold, 0);
QTest::mouseMove(window, p1);
if (shouldDrag) {
- QTRY_VERIFY(dragHandler->centroid().velocity().x() > 0);
+// QTRY_VERIFY(dragHandler->centroid().velocity().x() > 0); // TODO QTBUG-33891
QCOMPARE(centroidChangedSpy.count(), 2);
QVERIFY(!dragHandler->active());
#if QT_CONFIG(cursor)
@@ -294,7 +294,7 @@ void tst_DragHandler::mouseDrag()
QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos);
QCOMPARE(dragHandler->translation().x(), dragThreshold + 20.0);
QCOMPARE(dragHandler->translation().y(), 0.0);
- QVERIFY(dragHandler->centroid().velocity().x() > 0);
+// QVERIFY(dragHandler->centroid().velocity().x() > 0); // TODO QTBUG-33891
QCOMPARE(centroidChangedSpy.count(), 4);
#if QT_CONFIG(cursor)
QCOMPARE(window->cursor().shape(), Qt::ClosedHandCursor);
diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
index 6f81e6b566..a4ff2477bb 100644
--- a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp
@@ -30,6 +30,7 @@
#include <private/qdebug_p.h>
#include <QtGui/qstylehints.h>
+#include <QtGui/private/qpointingdevice_p.h>
#include <QtQuick/private/qquickpointerhandler_p.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
@@ -58,7 +59,7 @@ public:
Destination destination;
QEvent::Type type; // if this represents a QEvent that was received
QEventPoint::State state; // if this represents an event (pointer, touch or mouse)
- int grabTransition; // if this represents an onGrabChanged() notification (QQuickEventPoint::GrabTransition)
+ int grabTransition; // if this represents an onGrabChanged() notification (QPointingDevice::GrabTransition)
QPointF posWrtItem;
QPointF posWrtScene;
};
@@ -75,7 +76,7 @@ QDebug operator<<(QDebug dbg, const class Event &event) {
QtDebugUtils::formatQEnum(dbg, event.state);
if (event.grabTransition) {
dbg << ' ';
- QtDebugUtils::formatQEnum(dbg, QQuickEventPoint::GrabTransition(event.grabTransition));
+ QtDebugUtils::formatQEnum(dbg, QPointingDevice::GrabTransition(event.grabTransition));
}
dbg << " @ ";
QtDebugUtils::formatQPoint(dbg, event.posWrtItem);
@@ -99,13 +100,13 @@ public:
{}
inline int grabTransition(bool accept, QEventPoint::State state) {
- return (accept && (state != QEventPoint::State::Released)) ? (int)QQuickEventPoint::GrabExclusive : (int)NoGrab;
+ return (accept && (state != QEventPoint::State::Released)) ? (int)QPointingDevice::GrabExclusive : (int)NoGrab;
}
void touchEvent(QTouchEvent *event)
{
qCDebug(lcPointerTests) << event << "will accept?" << acceptTouch;
- for (const QEventPoint &tp : event->touchPoints())
+ for (auto &tp : event->points())
eventList.append(Event(Event::TouchDestination, event->type(), tp.state(), grabTransition(acceptTouch, tp.state()), tp.position(), tp.scenePosition()));
event->setAccepted(acceptTouch);
}
@@ -137,7 +138,7 @@ public:
void mouseUngrabEvent()
{
qCDebug(lcPointerTests);
- eventList.append(Event(Event::MouseDestination, QEvent::UngrabMouse, QEventPoint::State::Released, QQuickEventPoint::UngrabExclusive, QPoint(0,0), QPoint(0,0)));
+ eventList.append(Event(Event::MouseDestination, QEvent::UngrabMouse, QEventPoint::State::Released, QPointingDevice::UngrabExclusive, QPoint(0,0), QPoint(0,0)));
}
bool event(QEvent *event)
@@ -161,8 +162,9 @@ public:
event->type() == QEvent::TouchCancel ||
event->type() == QEvent::TouchEnd) {
QTouchEvent *touch = static_cast<QTouchEvent*>(event);
- for (const QEventPoint &tp : touch->touchPoints())
- eventList.append(Event(Event::FilterDestination, event->type(), tp.state(), QQuickEventPoint::GrabExclusive, tp.position(), tp.scenePosition()));
+ for (auto &tp : touch->points())
+ eventList.append(Event(Event::FilterDestination, event->type(), tp.state(),
+ QPointingDevice::GrabExclusive, tp.position(), tp.scenePosition()));
if (filterTouch)
event->accept();
return true;
@@ -183,42 +185,43 @@ public:
class EventHandler : public QQuickPointerHandler
{
public:
- void handlePointerEventImpl(QQuickPointerEvent *event) override
+ void handlePointerEventImpl(QPointerEvent *event) override
{
QQuickPointerHandler::handlePointerEventImpl(event);
if (!enabled())
return;
- if (event->isPressEvent())
+ if (event->isBeginEvent())
++pressEventCount;
- if (event->isReleaseEvent())
+ if (event->isEndEvent())
++releaseEventCount;
EventItem *item = qmlobject_cast<EventItem *>(target());
if (!item) {
- event->point(0)->setGrabberPointerHandler(this);
+ event->setExclusiveGrabber(event->point(0), this);
return;
}
qCDebug(lcPointerTests) << item->objectName() << event;
- int c = event->pointCount();
- for (int i = 0; i < c; ++i) {
- QQuickEventPoint *point = event->point(i);
+ for (auto point : event->points()) {
if (item->acceptPointer)
- point->setAccepted(item->acceptPointer); // does NOT imply a grab
+ point.setAccepted(item->acceptPointer); // does NOT imply a grab
if (item->grabPointer)
- setExclusiveGrab(point, true);
- qCDebug(lcPointerTests) << " " << i << ":" << point << "accepted?" << item->acceptPointer << "grabbed?" << (point->exclusiveGrabber() == this);
+ setExclusiveGrab(event, point, true);
+ qCDebug(lcPointerTests) << " " << point << "accepted?" << item->acceptPointer
+ << "grabbed?" << (event->exclusiveGrabber(point) == this);
item->eventList.append(Event(Event::HandlerDestination, QEvent::Pointer,
- static_cast<QEventPoint::State>(point->state()),
- item->grabPointer ? (int)QQuickEventPoint::GrabExclusive : (int)NoGrab,
- eventPos(point), point->scenePosition()));
+ static_cast<QEventPoint::State>(point.state()),
+ item->grabPointer ? (int)QPointingDevice::GrabExclusive : (int)NoGrab,
+ eventPos(point), point.scenePosition()));
}
}
- void onGrabChanged(QQuickPointerHandler *, QQuickEventPoint::GrabTransition stateChange, QQuickEventPoint *point) override
+ void onGrabChanged(QQuickPointerHandler *, QPointingDevice::GrabTransition stateChange,
+ QPointerEvent *ev, QEventPoint &point) override
{
+ Q_UNUSED(ev);
EventItem *item = qmlobject_cast<EventItem *>(target());
if (item)
item->eventList.append(Event(Event::HandlerDestination, QEvent::None,
- static_cast<QEventPoint::State>(point->state()), stateChange, eventPos(point), point->scenePosition()));
+ static_cast<QEventPoint::State>(point.state()), stateChange, eventPos(point), point.scenePosition()));
}
int pressEventCount = 0;
@@ -342,15 +345,15 @@ void tst_PointerHandlers::touchEventDelivery()
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Pressed, NoGrab);
- QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, QEventPoint::State::Pressed, QQuickEventPoint::GrabExclusive);
- auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchDevice);
- QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), eventItem1);
+ QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, QEventPoint::State::Pressed, QPointingDevice::GrabExclusive);
+ auto devPriv = QPointingDevicePrivate::get(touchDevice);
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, eventItem1);
p1 += QPoint(10, 0);
QTest::touchEvent(window, touchDevice).move(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 4);
QCOMPARE_EVENT(2, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Updated, NoGrab);
- QCOMPARE_EVENT(3, Event::TouchDestination, QEvent::TouchUpdate, QEventPoint::State::Updated, QQuickEventPoint::GrabExclusive);
+ QCOMPARE_EVENT(3, Event::TouchDestination, QEvent::TouchUpdate, QEventPoint::State::Updated, QPointingDevice::GrabExclusive);
QTest::touchEvent(window, touchDevice).release(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 6);
@@ -372,7 +375,7 @@ void tst_PointerHandlers::touchEventDelivery()
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Pressed, NoGrab);
QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, QEventPoint::State::Pressed, NoGrab);
if (synthMouse)
- QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, QEventPoint::State::Pressed, QQuickEventPoint::GrabExclusive);
+ QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, QEventPoint::State::Pressed, QPointingDevice::GrabExclusive);
QCOMPARE(window->mouseGrabberItem(), synthMouse ? eventItem1 : nullptr);
QPointF localPos = eventItem1->mapFromScene(p1);
@@ -391,7 +394,7 @@ void tst_PointerHandlers::touchEventDelivery()
if (synthMouse) {
QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Updated, NoGrab);
QCOMPARE_EVENT(4, Event::TouchDestination, QEvent::TouchUpdate, QEventPoint::State::Updated, NoGrab);
- QCOMPARE_EVENT(5, Event::MouseDestination, QEvent::MouseMove, QEventPoint::State::Updated, QQuickEventPoint::GrabExclusive);
+ QCOMPARE_EVENT(5, Event::MouseDestination, QEvent::MouseMove, QEventPoint::State::Updated, QPointingDevice::GrabExclusive);
}
QTest::touchEvent(window, touchDevice).release(0, p1, window);
QQuickTouchUtils::flush(window);
@@ -400,7 +403,7 @@ void tst_PointerHandlers::touchEventDelivery()
QCOMPARE_EVENT(6, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Released, NoGrab);
QCOMPARE_EVENT(7, Event::TouchDestination, QEvent::TouchEnd, QEventPoint::State::Released, NoGrab);
QCOMPARE_EVENT(8, Event::MouseDestination, QEvent::MouseButtonRelease, QEventPoint::State::Released, NoGrab);
- QCOMPARE_EVENT(9, Event::MouseDestination, QEvent::UngrabMouse, QEventPoint::State::Released, QQuickEventPoint::UngrabExclusive);
+ QCOMPARE_EVENT(9, Event::MouseDestination, QEvent::UngrabMouse, QEventPoint::State::Released, QPointingDevice::UngrabExclusive);
} else {
QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Released, NoGrab);
}
@@ -421,7 +424,7 @@ void tst_PointerHandlers::touchEventDelivery()
QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, QEventPoint::State::Pressed, NoGrab);
if (synthMouse)
QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, QEventPoint::State::Pressed, NoGrab);
- QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), nullptr);
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, nullptr);
p1 += QPoint(10, 0);
QTest::touchEvent(window, touchDevice).move(0, p1, window);
QQuickTouchUtils::flush(window);
@@ -442,13 +445,13 @@ void tst_PointerHandlers::touchEventDelivery()
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Pressed, NoGrab);
- QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, QEventPoint::State::Pressed, QQuickEventPoint::GrabExclusive);
+ QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, QEventPoint::State::Pressed, QPointingDevice::GrabExclusive);
p1 += QPoint(10, 0);
QTest::touchEvent(window, touchDevice).move(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 4);
QCOMPARE_EVENT(2, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Updated, NoGrab);
- QCOMPARE_EVENT(3, Event::TouchDestination, QEvent::TouchUpdate, QEventPoint::State::Updated, QQuickEventPoint::GrabExclusive);
+ QCOMPARE_EVENT(3, Event::TouchDestination, QEvent::TouchUpdate, QEventPoint::State::Updated, QPointingDevice::GrabExclusive);
QTest::touchEvent(window, touchDevice).release(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 6);
@@ -463,19 +466,19 @@ void tst_PointerHandlers::touchEventDelivery()
QTest::touchEvent(window, touchDevice).press(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 2);
- QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::None, QEventPoint::State::Pressed, QQuickEventPoint::GrabExclusive);
- QCOMPARE_EVENT(1, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Pressed, QQuickEventPoint::GrabExclusive);
+ QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::None, QEventPoint::State::Pressed, QPointingDevice::GrabExclusive);
+ QCOMPARE_EVENT(1, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Pressed, QPointingDevice::GrabExclusive);
p1 += QPoint(10, 0);
QTest::touchEvent(window, touchDevice).move(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 3);
- QCOMPARE_EVENT(2, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Updated, QQuickEventPoint::GrabExclusive);
+ QCOMPARE_EVENT(2, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Updated, QPointingDevice::GrabExclusive);
QTest::touchEvent(window, touchDevice).release(0, p1, window);
QQuickTouchUtils::flush(window);
QCOMPARE(eventItem1->eventList.size(), 5);
qCDebug(lcPointerTests) << eventItem1->eventList;
- QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Released, QQuickEventPoint::GrabExclusive);
- QCOMPARE_EVENT(4, Event::HandlerDestination, QEvent::None, QEventPoint::State::Released, QQuickEventPoint::UngrabExclusive);
+ QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Released, QPointingDevice::GrabExclusive);
+ QCOMPARE_EVENT(4, Event::HandlerDestination, QEvent::None, QEventPoint::State::Released, QPointingDevice::UngrabExclusive);
eventItem1->eventList.clear();
}
@@ -510,7 +513,7 @@ void tst_PointerHandlers::mouseEventDelivery()
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
QCOMPARE(eventItem1->eventList.size(), 2);
QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Pressed, NoGrab);
- QCOMPARE_EVENT(1, Event::MouseDestination, QEvent::MouseButtonPress, QEventPoint::State::Pressed, QQuickEventPoint::GrabExclusive);
+ QCOMPARE_EVENT(1, Event::MouseDestination, QEvent::MouseButtonPress, QEventPoint::State::Pressed, QPointingDevice::GrabExclusive);
QCOMPARE(window->mouseGrabberItem(), eventItem1);
QPointF localPos = eventItem1->mapFromScene(p1);
@@ -523,11 +526,11 @@ void tst_PointerHandlers::mouseEventDelivery()
p1 += QPoint(10, 0);
QTest::mouseMove(window, p1);
QCOMPARE(eventItem1->eventList.size(), 3);
- QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseMove, QEventPoint::State::Updated, QQuickEventPoint::GrabExclusive);
+ QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseMove, QEventPoint::State::Updated, QPointingDevice::GrabExclusive);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
QCOMPARE(eventItem1->eventList.size(), 5);
QCOMPARE_EVENT(3, Event::MouseDestination, QEvent::MouseButtonRelease, QEventPoint::State::Released, NoGrab);
- QCOMPARE_EVENT(4, Event::MouseDestination, QEvent::UngrabMouse, QEventPoint::State::Released, QQuickEventPoint::UngrabExclusive);
+ QCOMPARE_EVENT(4, Event::MouseDestination, QEvent::UngrabMouse, QEventPoint::State::Released, QPointingDevice::UngrabExclusive);
eventItem1->eventList.clear();
// wait to avoid getting a double click event
@@ -540,17 +543,17 @@ void tst_PointerHandlers::mouseEventDelivery()
p1 = QPoint(20, 20);
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
QTRY_COMPARE(eventItem1->eventList.size(), 3);
- QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::None, QEventPoint::State::Pressed, QQuickEventPoint::GrabExclusive);
- QCOMPARE_EVENT(1, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Pressed, QQuickEventPoint::GrabExclusive);
+ QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::None, QEventPoint::State::Pressed, QPointingDevice::GrabExclusive);
+ QCOMPARE_EVENT(1, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Pressed, QPointingDevice::GrabExclusive);
QCOMPARE_EVENT(2, Event::MouseDestination, QEvent::MouseButtonPress, QEventPoint::State::Pressed, 0);
p1 += QPoint(10, 0);
QTest::mouseMove(window, p1);
QCOMPARE(eventItem1->eventList.size(), 4);
- QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Updated, QQuickEventPoint::GrabExclusive);
+ QCOMPARE_EVENT(3, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Updated, QPointingDevice::GrabExclusive);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
QCOMPARE(eventItem1->eventList.size(), 6);
- QCOMPARE_EVENT(4, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Released, QQuickEventPoint::GrabExclusive);
- QCOMPARE_EVENT(5, Event::HandlerDestination, QEvent::None, QEventPoint::State::Released, QQuickEventPoint::UngrabExclusive);
+ QCOMPARE_EVENT(4, Event::HandlerDestination, QEvent::Pointer, QEventPoint::State::Released, QPointingDevice::GrabExclusive);
+ QCOMPARE_EVENT(5, Event::HandlerDestination, QEvent::None, QEventPoint::State::Released, QPointingDevice::UngrabExclusive);
eventItem1->eventList.clear();
}
@@ -568,11 +571,11 @@ void tst_PointerHandlers::touchReleaseOutside_data()
QTest::newRow("reject and ignore") << false << false << 6 << 5 << (int)Event::TouchDestination
<< (int)QEvent::TouchEnd << (int)QEventPoint::State::Released << (int)NoGrab;
QTest::newRow("reject and grab") << false << true << 5 << 4 << (int)Event::HandlerDestination
- << (int)QEvent::None << (int)QEventPoint::State::Released << (int)QQuickEventPoint::UngrabExclusive;
+ << (int)QEvent::None << (int)QEventPoint::State::Released << (int)QPointingDevice::UngrabExclusive;
QTest::newRow("accept and ignore") << true << false << 1 << 0 << (int)Event::HandlerDestination
<< (int)QEvent::Pointer << (int)QEventPoint::State::Pressed << (int)NoGrab;
QTest::newRow("accept and grab") << true << true << 5 << 4 << (int)Event::HandlerDestination
- << (int)QEvent::None << (int)QEventPoint::State::Released << (int)QQuickEventPoint::UngrabExclusive;
+ << (int)QEvent::None << (int)QEventPoint::State::Released << (int)QPointingDevice::UngrabExclusive;
}
void tst_PointerHandlers::touchReleaseOutside()
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
index 89de571abd..43b1affc09 100644
--- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp
@@ -685,8 +685,8 @@ void tst_TapHandler::componentUserBehavioralOverride()
QQuickTapHandler *userTapHandler = button->findChild<QQuickTapHandler*>("override");
QVERIFY(userTapHandler);
QSignalSpy tappedSpy(button, SIGNAL(tapped()));
- QSignalSpy innerGrabChangedSpy(innerTapHandler, SIGNAL(grabChanged(QQuickEventPoint::GrabTransition, QQuickEventPoint *)));
- QSignalSpy userGrabChangedSpy(userTapHandler, SIGNAL(grabChanged(QQuickEventPoint::GrabTransition, QQuickEventPoint *)));
+ QSignalSpy innerGrabChangedSpy(innerTapHandler, SIGNAL(grabChanged(QPointingDevice::GrabTransition, QEventPoint *)));
+ QSignalSpy userGrabChangedSpy(userTapHandler, SIGNAL(grabChanged(QPointingDevice::GrabTransition, QEventPoint *)));
QSignalSpy innerPressedChangedSpy(innerTapHandler, SIGNAL(pressedChanged()));
QSignalSpy userPressedChangedSpy(userTapHandler, SIGNAL(pressedChanged()));
@@ -715,7 +715,7 @@ void tst_TapHandler::rightLongPressIgnoreWheel()
QQuickTapHandler *tap = window->rootObject()->findChild<QQuickTapHandler*>();
QVERIFY(tap);
- QSignalSpy tappedSpy(tap, SIGNAL(tapped(QQuickEventPoint *)));
+ QSignalSpy tappedSpy(tap, SIGNAL(tapped(QEventPoint *)));
QSignalSpy longPressedSpy(tap, SIGNAL(longPressed()));
QPoint p1(100, 100);
diff --git a/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
index bdb866ce65..3cc0987141 100644
--- a/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
+++ b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
@@ -1,6 +1,7 @@
import QtQuick 2.0
Flickable {
+ objectName: "outerFlickable"
property bool pressed: ma.pressed
width: 240
height: 320
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index f6a6ab17b4..0a75690904 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -65,11 +65,7 @@ public:
, ungrabs(0)
, m_active(false)
{
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
setAcceptTouchEvents(true);
-#else
- setAcceptedMouseButtons(Qt::LeftButton); // not really, but we want touch events
-#endif
}
QPointF pos() const { return m_pos; }
@@ -97,8 +93,8 @@ public:
protected:
void touchEvent(QTouchEvent *ev) override
{
- QCOMPARE(ev->touchPoints().count(), 1);
- auto touchpoint = ev->touchPoints().first();
+ QCOMPARE(ev->points().count(), 1);
+ auto touchpoint = ev->points().first();
switch (touchpoint.state()) {
case QEventPoint::State::Pressed:
QVERIFY(!m_active);
@@ -115,6 +111,7 @@ protected:
++touchReleases;
emit activeChanged();
case QEventPoint::State::Stationary:
+ case QEventPoint::State::Unknown:
break;
}
touchPointStates << touchpoint.state();
@@ -1566,6 +1563,8 @@ void tst_qquickflickable::cancelOnHide()
void tst_qquickflickable::cancelOnMouseGrab()
{
+ QSKIP("need a realistic test scenario: can no longer grab mouse between events");
+
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("cancel.qml"));
QTRY_COMPARE(window->status(), QQuickView::Ready);
diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
index 47f7943d12..1cb5591519 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
+++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -36,6 +36,7 @@
#include <QtQuick/qquickview.h>
#include <QtGui/QScreen>
#include <QtGui/private/qevent_p.h>
+#include <QtGui/private/qpointingdevice_p.h>
#include "../../shared/util.h"
#include "../shared/viewtestutil.h"
@@ -814,7 +815,6 @@ void tst_QQuickMultiPointTouchArea::inFlickableWithPressDelay() // QTBUG-78818
const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
QScopedPointer<QQuickView> window(createAndShowView("inFlickable.qml"));
QVERIFY(window->rootObject() != nullptr);
- QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window.data());
QQuickFlickable *flickable = qobject_cast<QQuickFlickable *>(window->rootObject());
QVERIFY(flickable != nullptr);
@@ -831,8 +831,8 @@ void tst_QQuickMultiPointTouchArea::inFlickableWithPressDelay() // QTBUG-78818
QTest::touchEvent(window.data(), device).press(0, p1);
QQuickTouchUtils::flush(window.data());
QTRY_COMPARE(point11->pressed(), true);
- auto pointerEvent = windowPriv->pointerEventInstance(device);
- QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
+ auto devPriv = QPointingDevicePrivate::get(device);
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, mpta);
// release: MPTA receives TouchEnd (which is asymmetric with mouse press); does NOT emit canceled.
QTest::touchEvent(window.data(), device).release(0, p1);
@@ -843,18 +843,18 @@ void tst_QQuickMultiPointTouchArea::inFlickableWithPressDelay() // QTBUG-78818
QTest::touchEvent(window.data(), device).press(0, p1);
QQuickTouchUtils::flush(window.data());
QTRY_COMPARE(point11->pressed(), true); // wait until pressDelay exceeded
- QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, mpta);
// drag past the threshold: Flickable takes over the grab, MPTA gets touchUngrab and is no longer pressed
int i = 0;
- for (; i < 10 && window->mouseGrabberItem() != flickable; ++i) {
+ for (; i < 10 && devPriv->firstPointExclusiveGrabber() != flickable; ++i) {
p1 += QPoint(0,dragThreshold);
QTest::touchEvent(window.data(), device).move(0, p1);
QQuickTouchUtils::flush(window.data());
}
- QCOMPARE(window->mouseGrabberItem(), flickable);
+ QCOMPARE(devPriv->firstPointExclusiveGrabber(), flickable);
qCDebug(lcTests, "Flickable stole grab from MPTA after %d moves", i);
- QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), flickable);
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, flickable);
QCOMPARE(point11->pressed(), false);
QVERIFY(flickable->property("cancelCount").toInt() > 0); // actually 2 because 2 touchPoints are declared... but only one was really cancelled
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index cfccfe88ba..dd95ab1808 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -85,12 +85,23 @@ static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, QEventPoint::
const QList<QEventPoint>& touchPoints = QList<QEventPoint>())
{
TouchEventData d = { type, nullptr, w, states, touchPoints };
+ for (auto &pt : d.touchPoints)
+ QMutableEventPoint::from(pt).detach();
+ return d;
+}
+static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, QEventPoint::States states,
+ const QList<QEventPoint*>& touchPoints)
+{
+ QList <QEventPoint> pts;
+ for (auto pt : touchPoints)
+ pts << *pt;
+ TouchEventData d = { type, nullptr, w, states, pts };
return d;
}
static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, QEventPoint::States states, const QEventPoint &touchPoint)
{
- QList<QEventPoint> points;
- points << touchPoint;
+ QList<QEventPoint*> points;
+ points << const_cast<QEventPoint *>(&touchPoint);
return makeTouchData(type, w, states, points);
}
@@ -157,6 +168,7 @@ public:
{
border()->setWidth(1);
setAcceptedMouseButtons(Qt::LeftButton);
+ setAcceptTouchEvents(true);
setFiltersChildMouseEvents(true);
}
@@ -165,7 +177,7 @@ public:
setEnabled(true);
setVisible(true);
- lastEvent = makeTouchData(QEvent::None, window(), {}, QList<QEventPoint>());//CHECK_VALID
+ lastEvent = makeTouchData(QEvent::None, window());//CHECK_VALID
lastVelocity = lastVelocityFromMouseMove = QVector2D();
lastMousePos = QPointF();
@@ -204,10 +216,11 @@ public:
event->ignore();
return;
}
+ qCDebug(lcTests) << objectName() << event;
++touchEventCount;
- lastEvent = makeTouchData(event->type(), nullptr, event->touchPointStates(), event->touchPoints());
- if (event->device()->capabilities().testFlag(QPointingDevice::Capability::Velocity) && !event->touchPoints().isEmpty()) {
- lastVelocity = event->touchPoints().first().velocity();
+ lastEvent = makeTouchData(event->type(), nullptr, event->touchPointStates(), event->points());
+ if (event->device()->capabilities().testFlag(QPointingDevice::Capability::Velocity) && !event->points().isEmpty()) {
+ lastVelocity = event->points().first().velocity();
} else {
lastVelocity = QVector2D();
}
@@ -232,7 +245,7 @@ public:
return;
}
mouseMoveCount = ++mouseMoveNum;
- lastVelocityFromMouseMove = e->point(0).velocity();
+ lastVelocityFromMouseMove = e->points().first().velocity();
lastMouseCapabilityFlags = e->device()->capabilities();
lastMousePos = e->position().toPoint();
}
@@ -248,6 +261,7 @@ public:
}
void mouseUngrabEvent() {
+ qCDebug(lcTests) << objectName();
++mouseUngrabEventCount;
}
@@ -340,6 +354,7 @@ public:
{
setSize(QSizeF(300, 300));
setAcceptedMouseButtons(Qt::LeftButton);
+ setAcceptTouchEvents(true);
}
protected:
@@ -477,8 +492,6 @@ private slots:
void testHoverTimestamp();
void test_circleMapItem();
- void pointerEventTypeAndPointCount();
-
void grabContentItemToImage();
void testDragEventPropertyPropagation();
@@ -727,8 +740,11 @@ void tst_qquickwindow::touchEvent_basic()
QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
+ // Since qtbase 2692237bb1b0c0f50b7cc5d920eb8ab065063d47, if the point didn't have a different position on release,
+ // then lastPosition is not changed. So in this case, it still holds the press position. I.e. on release,
+ // it's the last position that was actually different.
COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, window, QEventPoint::State::Released,
- makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos))));
+ makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos)));
COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, window, QEventPoint::State::Pressed, makeTouchPoint(bottomItem, pos)));
topItem->reset();
bottomItem->reset();
@@ -910,7 +926,7 @@ void tst_qquickwindow::touchEvent_cancel()
QWindowSystemInterface::handleTouchCancelEvent(nullptr, touchDevice);
QCoreApplication::processEvents();
- d = makeTouchData(QEvent::TouchCancel, window);
+ d = makeTouchData(QEvent::TouchCancel, window, QEventPoint::State::Pressed, makeTouchPoint(item, pos));
COMPARE_TOUCH_DATA(item->lastEvent, d);
delete item;
@@ -1031,18 +1047,18 @@ void tst_qquickwindow::touchEvent_velocity()
QCOMPARE(item->lastEvent.touchPoints.count(), 1);
QCOMPARE(item->lastVelocity, velocity);
- // Now have a transformation on the item and check if velocity and position are transformed accordingly.
+ // Now have a transformation on the item and check if position is transformed accordingly.
+ // (In Qt 6, transforming the velocity is an exercise left to the user. This saves work
+ // during delivery. If we want it to be transformed, we should add QEventPoint::sceneVelocity
+ // so that we can keep transforming it repeatedly during Item-localization.)
item->setRotation(90); // clockwise
- QMatrix4x4 transformMatrix;
- transformMatrix.rotate(-90, 0, 0, 1); // counterclockwise
- QVector2D transformedVelocity = transformMatrix.mapVector(velocity).toVector2D();
points[0].setPosition(points[0].position() + QPointF(5, 5));
points[0].setGlobalPosition(points[0].globalPosition() + QPointF(5, 5));
QWindowSystemInterface::handleTouchEvent(window, touchDeviceWithVelocity,
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, window));
QGuiApplication::processEvents();
QQuickTouchUtils::flush(window);
- QCOMPARE(item->lastVelocity, transformedVelocity);
+ QCOMPARE(item->lastVelocity, velocity);
QPoint itemLocalPos = item->mapFromScene(points[0].position()).toPoint();
QPoint itemLocalPosFromEvent = item->lastEvent.touchPoints[0].position().toPoint();
QCOMPARE(itemLocalPos, itemLocalPosFromEvent);
@@ -1183,9 +1199,6 @@ void tst_qquickwindow::mouseFromTouch_basic()
// Now the same with a transformation.
item->setRotation(90); // clockwise
- QMatrix4x4 transformMatrix;
- transformMatrix.rotate(-90, 0, 0, 1); // counterclockwise
- QVector2D transformedVelocity = transformMatrix.mapVector(velocity).toVector2D();
points[0].setState(QEventPoint::State::Pressed);
points[0].setVelocity(velocity);
tp.setPosition(localPos);
@@ -1202,8 +1215,7 @@ void tst_qquickwindow::mouseFromTouch_basic()
QGuiApplication::processEvents();
QQuickTouchUtils::flush(window);
QCOMPARE(item->lastMousePos.toPoint(), item->mapFromScene(points[0].position()).toPoint());
- QEXPECT_FAIL(0, "fails after pointer event refactoring in qtbase", Abort);
- QCOMPARE(item->lastVelocityFromMouseMove, transformedVelocity);
+ QCOMPARE(item->lastVelocityFromMouseMove, velocity); // Velocity is always in scene coords
points[0].setState(QEventPoint::State::Released);
QWindowSystemInterface::handleTouchEvent(window, touchDeviceWithVelocity,
@@ -1242,8 +1254,11 @@ void tst_qquickwindow::synthMouseFromTouch()
QPoint p1 = QPoint(20, 20);
QPoint p2 = QPoint(30, 30);
QTest::touchEvent(window.data(), touchDevice).press(0, p1, window.data());
+ QQuickTouchUtils::flush(window.data());
QTest::touchEvent(window.data(), touchDevice).move(0, p2, window.data());
+ QQuickTouchUtils::flush(window.data());
QTest::touchEvent(window.data(), touchDevice).release(0, p2, window.data());
+ QQuickTouchUtils::flush(window.data());
QCOMPARE(item->m_touchEvents.count(), !synthMouse && !acceptTouch ? 1 : 3);
QCOMPARE(item->m_mouseEvents.count(), (acceptTouch || !synthMouse) ? 0 : 3);
@@ -1295,7 +1310,8 @@ void tst_qquickwindow::synthMouseDoubleClickFromTouch()
const int eventCount = item->m_mouseEvents.count();
QVERIFY(eventCount >= 2);
- const int nDoubleClicks = std::count_if(item->m_mouseEvents.constBegin(), item->m_mouseEvents.constEnd(), [](const QMouseEvent &ev) { return (ev.type() == QEvent::MouseButtonDblClick); } );
+ const int nDoubleClicks = std::count_if(item->m_mouseEvents.constBegin(), item->m_mouseEvents.constEnd(),
+ [](const QMouseEvent &ev) { return (ev.type() == QEvent::MouseButtonDblClick); } );
const bool foundDoubleClick = (nDoubleClicks == 1);
QCOMPARE(foundDoubleClick, expectedSynthesizedDoubleClickEvent);
@@ -2834,58 +2850,6 @@ void tst_qquickwindow::test_circleMapItem()
QCOMPARE(topSpy.count(), 1);
}
-void tst_qquickwindow::pointerEventTypeAndPointCount()
-{
- QPointF localPosition(33, 66);
- QPointF scenePosition(133, 166);
- QPointF screenPosition(333, 366);
- QMouseEvent me(QEvent::MouseButtonPress, localPosition, scenePosition, screenPosition,
- Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
- QMutableTouchEvent te(QEvent::TouchBegin, touchDevice, Qt::NoModifier,
- QList<QEventPoint>() << QEventPoint(1));
-
-
- QQuickPointerMouseEvent pme(nullptr, QPointingDevice::primaryPointingDevice());
- pme.reset(&me);
- QCOMPARE(pme.asMouseEvent(localPosition), &me);
- QVERIFY(pme.asPointerMouseEvent());
- QVERIFY(!pme.asPointerTouchEvent());
- QVERIFY(!pme.asPointerTabletEvent());
-// QVERIFY(!pe->asTabletEvent()); // TODO
- QCOMPARE(pme.pointCount(), 1);
- QCOMPARE(pme.point(0)->scenePosition(), scenePosition);
- QCOMPARE(pme.asMouseEvent(localPosition)->position(), localPosition);
- QCOMPARE(pme.asMouseEvent(localPosition)->globalPosition(), screenPosition);
-
- QQuickPointerTouchEvent pte(nullptr, touchDevice);
- pte.reset(&te);
- QCOMPARE(pte.asTouchEvent(), &te);
- QVERIFY(!pte.asPointerMouseEvent());
- QVERIFY(pte.asPointerTouchEvent());
- QVERIFY(!pte.asPointerTabletEvent());
- QVERIFY(pte.asTouchEvent());
-// QVERIFY(!pte.asTabletEvent()); // TODO
- QCOMPARE(pte.pointCount(), 1);
- QCOMPARE(pte.touchPointById(1)->id(), 1);
- QVERIFY(!pte.touchPointById(0));
-
- te = QMutableTouchEvent(QEvent::TouchBegin, touchDevice, Qt::NoModifier,
- QList<QEventPoint>() << QEventPoint(1) << QEventPoint(2));
- pte.reset(&te);
- QCOMPARE(pte.pointCount(), 2);
- QCOMPARE(pte.touchPointById(1)->id(), 1);
- QCOMPARE(pte.touchPointById(2)->id(), 2);
- QVERIFY(!pte.touchPointById(0));
-
- te = QMutableTouchEvent(QEvent::TouchBegin, touchDevice, Qt::NoModifier,
- QList<QEventPoint>() << QEventPoint(2));
- pte.reset(&te);
- QCOMPARE(pte.pointCount(), 1);
- QCOMPARE(pte.touchPointById(2)->id(), 2);
- QVERIFY(!pte.touchPointById(1));
- QVERIFY(!pte.touchPointById(0));
-}
-
void tst_qquickwindow::grabContentItemToImage()
{
QQmlEngine engine;
diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
index 1c53a3abe2..2deaf31079 100644
--- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp
+++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
@@ -32,6 +32,7 @@
#include <QtGui/qstylehints.h>
#include <private/qdebug_p.h>
+#include <QtGui/private/qpointingdevice_p.h>
#include <QtQuick/qquickview.h>
#include <QtQuick/qquickitem.h>
@@ -56,9 +57,12 @@ struct Event
:type(t), mousePos(mouse), mousePosGlobal(global)
{}
- Event(QEvent::Type t, QList<QEventPoint> touch)
- :type(t), points(touch)
- {}
+ Event(QEvent::Type t, const QList<QEventPoint> &touch)
+ :type(t)
+ {
+ for (auto &tp : touch)
+ points << tp;
+ }
QEvent::Type type;
QPoint mousePos;
@@ -93,48 +97,57 @@ public:
: QQuickItem(parent)
{
setAcceptedMouseButtons(Qt::LeftButton);
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
setAcceptTouchEvents(true);
-#endif
}
void touchEvent(QTouchEvent *event)
{
- eventList.append(Event(event->type(), event->touchPoints()));
- QList<QEventPoint> tps = event->touchPoints();
- Q_ASSERT(!tps.isEmpty());
- point0 = tps.first().id();
+ qCDebug(lcTests) << event << "accepting?" << acceptTouch;
+ eventList.append(Event(event->type(), event->points()));
+ Q_ASSERT(event->pointCount() > 0);
+ point0 = event->point(0).id();
event->setAccepted(acceptTouch);
emit onTouchEvent(this);
}
void mousePressEvent(QMouseEvent *event)
{
+ qCDebug(lcTests) << event << "accepting?" << acceptMouse;
eventList.append(Event(event->type(), event->position().toPoint(), event->globalPosition().toPoint()));
+ mouseGrabber = event->exclusiveGrabber(event->points().first());
event->setAccepted(acceptMouse);
}
void mouseMoveEvent(QMouseEvent *event)
{
+ qCDebug(lcTests) << event << "accepting?" << acceptMouse;
eventList.append(Event(event->type(), event->position().toPoint(), event->globalPosition().toPoint()));
+ mouseGrabber = event->exclusiveGrabber(event->points().first());
event->setAccepted(acceptMouse);
}
void mouseReleaseEvent(QMouseEvent *event)
{
+ qCDebug(lcTests) << event << "accepting?" << acceptMouse;
eventList.append(Event(event->type(), event->position().toPoint(), event->globalPosition().toPoint()));
+ mouseGrabber = event->exclusiveGrabber(event->points().first());
event->setAccepted(acceptMouse);
}
void mouseDoubleClickEvent(QMouseEvent *event)
{
+ qCDebug(lcTests) << event << "accepting?" << acceptMouse;
eventList.append(Event(event->type(), event->position().toPoint(), event->globalPosition().toPoint()));
+ mouseGrabber = event->exclusiveGrabber(event->points().first());
event->setAccepted(acceptMouse);
}
void mouseUngrabEvent()
{
+ qCDebug(lcTests);
eventList.append(Event(QEvent::UngrabMouse, QPoint(0,0), QPoint(0,0)));
+ mouseGrabber = nullptr;
}
void touchUngrabEvent()
{
+ qCDebug(lcTests);
++touchUngrabCount;
}
@@ -143,6 +156,7 @@ public:
}
QList<Event> eventList;
+ QObject *mouseGrabber = nullptr;
int touchUngrabCount = 0;
bool acceptMouse = false;
bool acceptTouch = false;
@@ -154,11 +168,11 @@ public:
event->type() == QEvent::TouchUpdate ||
event->type() == QEvent::TouchCancel ||
event->type() == QEvent::TouchEnd) {
+ qCDebug(lcTests) << event;
QTouchEvent *touch = static_cast<QTouchEvent*>(event);
- eventList.append(Event(event->type(), touch->touchPoints()));
- QList<QEventPoint> tps = touch->touchPoints();
- Q_ASSERT(!tps.isEmpty());
- point0 = tps.first().id();
+ eventList.append(Event(event->type(), touch->points()));
+ Q_ASSERT(touch->pointCount() > 0);
+ point0 = touch->point(0).id();
if (filterTouch)
event->accept();
return true;
@@ -168,6 +182,37 @@ public:
int point0 = -1;
};
+class GrabMonitor : public QObject
+{
+public:
+ QObject *exclusiveGrabber = nullptr;
+ bool fromMouseEvent = false;
+ bool canceled = false;
+
+ void onGrabChanged(QObject *grabber, QPointingDevice::GrabTransition transition, const QPointerEvent *event, const QEventPoint &point)
+ {
+ qCDebug(lcTests) << grabber << transition << event << point << point.device();
+ switch (transition) {
+ case QPointingDevice::GrabTransition::GrabExclusive:
+ exclusiveGrabber = grabber;
+ fromMouseEvent = event && QQuickWindowPrivate::isMouseEvent(event);
+ canceled = false;
+ break;
+ case QPointingDevice::GrabTransition::UngrabExclusive:
+ exclusiveGrabber = nullptr;
+ canceled = false;
+ break;
+ case QPointingDevice::GrabTransition::CancelGrabExclusive:
+ exclusiveGrabber = nullptr;
+ canceled = true;
+ break;
+ default:
+ // ignore the passive grabs since this test doesn't involve pointer handlers
+ break;
+ }
+ }
+};
+
class tst_TouchMouse : public QQmlDataTest
{
Q_OBJECT
@@ -219,6 +264,7 @@ private:
QQuickView *createView();
QPointingDevice *device = QTest::createTouchDevice();
QList<Event> filteredEventList;
+ GrabMonitor grabMonitor;
};
QQuickView *tst_TouchMouse::createView()
@@ -231,6 +277,7 @@ void tst_TouchMouse::initTestCase()
{
QQmlDataTest::initTestCase();
qmlRegisterType<EventItem>("Qt.test", 1, 0, "EventItem");
+ connect(device, &QPointingDevice::grabChanged, &grabMonitor, &GrabMonitor::onGrabChanged);
}
void tst_TouchMouse::simpleTouchEvent_data()
@@ -254,6 +301,7 @@ void tst_TouchMouse::simpleTouchEvent()
EventItem *eventItem1 = window->rootObject()->findChild<EventItem*>("eventItem1");
QVERIFY(eventItem1);
+ auto devPriv = QPointingDevicePrivate::get(device);
// Do not accept touch or mouse
QPoint p1;
@@ -302,7 +350,7 @@ void tst_TouchMouse::simpleTouchEvent()
QCOMPARE(eventItem1->eventList.at(0).type, QEvent::TouchBegin);
if (synthMouse)
QCOMPARE(eventItem1->eventList.at(1).type, QEvent::MouseButtonPress);
- QCOMPARE(window->mouseGrabberItem(), synthMouse ? eventItem1 : nullptr);
+ QCOMPARE(devPriv->firstPointExclusiveGrabber(), synthMouse ? eventItem1 : nullptr);
QPoint localPos = eventItem1->mapFromScene(p1).toPoint();
QPoint globalPos = window->mapToGlobal(p1);
@@ -612,9 +660,9 @@ void tst_TouchMouse::buttonOnFlickable()
QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window.data());
QVERIFY(windowPriv->touchMouseId != -1);
- auto pointerEvent = windowPriv->pointerEventInstance(device);
- QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), eventItem1);
- QCOMPARE(window->mouseGrabberItem(), eventItem1);
+ auto devPriv = QPointingDevicePrivate::get(device);
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, eventItem1);
+ QCOMPARE(grabMonitor.exclusiveGrabber, eventItem1);
int dragDelta = -qApp->styleHints()->startDragDistance();
p1 += QPoint(0, dragDelta);
@@ -628,15 +676,14 @@ void tst_TouchMouse::buttonOnFlickable()
QTest::touchEvent(window.data(), device).move(0, p3, window.data());
QQuickTouchUtils::flush(window.data());
- // we cannot really know when the events get grabbed away
QVERIFY(eventItem1->eventList.size() >= 4);
QCOMPARE(eventItem1->eventList.at(2).type, QEvent::TouchUpdate);
QCOMPARE(eventItem1->eventList.at(3).type, QEvent::MouseMove);
- QCOMPARE(window->mouseGrabberItem(), flickable);
+ QCOMPARE(grabMonitor.exclusiveGrabber, flickable);
QVERIFY(windowPriv->touchMouseId != -1);
- QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), flickable);
- QVERIFY(flickable->isMovingVertically());
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, flickable);
+// QVERIFY(flickable->isMovingVertically()); // it will move after a couple more mouse moves
QTest::touchEvent(window.data(), device).release(0, p3, window.data());
QQuickTouchUtils::flush(window.data());
@@ -673,9 +720,9 @@ void tst_TouchMouse::touchButtonOnFlickable()
QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window.data());
QVERIFY(windowPriv->touchMouseId == -1);
- auto pointerEvent = windowPriv->pointerEventInstance(device);
- QCOMPARE(pointerEvent->point(0)->grabberItem(), eventItem2);
- QCOMPARE(window->mouseGrabberItem(), nullptr);
+ auto devPriv = QPointingDevicePrivate::get(device);
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, eventItem2);
+ QCOMPARE(grabMonitor.exclusiveGrabber, eventItem2);
int dragDelta = qApp->styleHints()->startDragDistance() * -0.7;
p1 += QPoint(0, dragDelta);
@@ -693,9 +740,9 @@ void tst_TouchMouse::touchButtonOnFlickable()
QTRY_COMPARE(eventItem2->touchUngrabCount, 1);
QVERIFY(eventItem2->eventList.size() > 2);
QCOMPARE(eventItem2->eventList.at(1).type, QEvent::TouchUpdate);
- QCOMPARE(window->mouseGrabberItem(), flickable);
+ QCOMPARE(grabMonitor.exclusiveGrabber, flickable);
QVERIFY(windowPriv->touchMouseId != -1);
- QCOMPARE(pointerEvent->point(0)->grabberItem(), flickable);
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, flickable);
QVERIFY(flickable->isMovingVertically());
QTest::touchEvent(window.data(), device).release(0, p3, window.data());
@@ -809,10 +856,10 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable()
// flickable should have the mouse grab, and have moved the itemForTouchPointId
// for the touchMouseId to the new grabber.
- QCOMPARE(window->mouseGrabberItem(), flickable);
+ QCOMPARE(grabMonitor.exclusiveGrabber, flickable);
QVERIFY(windowPriv->touchMouseId != -1);
- auto pointerEvent = windowPriv->pointerEventInstance(device);
- QCOMPARE(pointerEvent->point(0)->grabberItem(), flickable);
+ auto devPriv = QPointingDevicePrivate::get(device);
+ QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, flickable);
}
QTest::touchEvent(window.data(), device).release(0, pEnd, window.data());
@@ -1243,8 +1290,6 @@ void tst_TouchMouse::mouseOnFlickableOnPinch()
pinchSequence.move(0, p, window.data()).commit();
QQuickTouchUtils::flush(window.data());
- QCOMPARE(window->mouseGrabberItem(), flickable);
-
// Add a second finger, this should lead to stealing
p1 = QPoint(40, 100);
p2 = QPoint(60, 100);
@@ -1348,21 +1393,20 @@ void tst_TouchMouse::touchGrabCausesMouseUngrab()
QCOMPARE(leftItem->eventList.size(), 2);
QCOMPARE(leftItem->eventList.at(0).type, QEvent::TouchBegin);
QCOMPARE(leftItem->eventList.at(1).type, QEvent::MouseButtonPress);
- QCOMPARE(window->mouseGrabberItem(), leftItem);
+ QCOMPARE(grabMonitor.exclusiveGrabber, leftItem);
leftItem->eventList.clear();
rightItem->acceptTouch = true;
- {
- QList<int> ids;
- ids.append(leftItem->point0);
- rightItem->grabTouchPoints(ids);
- }
+ auto devPriv = QPointingDevicePrivate::get(device);
+ auto epd = devPriv->queryPointById(0);
+ QVERIFY(epd);
+ devPriv->setExclusiveGrabber(nullptr, epd->eventPoint, rightItem);
// leftItem should have lost the mouse as the touch point that was being used to emulate it
// has been grabbed by another item.
QCOMPARE(leftItem->eventList.size(), 1);
QCOMPARE(leftItem->eventList.at(0).type, QEvent::UngrabMouse);
- QCOMPARE(window->mouseGrabberItem(), (QQuickItem*)nullptr);
+ QCOMPARE(grabMonitor.exclusiveGrabber, rightItem);
}
void tst_TouchMouse::touchPointDeliveryOrder()
@@ -1556,6 +1600,7 @@ void tst_TouchMouse::implicitUngrab()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window.data());
QQuickItem *root = window->rootObject();
QVERIFY(root != nullptr);
@@ -1564,12 +1609,13 @@ void tst_TouchMouse::implicitUngrab()
QPoint p1(20, 20);
QTest::touchEvent(window.data(), device).press(0, p1);
- QCOMPARE(window->mouseGrabberItem(), eventItem);
+ QCOMPARE(grabMonitor.exclusiveGrabber, eventItem);
eventItem->eventList.clear();
eventItem->setEnabled(false);
QVERIFY(!eventItem->eventList.isEmpty());
QCOMPARE(eventItem->eventList.at(0).type, QEvent::UngrabMouse);
QTest::touchEvent(window.data(), device).release(0, p1); // clean up potential state
+ QCOMPARE(windowPriv->touchMouseId, -1);
eventItem->setEnabled(true);
QTest::touchEvent(window.data(), device).press(0, p1);
diff --git a/tests/manual/pointer/inputinspector.cpp b/tests/manual/pointer/inputinspector.cpp
index ff921fab0f..b919c489f4 100644
--- a/tests/manual/pointer/inputinspector.cpp
+++ b/tests/manual/pointer/inputinspector.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the manual tests of the Qt Toolkit.
@@ -27,9 +27,9 @@
****************************************************************************/
#include "inputinspector.h"
-#include <QtQuick/QQuickWindow>
#include <QtQuick/QQuickItem>
#include <QtQuick/private/qquickpointerhandler_p.h>
+#include <QtGui/private/qpointingdevice_p.h>
#include <QtCore/QSet>
static const int timerInterval = 100;
@@ -139,23 +139,13 @@ const QPointingDevice *InputInspector::pointerDevice() const
QVector<QObject*> InputInspector::passiveGrabbers_helper(int pointId /*= 0*/) const
{
QVector<QObject*> result;
- QSet<QObject*> visited;
const QPointingDevice *device = pointerDevice();
if (device && source()) {
- QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(source());
- QQuickPointerEvent *pointerEvent = winPriv->pointerEventInstance(device);
- if (pointerEvent) {
- for (int i = 0; i < pointerEvent->pointCount(); ++i) {
- QQuickEventPoint *eventPoint = pointerEvent->point(i);
- QVector<QPointer <QQuickPointerHandler> > passives = eventPoint->passiveGrabbers();
- if (!pointId || eventPoint->pointId() == pointId) {
- for (auto it = passives.constBegin(); it != passives.constEnd(); ++it) {
- QObject *handler = it->data();
- if (!visited.contains(handler)) {
- result << it->data();
- visited << handler;
- }
- }
+ for (auto eventPoint : QPointingDevicePrivate::get(device)->activePoints) {
+ if (!pointId || eventPoint.id() == pointId) {
+ for (auto pg : eventPoint.passiveGrabbers()) {
+ if (!result.contains(pg))
+ result << pg;
}
}
}
@@ -166,21 +156,13 @@ QVector<QObject*> InputInspector::passiveGrabbers_helper(int pointId /*= 0*/) co
QVector<QObject*> InputInspector::exclusiveGrabbers_helper(int pointId /*= 0*/) const
{
QVector<QObject*> result;
- QSet<QObject*> visited;
const QPointingDevice *device = pointerDevice();
if (device && source()) {
- QQuickWindowPrivate *winPriv = QQuickWindowPrivate::get(source());
- QQuickPointerEvent *pointerEvent = winPriv->pointerEventInstance(device);
- if (pointerEvent) {
- for (int i = 0; i < pointerEvent->pointCount(); ++i) {
- QQuickEventPoint *eventPoint = pointerEvent->point(i);
- if (!pointId || eventPoint->pointId() == pointId) {
- if (QObject *exclusiveGrabber = eventPoint->exclusiveGrabber()) {
- if (!visited.contains(exclusiveGrabber)) {
- result << exclusiveGrabber;
- visited << exclusiveGrabber;
- }
- }
+ for (auto eventPoint : QPointingDevicePrivate::get(device)->activePoints) {
+ if (!pointId || eventPoint.id() == pointId) {
+ if (auto g = eventPoint.exclusiveGrabber()) {
+ if (!result.contains(g))
+ result << g;
}
}
}
diff --git a/tests/manual/pointer/inputinspector.h b/tests/manual/pointer/inputinspector.h
index 0ef0a96987..31d99cf25d 100644
--- a/tests/manual/pointer/inputinspector.h
+++ b/tests/manual/pointer/inputinspector.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the manual tests of the Qt Toolkit.
@@ -30,7 +30,7 @@
#define INPUTINSPECTOR_H
#include <QObject>
-class QQuickWindow;
+#include <QtQuick/QQuickWindow>
class QQuickPointerHandler;
class QPointingDevice;
diff --git a/tests/manual/pointer/singlePointHandlerProperties.qml b/tests/manual/pointer/singlePointHandlerProperties.qml
index c2500770f0..9bebf23810 100644
--- a/tests/manual/pointer/singlePointHandlerProperties.qml
+++ b/tests/manual/pointer/singlePointHandlerProperties.qml
@@ -140,7 +140,7 @@ Rectangle {
id: pointHandler
target: null
acceptedButtons: Qt.AllButtons
- onGrabChanged: if (active) { // 'point' is an implicit parameter referencing to a QQuickEventPoint instance
+ onGrabChanged: if (active) { // 'point' is an implicit parameter referencing to a QEventPoint instance
console.log("grabbed " + point.pointId + " @ " + point.sceneGrabPos)
grabbingLocationIndicator.createObject(root, {"x": point.sceneGrabPosition.x, "y": point.sceneGrabPosition.y - 16})
}
diff --git a/tests/manual/pointer/tapHandler.qml b/tests/manual/pointer/tapHandler.qml
index 8c1fac9a2f..6e51fc6fda 100644
--- a/tests/manual/pointer/tapHandler.qml
+++ b/tests/manual/pointer/tapHandler.qml
@@ -53,7 +53,7 @@ Item {
borderBlink.blinkColor = "red"
borderBlink.start()
}
- onTapped: { // 'eventPoint' is a signal parameter of type QQuickEventPoint*
+ onTapped: { // 'eventPoint' is a signal parameter of type QEventPoint*
console.log("tapped button " + eventPoint.event.button + " @ " + eventPoint.scenePosition +
" on device '" + eventPoint.event.device.name + "' " + (tapCount > 1 ? (tapCount + " times") : "for the first time"))
if (tapCount > 1) {