diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 1de2ef17cee..af9458b44f9 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -73,7 +73,7 @@ #endif #include -#include +#include QT_BEGIN_NAMESPACE @@ -456,10 +456,11 @@ void QWaylandInputDevice::seat_capabilities(uint32_t caps) mTouch->init(get_touch()); if (!mTouchDevice) { - mTouchDevice = new QTouchDevice; - mTouchDevice->setType(QTouchDevice::TouchScreen); - mTouchDevice->setCapabilities(QTouchDevice::Position); - QWindowSystemInterface::registerTouchDevice(mTouchDevice); + // TODO number of touchpoints, actual name and ID + mTouchDevice = new QPointingDevice(QLatin1String("some touchscreen"), 0, + QInputDevice::DeviceType::TouchScreen, QPointingDevice::PointerType::Finger, + QInputDevice::Capability::Position, 10, 0); + QWindowSystemInterface::registerInputDevice(mTouchDevice); } } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && mTouch) { delete mTouch; diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice_p.h b/src/plugins/platforms/wayland/qwaylandinputdevice_p.h index 448d0fce5dc..8e2dd184bdd 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice_p.h +++ b/src/plugins/platforms/wayland/qwaylandinputdevice_p.h @@ -195,7 +195,7 @@ private: void seat_capabilities(uint32_t caps) override; void handleTouchPoint(int id, Qt::TouchPointState state, const QPointF &surfacePosition = QPoint()); - QTouchDevice *mTouchDevice = nullptr; + QPointingDevice *mTouchDevice = nullptr; friend class QWaylandTouchExtension; friend class QWaylandQtKeyExtension; diff --git a/src/plugins/platforms/wayland/qwaylandtabletv2.cpp b/src/plugins/platforms/wayland/qwaylandtabletv2.cpp index eb2e865f6e7..0f55aba9e00 100644 --- a/src/plugins/platforms/wayland/qwaylandtabletv2.cpp +++ b/src/plugins/platforms/wayland/qwaylandtabletv2.cpp @@ -137,35 +137,35 @@ void QWaylandTabletToolV2::zwp_tablet_tool_v2_done() case type::type_brush: case type::type_pencil: case type::type_pen: - m_pointerType = QTabletEvent::PointerType::Pen; + m_pointerType = QPointingDevice::PointerType::Pen; break; case type::type_eraser: - m_pointerType = QTabletEvent::PointerType::Eraser; + m_pointerType = QPointingDevice::PointerType::Eraser; break; case type::type_mouse: case type::type_lens: - m_pointerType = QTabletEvent::PointerType::Cursor; + m_pointerType = QPointingDevice::PointerType::Cursor; break; case type::type_finger: - m_pointerType = QTabletEvent::PointerType::UnknownPointer; + m_pointerType = QPointingDevice::PointerType::Unknown; break; } switch (m_toolType) { case type::type_airbrush: - m_tabletDevice = QTabletEvent::TabletDevice::Airbrush; + m_tabletDevice = QInputDevice::DeviceType::Airbrush; break; case type::type_brush: case type::type_pencil: case type::type_pen: case type::type_eraser: - m_tabletDevice = m_hasRotation ? QTabletEvent::TabletDevice::RotationStylus : QTabletEvent::TabletDevice::Stylus; + m_tabletDevice = QInputDevice::DeviceType::Stylus; break; case type::type_lens: - m_tabletDevice = QTabletEvent::TabletDevice::Puck; + m_tabletDevice = QInputDevice::DeviceType::Puck; break; case type::type_mouse: case type::type_finger: - m_tabletDevice = QTabletEvent::TabletDevice::NoDevice; + m_tabletDevice = QInputDevice::DeviceType::Unknown; break; } } @@ -261,7 +261,7 @@ void QWaylandTabletToolV2::zwp_tablet_tool_v2_button(uint32_t serial, uint32_t b void QWaylandTabletToolV2::zwp_tablet_tool_v2_frame(uint32_t time) { if (m_pending.proximitySurface && !m_applied.proximitySurface) { - QWindowSystemInterface::handleTabletEnterProximityEvent(m_tabletDevice, m_pointerType, m_uid); + QWindowSystemInterface::handleTabletEnterProximityEvent(int(m_tabletDevice), int(m_pointerType), m_uid); m_applied.proximitySurface = m_pending.proximitySurface; } @@ -288,12 +288,12 @@ void QWaylandTabletToolV2::zwp_tablet_tool_v2_frame(uint32_t time) qreal rotation = m_pending.rotation; int z = int(m_pending.distance); QWindowSystemInterface::handleTabletEvent(window, timestamp, localPosition, globalPosition, - m_tabletDevice, m_pointerType, buttons, pressure, + int(m_tabletDevice), int(m_pointerType), buttons, pressure, xTilt, yTilt, tangentialPressure, rotation, z, m_uid); } if (!m_pending.proximitySurface && m_applied.enteredSurface) { - QWindowSystemInterface::handleTabletLeaveProximityEvent(m_tabletDevice, m_pointerType, m_uid); + QWindowSystemInterface::handleTabletLeaveProximityEvent(int(m_tabletDevice), int(m_pointerType), m_uid); m_pending = State(); // Don't leave pressure etc. lying around when we enter the next surface } diff --git a/src/plugins/platforms/wayland/qwaylandtabletv2_p.h b/src/plugins/platforms/wayland/qwaylandtabletv2_p.h index 36dd4268983..bf3c78f0522 100644 --- a/src/plugins/platforms/wayland/qwaylandtabletv2_p.h +++ b/src/plugins/platforms/wayland/qwaylandtabletv2_p.h @@ -58,7 +58,8 @@ #include #include #include -#include +#include +#include QT_BEGIN_NAMESPACE @@ -142,8 +143,8 @@ protected: private: // Static state (sent before done event) - QTabletEvent::PointerType m_pointerType = QTabletEvent::PointerType::UnknownPointer; - QTabletEvent::TabletDevice m_tabletDevice = QTabletEvent::TabletDevice::NoDevice; + QPointingDevice::PointerType m_pointerType = QPointingDevice::PointerType::Unknown; + QInputDevice::DeviceType m_tabletDevice = QInputDevice::DeviceType::Unknown; type m_toolType = type_pen; bool m_hasRotation = false; quint64 m_uid = 0; diff --git a/src/plugins/platforms/wayland/qwaylandtouch.cpp b/src/plugins/platforms/wayland/qwaylandtouch.cpp index 17c41fa8d42..06fa822a3d9 100644 --- a/src/plugins/platforms/wayland/qwaylandtouch.cpp +++ b/src/plugins/platforms/wayland/qwaylandtouch.cpp @@ -42,7 +42,7 @@ #include "qwaylanddisplay_p.h" #include "qwaylandsurface_p.h" -#include +#include QT_BEGIN_NAMESPACE @@ -61,10 +61,11 @@ QWaylandTouchExtension::QWaylandTouchExtension(QWaylandDisplay *display, uint32_ void QWaylandTouchExtension::registerDevice(int caps) { - mTouchDevice = new QTouchDevice; - mTouchDevice->setType(QTouchDevice::TouchScreen); - mTouchDevice->setCapabilities(QTouchDevice::Capabilities(caps)); - QWindowSystemInterface::registerTouchDevice(mTouchDevice); + // TODO number of touchpoints, actual name and ID + mTouchDevice = new QPointingDevice(QLatin1String("some touchscreen"), 0, + QInputDevice::DeviceType::TouchScreen, QPointingDevice::PointerType::Finger, + QInputDevice::Capabilities(caps), 10, 0); + QWindowSystemInterface::registerInputDevice(mTouchDevice); } static inline qreal fromFixed(int f) diff --git a/src/plugins/platforms/wayland/qwaylandtouch_p.h b/src/plugins/platforms/wayland/qwaylandtouch_p.h index 93a829e2115..444e63facae 100644 --- a/src/plugins/platforms/wayland/qwaylandtouch_p.h +++ b/src/plugins/platforms/wayland/qwaylandtouch_p.h @@ -95,7 +95,7 @@ private: QList mTouchPoints; QList mPrevTouchPoints; - QTouchDevice *mTouchDevice = nullptr; + QPointingDevice *mTouchDevice = nullptr; uint32_t mTimestamp; int mPointsLeft; uint32_t mFlags; diff --git a/tests/auto/wayland/seatv4/tst_seatv4.cpp b/tests/auto/wayland/seatv4/tst_seatv4.cpp index 1c1e7a02b5f..b6394652baa 100644 --- a/tests/auto/wayland/seatv4/tst_seatv4.cpp +++ b/tests/auto/wayland/seatv4/tst_seatv4.cpp @@ -213,7 +213,7 @@ void tst_seatv4::mousePressFloat() { class Window : public QRasterWindow { public: - void mousePressEvent(QMouseEvent *e) override { m_position = e->localPos(); } + void mousePressEvent(QMouseEvent *e) override { m_position = e->position(); } QPointF m_position; }; diff --git a/tests/auto/wayland/seatv5/tst_seatv5.cpp b/tests/auto/wayland/seatv5/tst_seatv5.cpp index 2f7e70dc936..a4d4fe4dd48 100644 --- a/tests/auto/wayland/seatv5/tst_seatv5.cpp +++ b/tests/auto/wayland/seatv5/tst_seatv5.cpp @@ -424,14 +424,14 @@ void tst_seatv5::singleTap() QCOMPARE(e.type, QEvent::TouchBegin); QCOMPARE(e.touchPointStates, Qt::TouchPointState::TouchPointPressed); QCOMPARE(e.touchPoints.length(), 1); - QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top())); + QCOMPARE(e.touchPoints.first().position(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top())); } { auto e = window.m_events.takeFirst(); QCOMPARE(e.type, QEvent::TouchEnd); QCOMPARE(e.touchPointStates, Qt::TouchPointState::TouchPointReleased); QCOMPARE(e.touchPoints.length(), 1); - QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top())); + QCOMPARE(e.touchPoints.first().position(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top())); } } @@ -455,14 +455,14 @@ void tst_seatv5::singleTapFloat() QCOMPARE(e.type, QEvent::TouchBegin); QCOMPARE(e.touchPointStates, Qt::TouchPointState::TouchPointPressed); QCOMPARE(e.touchPoints.length(), 1); - QCOMPARE(e.touchPoints.first().pos(), QPointF(32.75-window.frameMargins().left(), 32.25-window.frameMargins().top())); + QCOMPARE(e.touchPoints.first().position(), QPointF(32.75-window.frameMargins().left(), 32.25-window.frameMargins().top())); } { auto e = window.m_events.takeFirst(); QCOMPARE(e.type, QEvent::TouchEnd); QCOMPARE(e.touchPointStates, Qt::TouchPointState::TouchPointReleased); QCOMPARE(e.touchPoints.length(), 1); - QCOMPARE(e.touchPoints.first().pos(), QPointF(32.75-window.frameMargins().left(), 32.25-window.frameMargins().top())); + QCOMPARE(e.touchPoints.first().position(), QPointF(32.75-window.frameMargins().left(), 32.25-window.frameMargins().top())); } } @@ -500,10 +500,10 @@ void tst_seatv5::multiTouch() QCOMPARE(e.touchPoints.length(), 2); QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointPressed); - QCOMPARE(e.touchPoints[0].pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top())); + QCOMPARE(e.touchPoints[0].position(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top())); QCOMPARE(e.touchPoints[1].state(), Qt::TouchPointState::TouchPointPressed); - QCOMPARE(e.touchPoints[1].pos(), QPointF(48-window.frameMargins().left(), 48-window.frameMargins().top())); + QCOMPARE(e.touchPoints[1].position(), QPointF(48-window.frameMargins().left(), 48-window.frameMargins().top())); } { auto e = window.m_events.takeFirst(); @@ -511,10 +511,10 @@ void tst_seatv5::multiTouch() QCOMPARE(e.touchPoints.length(), 2); QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointMoved); - QCOMPARE(e.touchPoints[0].pos(), QPointF(33-window.frameMargins().left(), 32-window.frameMargins().top())); + QCOMPARE(e.touchPoints[0].position(), QPointF(33-window.frameMargins().left(), 32-window.frameMargins().top())); QCOMPARE(e.touchPoints[1].state(), Qt::TouchPointState::TouchPointMoved); - QCOMPARE(e.touchPoints[1].pos(), QPointF(49-window.frameMargins().left(), 48-window.frameMargins().top())); + QCOMPARE(e.touchPoints[1].position(), QPointF(49-window.frameMargins().left(), 48-window.frameMargins().top())); } { auto e = window.m_events.takeFirst(); @@ -523,10 +523,10 @@ void tst_seatv5::multiTouch() QCOMPARE(e.touchPoints.length(), 2); QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointReleased); - QCOMPARE(e.touchPoints[0].pos(), QPointF(33-window.frameMargins().left(), 32-window.frameMargins().top())); + QCOMPARE(e.touchPoints[0].position(), QPointF(33-window.frameMargins().left(), 32-window.frameMargins().top())); QCOMPARE(e.touchPoints[1].state(), Qt::TouchPointState::TouchPointStationary); - QCOMPARE(e.touchPoints[1].pos(), QPointF(49-window.frameMargins().left(), 48-window.frameMargins().top())); + QCOMPARE(e.touchPoints[1].position(), QPointF(49-window.frameMargins().left(), 48-window.frameMargins().top())); } { auto e = window.m_events.takeFirst(); @@ -534,7 +534,7 @@ void tst_seatv5::multiTouch() QCOMPARE(e.touchPointStates, Qt::TouchPointState::TouchPointReleased); QCOMPARE(e.touchPoints.length(), 1); QCOMPARE(e.touchPoints[0].state(), Qt::TouchPointState::TouchPointReleased); - QCOMPARE(e.touchPoints[0].pos(), QPointF(49-window.frameMargins().left(), 48-window.frameMargins().top())); + QCOMPARE(e.touchPoints[0].position(), QPointF(49-window.frameMargins().left(), 48-window.frameMargins().top())); } } diff --git a/tests/auto/wayland/tabletv2/tst_tabletv2.cpp b/tests/auto/wayland/tabletv2/tst_tabletv2.cpp index 1c48a77f977..2cbafa35f7f 100644 --- a/tests/auto/wayland/tabletv2/tst_tabletv2.cpp +++ b/tests/auto/wayland/tabletv2/tst_tabletv2.cpp @@ -416,7 +416,7 @@ public: }; Q_DECLARE_METATYPE(QtWaylandServer::zwp_tablet_tool_v2::type); -Q_DECLARE_METATYPE(QTabletEvent::PointerType); +Q_DECLARE_METATYPE(QPointingDevice::PointerType); Q_DECLARE_METATYPE(Qt::MouseButton); class tst_tabletv2 : public QObject, private TabletCompositor @@ -465,8 +465,8 @@ protected: case QEvent::TabletEnterProximity: case QEvent::TabletLeaveProximity: { auto *e = static_cast(event); - auto *ev = new QTabletEvent(e->type(), e->posF(), e->globalPosF(), e->deviceType(), - e->pointerType(), e->pressure(), e->xTilt(), e->yTilt(), + auto *ev = new QTabletEvent(e->type(), e->position(), e->globalPosition(), int(e->deviceType()), + int(e->pointerType()), e->pressure(), e->xTilt(), e->yTilt(), e->tangentialPressure(), e->rotation(), e->z(), Qt::KeyboardModifier::NoModifier, e->uniqueId(), e->button(), e->buttons()); @@ -600,8 +600,8 @@ public: void tabletEvent(QTabletEvent *e) override { - m_events << new QTabletEvent(e->type(), e->posF(), e->globalPosF(), e->deviceType(), - e->pointerType(), e->pressure(), e->xTilt(), e->yTilt(), + m_events << new QTabletEvent(e->type(), e->position(), e->globalPosition(), int(e->deviceType()), + int(e->pointerType()), e->pressure(), e->xTilt(), e->yTilt(), e->tangentialPressure(), e->rotation(), e->z(), Qt::KeyboardModifier::NoModifier, e->uniqueId(), e->button(), e->buttons()); @@ -650,34 +650,34 @@ void tst_tabletv2::moveEvent() QTabletEvent *event = window.popEvent(); QCOMPARE(event->type(), QEvent::TabletMove); QCOMPARE(event->pressure(), 0); - QCOMPARE(event->posF(), QPointF(12, 34)); + QCOMPARE(event->position(), QPointF(12, 34)); } void tst_tabletv2::pointerType_data() { QTest::addColumn("toolType"); - QTest::addColumn("pointerType"); - QTest::addColumn("tabletDevice"); + QTest::addColumn("pointerType"); + QTest::addColumn("tabletDevice"); - QTest::newRow("pen") << ToolType::type_pen << QTabletEvent::PointerType::Pen << QTabletEvent::TabletDevice::Stylus; - QTest::newRow("eraser") << ToolType::type_eraser << QTabletEvent::PointerType::Eraser << QTabletEvent::TabletDevice::Stylus; - QTest::newRow("pencil") << ToolType::type_pencil << QTabletEvent::PointerType::Pen << QTabletEvent::TabletDevice::Stylus; - QTest::newRow("airbrush") << ToolType::type_airbrush << QTabletEvent::PointerType::Pen << QTabletEvent::TabletDevice::Airbrush; - QTest::newRow("brush") << ToolType::type_brush << QTabletEvent::PointerType::Pen << QTabletEvent::TabletDevice::Stylus; // TODO: is TabletDevice::Stylus the right thing? - QTest::newRow("lens") << ToolType::type_lens << QTabletEvent::PointerType::Cursor << QTabletEvent::TabletDevice::Puck; + QTest::newRow("pen") << ToolType::type_pen << QPointingDevice::PointerType::Pen << QInputDevice::DeviceType::Stylus; + QTest::newRow("eraser") << ToolType::type_eraser << QPointingDevice::PointerType::Eraser << QInputDevice::DeviceType::Stylus; + QTest::newRow("pencil") << ToolType::type_pencil << QPointingDevice::PointerType::Pen << QInputDevice::DeviceType::Stylus; + QTest::newRow("airbrush") << ToolType::type_airbrush << QPointingDevice::PointerType::Pen << QInputDevice::DeviceType::Airbrush; + QTest::newRow("brush") << ToolType::type_brush << QPointingDevice::PointerType::Pen << QInputDevice::DeviceType::Stylus; // TODO: is TabletDevice::Stylus the right thing? + QTest::newRow("lens") << ToolType::type_lens << QPointingDevice::PointerType::Cursor << QInputDevice::DeviceType::Puck; // TODO: also add tests for FourDMouse and RotationStylus (also need to send capabilities) // TODO: should these rather be mapped to touch/mouse events? - QTest::newRow("finger") << ToolType::type_finger << QTabletEvent::PointerType::UnknownPointer << QTabletEvent::TabletDevice::NoDevice; - QTest::newRow("mouse") << ToolType::type_mouse << QTabletEvent::PointerType::Cursor << QTabletEvent::TabletDevice::NoDevice; + QTest::newRow("finger") << ToolType::type_finger << QPointingDevice::PointerType::Unknown << QInputDevice::DeviceType::Unknown; + QTest::newRow("mouse") << ToolType::type_mouse << QPointingDevice::PointerType::Cursor << QInputDevice::DeviceType::Unknown; } void tst_tabletv2::pointerType() { using ToolType = QtWaylandServer::zwp_tablet_tool_v2::type; QFETCH(ToolType, toolType); - QFETCH(QTabletEvent::PointerType, pointerType); - QFETCH(QTabletEvent::TabletDevice, tabletDevice); + QFETCH(QPointingDevice::PointerType, pointerType); + QFETCH(QInputDevice::DeviceType, tabletDevice); ProximityFilter filter; @@ -726,7 +726,7 @@ void tst_tabletv2::pointerType() void tst_tabletv2::hardwareSerial() { ProximityFilter filter; - const quint64 uid = 0xbaba15dead15f00d; + const qint64 uid = 0xbaba15dead15f00d; QCOMPOSITOR_TRY_VERIFY(tabletSeat()); exec([&] { @@ -860,7 +860,7 @@ void tst_tabletv2::tabletEvents() QTabletEvent *event = window.popEvent(); QCOMPARE(event->type(), QEvent::TabletPress); QCOMPARE(event->pressure(), 1.0); - QCOMPARE(event->posF(), QPointF(12, 34)); + QCOMPARE(event->position(), QPointF(12, 34)); // Values we didn't send should be 0 QCOMPARE(event->rotation(), 0); @@ -882,7 +882,7 @@ void tst_tabletv2::tabletEvents() QVERIFY(qAbs(event->rotation() - 90) < 0.01); QVERIFY(qAbs(event->xTilt() - 13) < 0.01); QVERIFY(qAbs(event->yTilt() - 37) < 0.01); - QCOMPARE(event->posF(), QPointF(45, 56)); + QCOMPARE(event->position(), QPointF(45, 56)); // Verify that the values stay the same if we don't update them exec([&] { @@ -896,7 +896,7 @@ void tst_tabletv2::tabletEvents() QVERIFY(qAbs(event->rotation() - 90) < 0.01); QVERIFY(qAbs(event->xTilt() - 13) < 0.01); QVERIFY(qAbs(event->yTilt() - 37) < 0.01); - QCOMPARE(event->posF(), QPointF(10, 11)); + QCOMPARE(event->position(), QPointF(10, 11)); exec([&] { tabletTool()->sendPressure(0); @@ -911,7 +911,7 @@ void tst_tabletv2::tabletEvents() event = window.popEvent(); QCOMPARE(event->type(), QEvent::TabletRelease); QCOMPARE(event->pressure(), 0); - QCOMPARE(event->posF(), QPointF(10, 11)); + QCOMPARE(event->position(), QPointF(10, 11)); } QCOMPOSITOR_TEST_MAIN(tst_tabletv2)