diff options
Diffstat (limited to 'tests')
17 files changed, 139 insertions, 145 deletions
diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index 41a051a719..e569b49f7c 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -30,7 +30,7 @@ #include <QtCore/qpropertyanimation.h> #include <QtCore/qvariantanimation.h> #include <private/qabstractanimation_p.h> -#include <QtGui/qtouchdevice.h> +#include <QtGui/qpointingdevice.h> #include <QtWidgets/qwidget.h> Q_DECLARE_METATYPE(QAbstractAnimation::State) diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index d3cfeb204a..0d8e68f3f8 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -493,12 +493,12 @@ void tst_QGuiApplication::keyboardModifiers() QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier); // touch events - QList<const QTouchDevice *> touchDevices = QTouchDevice::devices(); - if (!touchDevices.isEmpty()) { - QTouchDevice *touchDevice = const_cast<QTouchDevice *>(touchDevices.first()); - QTest::touchEvent(window.data(), touchDevice).press(1, center).release(1, center); - QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); - } + QPointingDevice touchDevice(QLatin1String("test touchscreen"), 0, + QInputDevice::DeviceType::TouchScreen, QPointingDevice::PointerType::Finger, + QPointingDevice::Capability::Position, 10, 0); + QWindowSystemInterface::registerInputDevice(&touchDevice); + QTest::touchEvent(window.data(), &touchDevice).press(1, center).release(1, center); + QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); window->close(); } diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index 4499ba1334..7be68dd699 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -36,7 +36,7 @@ #include <qpa/qwindowsysteminterface.h> #include <qpa/qwindowsysteminterface_p.h> #include <private/qhighdpiscaling_p.h> -#include <private/qtouchdevice_p.h> +#include <private/qpointingdevice_p.h> class tst_QTouchEventWidget : public QWidget { @@ -46,7 +46,7 @@ public: bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd; bool deleteInTouchBegin, deleteInTouchUpdate, deleteInTouchEnd; ulong timestamp; - QTouchDevice *deviceFromEvent; + const QPointingDevice *deviceFromEvent; explicit tst_QTouchEventWidget(QWidget *parent = nullptr) : QWidget(parent) { @@ -73,7 +73,7 @@ public: seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd; touchBeginPoints = static_cast<QTouchEvent *>(event)->touchPoints(); timestamp = static_cast<QTouchEvent *>(event)->timestamp(); - deviceFromEvent = static_cast<QTouchEvent *>(event)->device(); + deviceFromEvent = static_cast<QTouchEvent *>(event)->pointingDevice(); event->setAccepted(acceptTouchBegin); if (deleteInTouchBegin) delete this; @@ -84,7 +84,7 @@ public: seenTouchUpdate = seenTouchBegin && !seenTouchEnd; touchUpdatePoints = static_cast<QTouchEvent *>(event)->touchPoints(); timestamp = static_cast<QTouchEvent *>(event)->timestamp(); - deviceFromEvent = static_cast<QTouchEvent *>(event)->device(); + deviceFromEvent = static_cast<QTouchEvent *>(event)->pointingDevice(); event->setAccepted(acceptTouchUpdate); if (deleteInTouchUpdate) delete this; @@ -95,7 +95,7 @@ public: seenTouchEnd = seenTouchBegin && !seenTouchEnd; touchEndPoints = static_cast<QTouchEvent *>(event)->touchPoints(); timestamp = static_cast<QTouchEvent *>(event)->timestamp(); - deviceFromEvent = static_cast<QTouchEvent *>(event)->device(); + deviceFromEvent = static_cast<QTouchEvent *>(event)->pointingDevice(); event->setAccepted(acceptTouchEnd); if (deleteInTouchEnd) delete this; @@ -213,22 +213,21 @@ private slots: void testMultiDevice(); private: - QTouchDevice *touchScreenDevice; - QTouchDevice *secondaryTouchScreenDevice; - QTouchDevice *touchPadDevice; + QPointingDevice *touchScreenDevice; + QPointingDevice *secondaryTouchScreenDevice; + QPointingDevice *touchPadDevice; }; tst_QTouchEvent::tst_QTouchEvent() : touchScreenDevice(QTest::createTouchDevice()) , secondaryTouchScreenDevice(QTest::createTouchDevice()) - , touchPadDevice(QTest::createTouchDevice(QTouchDevice::TouchPad)) + , touchPadDevice(QTest::createTouchDevice(QInputDevice::DeviceType::TouchPad)) { } void tst_QTouchEvent::cleanup() { QVERIFY(QGuiApplication::topLevelWindows().isEmpty()); - QWindowSystemInterfacePrivate::clearPointIdMap(); } void tst_QTouchEvent::qPointerUniqueId() @@ -641,8 +640,7 @@ void tst_QTouchEvent::basicRawEventTranslation() QCOMPARE(touchWidget.touchBeginPoints.count(), 1); QCOMPARE(touchWidget.timestamp, timestamp); QTouchEvent::TouchPoint touchBeginPoint = touchWidget.touchBeginPoints.first(); - const int touchPointId = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1; - QCOMPARE(touchBeginPoint.id(), touchPointId); + QCOMPARE(touchBeginPoint.id(), 0); QCOMPARE(touchBeginPoint.state(), rawTouchPoint.state()); QCOMPARE(touchBeginPoint.position(), pos); QCOMPARE(touchBeginPoint.pressPosition(), pos); @@ -678,7 +676,7 @@ void tst_QTouchEvent::basicRawEventTranslation() QVERIFY(!touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchUpdatePoints.count(), 1); QTouchEvent::TouchPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first(); - QCOMPARE(touchUpdatePoint.id(), touchPointId); + QCOMPARE(touchUpdatePoint.id(), 0); QCOMPARE(touchUpdatePoint.state(), rawTouchPoint.state()); QCOMPARE(touchUpdatePoint.position(), pos + delta); QCOMPARE(touchUpdatePoint.pressPosition(), pos); @@ -711,7 +709,7 @@ void tst_QTouchEvent::basicRawEventTranslation() QVERIFY(touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchEndPoints.count(), 1); QTouchEvent::TouchPoint touchEndPoint = touchWidget.touchEndPoints.first(); - QCOMPARE(touchEndPoint.id(), touchPointId); + QCOMPARE(touchEndPoint.id(), 0); QCOMPARE(touchEndPoint.state(), rawTouchPoint.state()); QCOMPARE(touchEndPoint.position(), pos + delta + delta); QCOMPARE(touchEndPoint.pressPosition(), pos); @@ -785,7 +783,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QVERIFY(!rightWidget.seenTouchEnd); QCOMPARE(leftWidget.touchBeginPoints.count(), 1); QCOMPARE(rightWidget.touchBeginPoints.count(), 1); - const int touchPointId0 = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1; + const int touchPointId0 = 0; const int touchPointId1 = touchPointId0 + 1; { QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchBeginPoints.first(); @@ -980,7 +978,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QRectF screenGeometry = touchWidget.screen()->geometry(); QVector<QTouchEvent::TouchPoint> rawTouchPoints(3); - rawTouchPoints[0].setId(0); + rawTouchPoints[0].setId(1); rawTouchPoints[1].setId(10); rawTouchPoints[2].setId(11); @@ -1000,9 +998,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QCOMPARE(touchWidget.touchBeginPoints.count(), 1); QCOMPARE(touchWidget.timestamp, timestamp); QTouchEvent::TouchPoint touchBeginPoint = touchWidget.touchBeginPoints.first(); - const int touchPointId = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1; - const int secTouchPointId = (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 2; - QCOMPARE(touchBeginPoint.id(), touchPointId); + QCOMPARE(touchBeginPoint.id(), 1); QCOMPARE(touchBeginPoint.state(), rawTouchPoints[0].state()); QCOMPARE(touchBeginPoint.position(), pos); @@ -1020,7 +1016,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QCOMPARE(touchWidget.touchBeginPoints.count(), 1); QCOMPARE(touchWidget.timestamp, timestamp); touchBeginPoint = touchWidget.touchBeginPoints[0]; - QCOMPARE(touchBeginPoint.id(), (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 2); + QCOMPARE(touchBeginPoint.id(), 10); QCOMPARE(touchBeginPoint.state(), rawTouchPoints[1].state()); QCOMPARE(touchBeginPoint.position(), pos); @@ -1038,7 +1034,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QCOMPARE(touchWidget.touchBeginPoints.count(), 1); QCOMPARE(touchWidget.timestamp, timestamp); touchBeginPoint = touchWidget.touchBeginPoints[0]; - QCOMPARE(touchBeginPoint.id(), (QTouchDevicePrivate::get(secondaryTouchScreenDevice)->id << 24) + 3); + QCOMPARE(touchBeginPoint.id(), 11); QCOMPARE(touchBeginPoint.state(), rawTouchPoints[2].state()); QCOMPARE(touchBeginPoint.position(), pos); @@ -1055,7 +1051,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QVERIFY(!touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchUpdatePoints.count(), 1); QTouchEvent::TouchPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first(); - QCOMPARE(touchUpdatePoint.id(), touchPointId); + QCOMPARE(touchUpdatePoint.id(), 1); QCOMPARE(touchUpdatePoint.state(), rawTouchPoints[0].state()); QCOMPARE(touchUpdatePoint.position(), pos + delta); @@ -1072,7 +1068,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QVERIFY(touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchEndPoints.count(), 1); QTouchEvent::TouchPoint touchEndPoint = touchWidget.touchEndPoints.first(); - QCOMPARE(touchEndPoint.id(), touchPointId); + QCOMPARE(touchEndPoint.id(), 1); QCOMPARE(touchEndPoint.state(), rawTouchPoints[0].state()); QCOMPARE(touchEndPoint.position(), pos + delta + delta); @@ -1096,8 +1092,8 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); - QCOMPARE(touchWidget.touchUpdatePoints[0].id(), secTouchPointId); - QCOMPARE(touchWidget.touchUpdatePoints[1].id(), secTouchPointId + 1); + QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 10); + QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 11); // releasing the last point on the secondary touchscreen translates to TouchEnd touchWidget.seenTouchEnd = false; @@ -1111,7 +1107,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens() QVERIFY(touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchEndPoints.count(), 1); touchEndPoint = touchWidget.touchEndPoints.first(); - QCOMPARE(touchEndPoint.id(), secTouchPointId + 1); + QCOMPARE(touchEndPoint.id(), 11); QCOMPARE(touchEndPoint.state(), rawTouchPoints[2].state()); } @@ -1394,11 +1390,9 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds() QVERIFY(!touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchBeginPoints.count(), 2); - const int initialTouchPointId = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1; - for (int i = 0; i < touchWidget.touchBeginPoints.count(); ++i) { QTouchEvent::TouchPoint touchBeginPoint = touchWidget.touchBeginPoints.at(i); - QCOMPARE(touchBeginPoint.id(), initialTouchPointId + i); + QCOMPARE(touchBeginPoint.id(), i); QCOMPARE(touchBeginPoint.state(), rawTouchPoints[i].state()); } @@ -1417,8 +1411,8 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds() QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); - QCOMPARE(touchWidget.touchUpdatePoints.at(0).id(), initialTouchPointId); - QCOMPARE(touchWidget.touchUpdatePoints.at(1).id(), initialTouchPointId + 1); + QCOMPARE(touchWidget.touchUpdatePoints.at(0).id(), 0); + QCOMPARE(touchWidget.touchUpdatePoints.at(1).id(), 1); // release last point p0.setState(Qt::TouchPointStationary); @@ -1432,8 +1426,8 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds() QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); - QCOMPARE(touchWidget.touchUpdatePoints[0].id(), initialTouchPointId); - QCOMPARE(touchWidget.touchUpdatePoints[1].id(), initialTouchPointId + 1); + QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0); + QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 1); // Press last point again, id should increase p1.setState(Qt::TouchPointPressed); @@ -1446,8 +1440,8 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds() QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(!touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); - QCOMPARE(touchWidget.touchUpdatePoints[0].id(), initialTouchPointId); - QCOMPARE(touchWidget.touchUpdatePoints[1].id(), initialTouchPointId + 2); + QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0); + QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 42); // release everything p0.setState(Qt::TouchPointReleased); @@ -1460,8 +1454,8 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds() QVERIFY(touchWidget.seenTouchUpdate); QVERIFY(touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); - QCOMPARE(touchWidget.touchUpdatePoints[0].id(), initialTouchPointId); - QCOMPARE(touchWidget.touchUpdatePoints[1].id(), initialTouchPointId + 2); + QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0); + QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 42); } void tst_QTouchEvent::deleteInEventHandler() @@ -1782,7 +1776,7 @@ public: QList<QTouchEvent::TouchPoint> points; QEvent::Type lastSeenType; }; - QMap<QTouchDevice *, TouchInfo> d; + QMap<const QPointingDevice *, TouchInfo> d; }; bool WindowTouchEventFilter::eventFilter(QObject *, QEvent *event) @@ -1791,7 +1785,7 @@ bool WindowTouchEventFilter::eventFilter(QObject *, QEvent *event) || event->type() == QEvent::TouchUpdate || event->type() == QEvent::TouchEnd) { QTouchEvent *te = static_cast<QTouchEvent *>(event); - TouchInfo &td = d[te->device()]; + TouchInfo &td = d[te->pointingDevice()]; if (event->type() == QEvent::TouchBegin) td.points.clear(); td.points.append(te->touchPoints()); @@ -1813,7 +1807,7 @@ void tst_QTouchEvent::testQGuiAppDelivery() QList<QWindowSystemInterface::TouchPoint> points; // Pass empty list, should be ignored. - QWindowSystemInterface::handleTouchEvent(&w, 0, points); + QWindowSystemInterface::handleTouchEvent(&w, nullptr, points); QCoreApplication::processEvents(); QCOMPARE(filter.d.isEmpty(), true); @@ -1823,8 +1817,8 @@ void tst_QTouchEvent::testQGuiAppDelivery() tp.area = QRectF(120, 120, 20, 20); points.append(tp); - // Pass 0 as device, should be ignored. - QWindowSystemInterface::handleTouchEvent(&w, 0, points); + // Null device: should be ignored. + QWindowSystemInterface::handleTouchEvent(&w, nullptr, points); QCoreApplication::processEvents(); QCOMPARE(filter.d.isEmpty(), true); @@ -1855,7 +1849,7 @@ void tst_QTouchEvent::testQGuiAppDelivery() void tst_QTouchEvent::testMultiDevice() { - QTouchDevice *deviceTwo = QTest::createTouchDevice(); + QPointingDevice *deviceTwo = QTest::createTouchDevice(); QWindow w; w.setGeometry(100, 100, 100, 100); diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index f22c23f6e0..afa764d580 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -110,7 +110,10 @@ private slots: private: QPoint m_availableTopLeft; QSize m_testWindowSize; - QTouchDevice *touchDevice = QTest::createTouchDevice(); + QPointingDevice *touchDevice = QTest::createTouchDevice(); + QPointingDevice *touchDeviceWithMouseEmulation = + QTest::createTouchDevice(QInputDevice::DeviceType::TouchScreen, + QInputDevice::Capability::Position | QInputDevice::Capability::MouseEmulation); }; void tst_QWindow::initTestCase() @@ -1180,11 +1183,9 @@ void tst_QWindow::touchToMouseTranslationForDevices() window.resetCounters(); - touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation); - QTest::touchEvent(&window, touchDevice).press(0, touchPoint, &window); - QTest::touchEvent(&window, touchDevice).release(0, touchPoint, &window); + QTest::touchEvent(&window, touchDeviceWithMouseEmulation).press(0, touchPoint, &window); + QTest::touchEvent(&window, touchDeviceWithMouseEmulation).release(0, touchPoint, &window); QCoreApplication::processEvents(); - touchDevice->setCapabilities(touchDevice->capabilities() & ~QTouchDevice::MouseEmulation); QCOMPARE(window.mousePressedCount, 0); QCOMPARE(window.mouseReleasedCount, 0); @@ -1704,7 +1705,8 @@ public: QEvent::Type eventType = QEvent::None; QPointF eventGlobal, eventLocal; - int eventDevice = -1; + QInputDevice::DeviceType eventDevice = QInputDevice::DeviceType::Unknown; + QPointingDevice::PointerType eventPointerType = QPointingDevice::PointerType::Unknown; bool eventFilter(QObject *obj, QEvent *ev) override { @@ -1713,6 +1715,7 @@ public: eventType = ev->type(); QTabletEvent *te = static_cast<QTabletEvent *>(ev); eventDevice = te->deviceType(); + eventPointerType = te->pointerType(); } return QWindow::eventFilter(obj, ev); } @@ -1741,16 +1744,17 @@ void tst_QWindow::tabletEvents() QCoreApplication::processEvents(); QTRY_COMPARE(window.eventType, QEvent::TabletRelease); - QWindowSystemInterface::handleTabletEnterProximityEvent(1, 2, 3); + QWindowSystemInterface::handleTabletEnterProximityEvent(int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Eraser), 3); QCoreApplication::processEvents(); QTRY_COMPARE(window.eventType, QEvent::TabletEnterProximity); - QTRY_COMPARE(window.eventDevice, 1); + QCOMPARE(window.eventDevice, QInputDevice::DeviceType::Stylus); + QCOMPARE(window.eventPointerType, QPointingDevice::PointerType::Eraser); - QWindowSystemInterface::handleTabletLeaveProximityEvent(1, 2, 3); + QWindowSystemInterface::handleTabletLeaveProximityEvent(int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Eraser), 3); QCoreApplication::processEvents(); QTRY_COMPARE(window.eventType, QEvent::TabletLeaveProximity); - QTRY_COMPARE(window.eventDevice, 1); - + QCOMPARE(window.eventDevice, QInputDevice::DeviceType::Stylus); + QCOMPARE(window.eventPointerType, QPointingDevice::PointerType::Eraser); #endif } diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index 5b34ebb013..a4017047ea 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -31,7 +31,7 @@ #include <QtTest/qtesttouch.h> #include <qevent.h> -#include <qtouchdevice.h> +#include <qpointingdevice.h> #include <qwidget.h> #include <qlayout.h> #include <qgesture.h> @@ -1821,7 +1821,7 @@ void tst_Gestures::deleteMacPanGestureRecognizerTargetWidget() window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); - QTouchDevice *device = QTest::createTouchDevice(); + QPointingDevice *device = QTest::createTouchDevice(); // QMacOSPenGestureRecognizer will start a timer on a touch press event QTest::touchEvent(&window, device).press(1, QPoint(100, 100), &window); delete view; @@ -2327,7 +2327,7 @@ void tst_Gestures::bug_13501_gesture_not_accepted() w.show(); QVERIFY(QTest::qWaitForWindowExposed(&w)); //QTest::mousePress(&ignoreEvent, Qt::LeftButton); - QTouchDevice *device = QTest::createTouchDevice(); + QPointingDevice *device = QTest::createTouchDevice(); QTest::touchEvent(&w, device).press(0, QPoint(10, 10), &w); } diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 9ae127dbe0..94575e174d 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -490,7 +490,7 @@ private slots: private: GraphicsItems paintedItems; - QTouchDevice *m_touchDevice = nullptr; + QPointingDevice *m_touchDevice = nullptr; }; void tst_QGraphicsItem::initMain() diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 8c2d89e34b..e0f4b67d50 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -3871,7 +3871,7 @@ void tst_QGraphicsProxyWidget::forwardTouchEvent() EventSpy eventSpy(widget); - QTouchDevice *device = QTest::createTouchDevice(); + QPointingDevice *device = QTest::createTouchDevice(); QCOMPARE(eventSpy.counts[QEvent::TouchBegin], 0); QCOMPARE(eventSpy.counts[QEvent::TouchUpdate], 0); diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index f0a276b9e7..7798bb52dc 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -4849,8 +4849,8 @@ void tst_QGraphicsScene::focusOnTouch() scene.setFocusOnTouch(false); - QTouchDevice device; - device.setType(QTouchDevice::TouchPad); + QPointingDevice device; + device.setType(QInputDevice::DeviceType::TouchPad); QList<QTouchEvent::TouchPoint> touchPoints; QTouchEvent::TouchPoint point; point.setScenePos(QPointF(10, 10)); diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index b0689f5c16..a4a8eb956c 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -1910,7 +1910,7 @@ void tst_QApplication::touchEventPropagation() release.setState(Qt::TouchPointReleased); releasedTouchPoints << release; - QTouchDevice *device = QTest::createTouchDevice(); + QPointingDevice *device = QTest::createTouchDevice(); { // touch event behavior on a window diff --git a/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp b/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp index bcf48c21df..e2dc7006b3 100644 --- a/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp +++ b/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp @@ -32,7 +32,7 @@ #include <QtWidgets/QWidget> #include <QtWidgets/QGestureEvent> #include <QtGui/QScreen> -#include <QtGui/QTouchDevice> +#include <QtGui/QPointingDevice> #include <QtCore/QVector> #include <QtCore/QString> #include <QtCore/QHash> @@ -57,7 +57,7 @@ private Q_SLOTS: private: const int m_fingerDistance; - QTouchDevice *m_touchDevice; + QPointingDevice *m_touchDevice; }; tst_QGestureRecognizer::tst_QGestureRecognizer() diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index b05d6cd96e..c029e58acc 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -428,7 +428,7 @@ private: QPoint m_availableTopLeft; QPoint m_safeCursorPos; const bool m_windowsAnimationsEnabled; - QTouchDevice *m_touchScreen; + QPointingDevice *m_touchScreen; const int m_fuzz; }; @@ -11447,7 +11447,7 @@ void tst_QWidget::tabletTracking() qint64 uid = 1234UL; QWindowSystemInterface::handleTabletEvent(window, ulong(QDateTime::currentMSecsSinceEpoch()), deviceLocal, deviceGlobal, - QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); + int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); QCoreApplication::processEvents(); QTRY_COMPARE(widget.moveEventCount, 1); QCOMPARE(widget.uid, uid); @@ -11456,7 +11456,7 @@ void tst_QWidget::tabletTracking() deviceLocal += QPoint(10, 10); deviceGlobal += QPoint(10, 10); QWindowSystemInterface::handleTabletEvent(window, ulong(QDateTime::currentMSecsSinceEpoch()), deviceLocal, deviceGlobal, - QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); + int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); QCoreApplication::processEvents(); QTRY_COMPARE(widget.moveEventCount, 2); @@ -11465,7 +11465,7 @@ void tst_QWidget::tabletTracking() QTRY_COMPARE(widget.trackingChangeEventCount, 2); QWindowSystemInterface::handleTabletEvent(window, ulong(QDateTime::currentMSecsSinceEpoch()), deviceLocal, deviceGlobal, - QTabletEvent::Stylus, QTabletEvent::Pen, Qt::LeftButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); + int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), Qt::LeftButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); QCoreApplication::processEvents(); QTRY_COMPARE(widget.pressEventCount, 1); @@ -11473,12 +11473,12 @@ void tst_QWidget::tabletTracking() deviceLocal += QPoint(10, 10); deviceGlobal += QPoint(10, 10); QWindowSystemInterface::handleTabletEvent(window, ulong(QDateTime::currentMSecsSinceEpoch()), deviceLocal, deviceGlobal, - QTabletEvent::Stylus, QTabletEvent::Pen, Qt::LeftButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); + int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), Qt::LeftButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); QCoreApplication::processEvents(); QTRY_COMPARE(widget.moveEventCount, 3); QWindowSystemInterface::handleTabletEvent(window, ulong(QDateTime::currentMSecsSinceEpoch()), deviceLocal, deviceGlobal, - QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); + int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); QCoreApplication::processEvents(); QTRY_COMPARE(widget.releaseEventCount, 1); @@ -11486,7 +11486,7 @@ void tst_QWidget::tabletTracking() deviceLocal += QPoint(10, 10); deviceGlobal += QPoint(10, 10); QWindowSystemInterface::handleTabletEvent(window, ulong(QDateTime::currentMSecsSinceEpoch()), deviceLocal, deviceGlobal, - QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); + int(QInputDevice::DeviceType::Stylus), int(QPointingDevice::PointerType::Pen), Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); QCoreApplication::processEvents(); QTRY_COMPARE(widget.moveEventCount, 3); } diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp index 5e71c1888d..83ff5ed668 100644 --- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp +++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp @@ -128,7 +128,7 @@ private slots: void multipleWindows(); private: - QTouchDevice *m_touchScreen = QTest::createTouchDevice(); + QPointingDevice *m_touchScreen = QTest::createTouchDevice(); }; /*! \internal diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp index e146175109..18ea50c854 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp +++ b/tests/manual/qtabletevent/device_information/tabletwidget.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 module of the Qt Toolkit. @@ -58,8 +58,13 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev) mPos = event->pos(); mGPos = event->globalPos(); mHiResGlobalPos = event->posF(); - mDev = event->deviceType(); - mPointerType = event->pointerType(); + if (event->pointingDevice()) { + mDev = event->pointingDevice()->type(); + mPointerType = event->pointingDevice()->pointerType(); + mCaps = event->pointingDevice()->capabilities(); + } else { + qWarning() << "missing device in tablet event"; + } mUnique = event->uniqueId(); mXT = event->xTilt(); mYT = event->yTilt(); @@ -132,46 +137,9 @@ void TabletWidget::paintEvent(QPaintEvent *) eventInfo << QString("High res global position: %1 %2").arg(QString::number(mHiResGlobalPos.x()), QString::number(mHiResGlobalPos.y())); - QString pointerType("Pointer type: "); - switch (mPointerType) { - case QTabletEvent::UnknownPointer: - pointerType += "QTabletEvent::UnknownPointer"; - break; - case QTabletEvent::Pen: - pointerType += "QTabletEvent::Pen"; - break; - case QTabletEvent::Cursor: - pointerType += "QTabletEvent::Cursor"; - break; - case QTabletEvent::Eraser: - pointerType += "QTabletEvent::Eraser"; - break; - } - eventInfo << pointerType; - - QString deviceString = "Device type: "; - switch (mDev) { - case QTabletEvent::NoDevice: - deviceString += "QTabletEvent::NoDevice"; - break; - case QTabletEvent::Puck: - deviceString += "QTabletEvent::Puck"; - break; - case QTabletEvent::Stylus: - deviceString += "QTabletEvent::Stylus"; - break; - case QTabletEvent::Airbrush: - deviceString += "QTabletEvent::Airbrush"; - break; - case QTabletEvent::FourDMouse: - deviceString += "QTabletEvent::FourDMouse"; - break; - case QTabletEvent::RotationStylus: - deviceString += "QTabletEvent::RotationStylus"; - break; - } - eventInfo << deviceString; - + eventInfo << QString("Device type: %1").arg(deviceTypeToString(mDev)); + eventInfo << QString("Pointer type: %1").arg(pointerTypeToString(mPointerType)); + eventInfo << QString("Capabilities: %1").arg(pointerCapabilitiesToString(mCaps)); eventInfo << QString("Button: %1 (0x%2)").arg(buttonToString(mButton)).arg(mButton, 0, 16); eventInfo << QString("Buttons currently pressed: %1 (0x%2)").arg(buttonsToString(mButtons)).arg(mButtons, 0, 16); eventInfo << QString("Keyboard modifiers: %1 (0x%2)").arg(modifiersToString(mModifiers)).arg(mModifiers, 0, 16); @@ -182,7 +150,7 @@ void TabletWidget::paintEvent(QPaintEvent *) eventInfo << QString("yTilt: %1").arg(QString::number(mYT)); eventInfo << QString("z: %1").arg(QString::number(mZ)); - eventInfo << QString("Unique Id: %1").arg(QString::number(mUnique)); + eventInfo << QString("Unique Id: %1").arg(QString::number(mUnique, 16)); eventInfo << QString("Total wheel events: %1").arg(QString::number(mWheelEventCount)); } @@ -191,10 +159,28 @@ void TabletWidget::paintEvent(QPaintEvent *) painter.drawText(rect(), text); } +const char *TabletWidget::deviceTypeToString(QInputDevice::DeviceType t) +{ + static int enumIdx = QInputDevice::staticMetaObject.indexOfEnumerator("DeviceType"); + return QPointingDevice::staticMetaObject.enumerator(enumIdx).valueToKey(int(t)); +} + +const char *TabletWidget::pointerTypeToString(QPointingDevice::PointerType t) +{ + static int enumIdx = QPointingDevice::staticMetaObject.indexOfEnumerator("PointerType"); + return QPointingDevice::staticMetaObject.enumerator(enumIdx).valueToKey(int(t)); +} + +QString TabletWidget::pointerCapabilitiesToString(QPointingDevice::Capabilities c) +{ + static int enumIdx = QPointingDevice::staticMetaObject.indexOfEnumerator("Capabilities"); + return QString::fromLatin1(QPointingDevice::staticMetaObject.enumerator(enumIdx).valueToKeys(c)); +} + const char *TabletWidget::buttonToString(Qt::MouseButton b) { - static int enumIdx = QObject::staticQtMetaObject.indexOfEnumerator("MouseButtons"); - return QObject::staticQtMetaObject.enumerator(enumIdx).valueToKey(b); + static int enumIdx = QObject::staticMetaObject.indexOfEnumerator("MouseButtons"); + return QObject::staticMetaObject.enumerator(enumIdx).valueToKey(b); } QString TabletWidget::buttonsToString(Qt::MouseButtons bs) diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h index 404be1289f..d05b89a74e 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.h +++ b/tests/manual/qtabletevent/device_information/tabletwidget.h @@ -31,6 +31,7 @@ #include <QWidget> #include <QTabletEvent> +#include <QPointingDevice> #include <QShortcut> // a widget showing the information of the last tablet event @@ -42,12 +43,18 @@ protected: bool eventFilter(QObject *obj, QEvent *ev); void tabletEvent(QTabletEvent *event); void paintEvent(QPaintEvent *event); + const char *deviceTypeToString(QInputDevice::DeviceType t); + const char *pointerTypeToString(QPointingDevice::PointerType t); + QString pointerCapabilitiesToString(QPointingDevice::Capabilities c); const char *buttonToString(Qt::MouseButton b); QString buttonsToString(Qt::MouseButtons bs); QString modifiersToString(Qt::KeyboardModifiers m); private: void resetAttributes() { - mType = mDev = mPointerType = mXT = mYT = mZ = 0; + mDev = QInputDevice::DeviceType::Unknown; + mPointerType = QPointingDevice::PointerType::Unknown; + mCaps = {}; + mType = mXT = mYT = mZ = 0; mPress = mTangential = mRot = 0.0; mPos = mGPos = QPoint(); mHiResGlobalPos = QPointF(); @@ -56,7 +63,10 @@ private: int mType; QPoint mPos, mGPos; QPointF mHiResGlobalPos; - int mDev, mPointerType, mXT, mYT, mZ; + QInputDevice::DeviceType mDev; + QPointingDevice::PointerType mPointerType; + QPointingDevice::Capabilities mCaps; + int mXT, mYT, mZ; Qt::MouseButton mButton; Qt::MouseButtons mButtons; Qt::KeyboardModifiers mModifiers; diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp index 1d0af4559b..38b8ae816d 100644 --- a/tests/manual/qtabletevent/regular_widgets/main.cpp +++ b/tests/manual/qtabletevent/regular_widgets/main.cpp @@ -48,14 +48,14 @@ enum TabletPointType { struct TabletPoint { - TabletPoint(const QPointF &p = QPointF(), TabletPointType t = TabletMove, - Qt::MouseButton b = Qt::LeftButton, QTabletEvent::PointerType pt = QTabletEvent::UnknownPointer, qreal prs = 0, qreal rotation = 0) : + TabletPoint(const QPointF &p = QPointF(), TabletPointType t = TabletMove, Qt::MouseButton b = Qt::LeftButton, + QPointingDevice::PointerType pt = QPointingDevice::PointerType::Unknown, qreal prs = 0, qreal rotation = 0) : pos(p), type(t), button(b), ptype(pt), pressure(prs), angle(rotation) {} QPointF pos; TabletPointType type; Qt::MouseButton button; - QTabletEvent::PointerType ptype; + QPointingDevice::PointerType ptype; qreal pressure; qreal angle; }; @@ -167,7 +167,7 @@ void EventReportWidget::paintEvent(QPaintEvent *) break; case TabletMove: if (t.pressure > 0.0) { - p.setPen(t.ptype == QTabletEvent::Eraser ? Qt::red : Qt::black); + p.setPen(t.ptype == QPointingDevice::PointerType::Eraser ? Qt::red : Qt::black); if (t.angle != 0.0) { p.save(); p.translate(t.pos); @@ -205,7 +205,7 @@ void EventReportWidget::tabletEvent(QTabletEvent *event) { QWidget::tabletEvent(event); bool isMove = false; - m_tabletPos = event->posF(); + m_tabletPos = event->position(); switch (event->type()) { case QEvent::TabletMove: m_points.push_back(TabletPoint(m_tabletPos, TabletMove, m_lastButton, event->pointerType(), event->pressure(), event->rotation())); @@ -229,7 +229,7 @@ void EventReportWidget::tabletEvent(QTabletEvent *event) if (!(isMove && m_lastIsTabletMove)) { QDebug d = qDebug(); - d << event << " global position = " << event->globalPos() + d << event << " global position = " << event->globalPosition() << " cursor at " << QCursor::pos(); if (event->button() != Qt::NoButton) d << " changed button " << event->button(); @@ -245,7 +245,7 @@ bool EventReportWidget::event(QEvent *event) event->accept(); m_touchPoints.clear(); for (const QTouchEvent::TouchPoint &p : static_cast<const QTouchEvent *>(event)->touchPoints()) - m_touchPoints.append(p.pos()); + m_touchPoints.append(p.position()); update(); break; case QEvent::TouchEnd: diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp index 8572e18955..c8d1950f8c 100644 --- a/tests/manual/touch/main.cpp +++ b/tests/manual/touch/main.cpp @@ -536,7 +536,7 @@ void MainWindow::dumpTouchDevices() { QString message; QDebug debug(&message); - const QList<const QTouchDevice *> devices = QTouchDevice::devices(); + const QList<const QPointingDevice *> devices = QPointingDevice::devices(); debug << devices.size() << "Device(s):\n"; for (int i = 0; i < devices.size(); ++i) debug << "Device #" << i << devices.at(i) << '\n'; diff --git a/tests/manual/touchGraphicsItem/main.cpp b/tests/manual/touchGraphicsItem/main.cpp index 7afadc7edd..2b18634cbd 100644 --- a/tests/manual/touchGraphicsItem/main.cpp +++ b/tests/manual/touchGraphicsItem/main.cpp @@ -106,26 +106,26 @@ int main(int argc, char **argv) QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(new QLabel("The blue ellipses should indicate touch point contact patches")); qDebug() << "Touch devices:"; - for (const QTouchDevice *device : QTouchDevice::devices()) { + for (const QPointingDevice *device : QPointingDevice::devices()) { QString result; QTextStream str(&result); - str << (device->type() == QTouchDevice::TouchScreen ? "TouchScreen" : "TouchPad") + str << (device->type() == QInputDevice::DeviceType::TouchScreen ? "TouchScreen" : "TouchPad") << " \"" << device->name() << "\", max " << device->maximumTouchPoints() << " touch points, capabilities:"; - const QTouchDevice::Capabilities capabilities = device->capabilities(); - if (capabilities & QTouchDevice::Position) + const QPointingDevice::Capabilities capabilities = device->capabilities(); + if (capabilities & QPointingDevice::Capability::Position) str << " Position"; - if (capabilities & QTouchDevice::Area) + if (capabilities & QPointingDevice::Capability::Area) str << " Area"; - if (capabilities & QTouchDevice::Pressure) + if (capabilities & QPointingDevice::Capability::Pressure) str << " Pressure"; - if (capabilities & QTouchDevice::Velocity) + if (capabilities & QPointingDevice::Velocity) str << " Velocity"; - if (capabilities & QTouchDevice::RawPositions) + if (capabilities & QPointingDevice::RawPositions) str << " RawPositions"; - if (capabilities & QTouchDevice::NormalizedPosition) + if (capabilities & QPointingDevice::Capability::NormalizedPosition) str << " NormalizedPosition"; - if (capabilities & QTouchDevice::MouseEmulation) + if (capabilities & QInputDevice::DeviceType::MouseEmulation) str << " MouseEmulation"; vbox->addWidget(new QLabel(result)); qDebug() << " " << result; |