diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-06-25 15:04:20 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2020-06-26 10:46:20 +0200 |
commit | bad18e2db95a399e350b890a0cd084d53c1e2ae8 (patch) | |
tree | 9af16cdafdb00252df807cf4db8572318cd4d5aa | |
parent | 04ed6ad3fc9816947dfe1b3924ca2f109372408c (diff) |
Adapt to new QPointingDevice API
QTouchDevice has been replaced with a more general QPointingDevice.
All input devices need detailed information and need to be registered
via QWindowSystemInterface::registerInputDevice(). This patch is not
doing that yet; it's just enough to get qtwayland to compile again.
Done-With: Liang Qi <liang.qi@qt.io>
Change-Id: Id3a2e475ed07294a1977004fc72b11e466acc216
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r-- | examples/wayland/minimal-cpp/window.cpp | 6 | ||||
-rw-r--r-- | examples/wayland/qwindow-compositor/compositor.cpp | 4 | ||||
-rw-r--r-- | examples/wayland/qwindow-compositor/window.cpp | 24 | ||||
-rw-r--r-- | src/client/qwaylandinputdevice.cpp | 11 | ||||
-rw-r--r-- | src/client/qwaylandinputdevice_p.h | 2 | ||||
-rw-r--r-- | src/client/qwaylandtabletv2.cpp | 22 | ||||
-rw-r--r-- | src/client/qwaylandtabletv2_p.h | 7 | ||||
-rw-r--r-- | src/client/qwaylandtouch.cpp | 11 | ||||
-rw-r--r-- | src/client/qwaylandtouch_p.h | 2 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandquickitem.cpp | 32 | ||||
-rw-r--r-- | src/compositor/extensions/qwaylandwlshellintegration.cpp | 8 | ||||
-rw-r--r-- | src/compositor/extensions/qwaylandxdgshellintegration.cpp | 8 | ||||
-rw-r--r-- | src/compositor/extensions/qwaylandxdgshellv5integration.cpp | 8 | ||||
-rw-r--r-- | src/compositor/extensions/qwaylandxdgshellv6integration.cpp | 8 | ||||
-rw-r--r-- | src/compositor/extensions/qwlqttouch.cpp | 4 | ||||
-rw-r--r-- | tests/auto/client/seatv4/tst_seatv4.cpp | 2 | ||||
-rw-r--r-- | tests/auto/client/seatv5/tst_seatv5.cpp | 22 | ||||
-rw-r--r-- | tests/auto/client/tabletv2/tst_tabletv2.cpp | 48 |
18 files changed, 116 insertions, 113 deletions
diff --git a/examples/wayland/minimal-cpp/window.cpp b/examples/wayland/minimal-cpp/window.cpp index 9f22cc68a..4d1c1a890 100644 --- a/examples/wayland/minimal-cpp/window.cpp +++ b/examples/wayland/minimal-cpp/window.cpp @@ -114,17 +114,17 @@ void Window::paintGL() void Window::mousePressEvent(QMouseEvent *event) { - m_compositor->handleMousePress(event->localPos().toPoint(), event->button()); + m_compositor->handleMousePress(event->position().toPoint(), event->button()); } void Window::mouseReleaseEvent(QMouseEvent *event) { - m_compositor->handleMouseRelease(event->localPos().toPoint(), event->button(), event->buttons()); + m_compositor->handleMouseRelease(event->position().toPoint(), event->button(), event->buttons()); } void Window::mouseMoveEvent(QMouseEvent *event) { - m_compositor->handleMouseMove(event->localPos().toPoint()); + m_compositor->handleMouseMove(event->position().toPoint()); } void Window::wheelEvent(QWheelEvent *event) diff --git a/examples/wayland/qwindow-compositor/compositor.cpp b/examples/wayland/qwindow-compositor/compositor.cpp index 220ea3d74..72f23ce6c 100644 --- a/examples/wayland/qwindow-compositor/compositor.cpp +++ b/examples/wayland/qwindow-compositor/compositor.cpp @@ -461,7 +461,7 @@ void Compositor::handleMouseEvent(QWaylandView *target, QMouseEvent *me) seat->sendMouseReleaseEvent(me->button()); break; case QEvent::MouseMove: - seat->sendMouseMoveEvent(target, me->localPos(), me->globalPos()); + seat->sendMouseMoveEvent(target, me->position(), me->globalPosition()); default: break; } @@ -496,7 +496,7 @@ void Compositor::startDrag() void Compositor::handleDrag(View *target, QMouseEvent *me) { - QPointF pos = me->localPos(); + QPointF pos = me->position(); QWaylandSurface *surface = nullptr; if (target) { pos -= target->position(); diff --git a/examples/wayland/qwindow-compositor/window.cpp b/examples/wayland/qwindow-compositor/window.cpp index c439d20a8..34066f42d 100644 --- a/examples/wayland/qwindow-compositor/window.cpp +++ b/examples/wayland/qwindow-compositor/window.cpp @@ -198,7 +198,7 @@ void Window::mousePressEvent(QMouseEvent *e) if (mouseGrab()) return; if (m_mouseView.isNull()) { - m_mouseView = viewAt(e->localPos()); + m_mouseView = viewAt(e->position()); if (!m_mouseView) { m_compositor->closePopups(); return; @@ -207,10 +207,10 @@ void Window::mousePressEvent(QMouseEvent *e) m_grabState = MoveGrab; //start move else m_compositor->raise(m_mouseView); - m_initialMousePos = e->localPos(); - m_mouseOffset = e->localPos() - m_mouseView->position(); + m_initialMousePos = e->position(); + m_mouseOffset = e->position() - m_mouseView->position(); - QMouseEvent moveEvent(QEvent::MouseMove, e->localPos(), e->globalPos(), Qt::NoButton, Qt::NoButton, e->modifiers()); + QMouseEvent moveEvent(QEvent::MouseMove, e->position(), e->globalPosition(), Qt::NoButton, Qt::NoButton, e->modifiers()); sendMouseEvent(&moveEvent, m_mouseView); } sendMouseEvent(e, m_mouseView); @@ -222,7 +222,7 @@ void Window::mouseReleaseEvent(QMouseEvent *e) sendMouseEvent(e, m_mouseView); if (e->buttons() == Qt::NoButton) { if (m_grabState == DragGrab) { - View *view = viewAt(e->localPos()); + View *view = viewAt(e->position()); m_compositor->handleDrag(view, e); } m_mouseView = nullptr; @@ -234,27 +234,27 @@ void Window::mouseMoveEvent(QMouseEvent *e) { switch (m_grabState) { case NoGrab: { - View *view = m_mouseView ? m_mouseView.data() : viewAt(e->localPos()); + View *view = m_mouseView ? m_mouseView.data() : viewAt(e->position()); sendMouseEvent(e, view); if (!view) setCursor(Qt::ArrowCursor); } break; case MoveGrab: { - m_mouseView->setPosition(e->localPos() - m_mouseOffset); + m_mouseView->setPosition(e->position() - m_mouseOffset); update(); } break; case ResizeGrab: { - QPoint delta = (e->localPos() - m_initialMousePos).toPoint(); + QPoint delta = (e->position() - m_initialMousePos).toPoint(); m_compositor->handleResize(m_mouseView, m_initialSize, delta, m_resizeEdge); } break; case DragGrab: { - View *view = viewAt(e->localPos()); + View *view = viewAt(e->position()); m_compositor->handleDrag(view, e); if (m_dragIconView) { - m_dragIconView->setPosition(e->localPos() + m_dragIconView->offset()); + m_dragIconView->setPosition(e->position() + m_dragIconView->offset()); update(); } } @@ -264,10 +264,10 @@ void Window::mouseMoveEvent(QMouseEvent *e) void Window::sendMouseEvent(QMouseEvent *e, View *target) { - QPointF mappedPos = e->localPos(); + QPointF mappedPos = e->position(); if (target) mappedPos -= target->position(); - QMouseEvent viewEvent(e->type(), mappedPos, e->localPos(), e->button(), e->buttons(), e->modifiers()); + QMouseEvent viewEvent(e->type(), mappedPos, e->position(), e->button(), e->buttons(), e->modifiers()); m_compositor->handleMouseEvent(target, &viewEvent); } diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index 1de2ef17c..af9458b44 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -73,7 +73,7 @@ #endif #include <QtGui/QGuiApplication> -#include <QtGui/QTouchDevice> +#include <QtGui/QPointingDevice> 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/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h index 448d0fce5..8e2dd184b 100644 --- a/src/client/qwaylandinputdevice_p.h +++ b/src/client/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/client/qwaylandtabletv2.cpp b/src/client/qwaylandtabletv2.cpp index eb2e865f6..0f55aba9e 100644 --- a/src/client/qwaylandtabletv2.cpp +++ b/src/client/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/client/qwaylandtabletv2_p.h b/src/client/qwaylandtabletv2_p.h index 36dd42689..bf3c78f05 100644 --- a/src/client/qwaylandtabletv2_p.h +++ b/src/client/qwaylandtabletv2_p.h @@ -58,7 +58,8 @@ #include <QtCore/QObject> #include <QtCore/QPointer> #include <QtCore/QPointF> -#include <QtGui/QTabletEvent> +#include <QtGui/QPointingDevice> +#include <QtGui/QInputDevice> 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/client/qwaylandtouch.cpp b/src/client/qwaylandtouch.cpp index 17c41fa8d..06fa822a3 100644 --- a/src/client/qwaylandtouch.cpp +++ b/src/client/qwaylandtouch.cpp @@ -42,7 +42,7 @@ #include "qwaylanddisplay_p.h" #include "qwaylandsurface_p.h" -#include <QtGui/QTouchDevice> +#include <QtGui/QPointingDevice> 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/client/qwaylandtouch_p.h b/src/client/qwaylandtouch_p.h index 93a829e21..444e63fac 100644 --- a/src/client/qwaylandtouch_p.h +++ b/src/client/qwaylandtouch_p.h @@ -95,7 +95,7 @@ private: QList<QWindowSystemInterface::TouchPoint> mTouchPoints; QList<QWindowSystemInterface::TouchPoint> mPrevTouchPoints; - QTouchDevice *mTouchDevice = nullptr; + QPointingDevice *mTouchDevice = nullptr; uint32_t mTimestamp; int mPointsLeft; uint32_t mFlags; diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index 3e069d9a9..45431cfa1 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -480,7 +480,7 @@ void QWaylandQuickItem::mousePressEvent(QMouseEvent *event) return; } - if (!inputRegionContains(event->localPos())) { + if (!inputRegionContains(event->position())) { event->ignore(); return; } @@ -490,9 +490,9 @@ void QWaylandQuickItem::mousePressEvent(QMouseEvent *event) if (d->focusOnClick) takeFocus(seat); - seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos()); + seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), event->scenePosition()); seat->sendMousePressEvent(event->button()); - d->hoverPos = event->localPos(); + d->hoverPos = event->position(); } /*! @@ -507,21 +507,21 @@ void QWaylandQuickItem::mouseMoveEvent(QMouseEvent *event) if (d->isDragging) { QWaylandQuickOutput *currentOutput = qobject_cast<QWaylandQuickOutput *>(view()->output()); //TODO: also check if dragging onto other outputs - QWaylandQuickItem *targetItem = qobject_cast<QWaylandQuickItem *>(currentOutput->pickClickableItem(mapToScene(event->localPos()))); + QWaylandQuickItem *targetItem = qobject_cast<QWaylandQuickItem *>(currentOutput->pickClickableItem(mapToScene(event->position()))); QWaylandSurface *targetSurface = targetItem ? targetItem->surface() : nullptr; if (targetSurface) { - QPointF position = mapToItem(targetItem, event->localPos()); + QPointF position = mapToItem(targetItem, event->position()); QPointF surfacePosition = targetItem->mapToSurface(position); seat->drag()->dragMove(targetSurface, surfacePosition); } } else #endif // QT_CONFIG(draganddrop) { - seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->localPos()), event->windowPos()); - d->hoverPos = event->localPos(); + seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), event->scenePosition()); + d->hoverPos = event->position(); } } else { - emit mouseMove(event->windowPos()); + emit mouseMove(event->scenePosition()); event->ignore(); } } @@ -555,14 +555,14 @@ void QWaylandQuickItem::mouseReleaseEvent(QMouseEvent *event) void QWaylandQuickItem::hoverEnterEvent(QHoverEvent *event) { Q_D(QWaylandQuickItem); - if (!inputRegionContains(event->posF())) { + if (!inputRegionContains(event->position())) { event->ignore(); return; } if (d->shouldSendInputEvents()) { QWaylandSeat *seat = compositor()->seatFor(event); - seat->sendMouseMoveEvent(d->view.data(), event->posF(), mapToScene(event->posF())); - d->hoverPos = event->posF(); + seat->sendMouseMoveEvent(d->view.data(), event->position(), mapToScene(event->position())); + d->hoverPos = event->position(); } else { event->ignore(); } @@ -575,16 +575,16 @@ void QWaylandQuickItem::hoverMoveEvent(QHoverEvent *event) { Q_D(QWaylandQuickItem); if (surface()) { - if (!inputRegionContains(event->posF())) { + if (!inputRegionContains(event->position())) { event->ignore(); return; } } if (d->shouldSendInputEvents()) { QWaylandSeat *seat = compositor()->seatFor(event); - if (event->posF() != d->hoverPos) { - seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->posF()), mapToScene(event->posF())); - d->hoverPos = event->posF(); + if (event->position() != d->hoverPos) { + seat->sendMouseMoveEvent(d->view.data(), mapToSurface(event->position()), mapToScene(event->position())); + d->hoverPos = event->position(); } } else { event->ignore(); @@ -673,7 +673,7 @@ void QWaylandQuickItem::touchEvent(QTouchEvent *event) QPointF pointPos; const QList<QTouchEvent::TouchPoint> &points = event->touchPoints(); if (!points.isEmpty()) - pointPos = points.at(0).pos(); + pointPos = points.at(0).position(); if (event->type() == QEvent::TouchBegin && !inputRegionContains(pointPos)) { event->ignore(); diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp index 3853d7eec..ef81aad37 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration.cpp +++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp @@ -296,25 +296,25 @@ bool WlShellIntegration::filterMouseMoveEvent(QMouseEvent *event) if (grabberState == GrabberState::Resize) { Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); if (!resizeState.initialized) { - resizeState.initialMousePos = event->windowPos(); + resizeState.initialMousePos = event->scenePosition(); resizeState.initialized = true; return true; } float scaleFactor = m_item->view()->output()->scaleFactor(); - QPointF delta = (event->windowPos() - resizeState.initialMousePos) / scaleFactor * devicePixelRatio(); + QPointF delta = (event->scenePosition() - resizeState.initialMousePos) / scaleFactor * devicePixelRatio(); QSize newSize = m_shellSurface->sizeForResize(resizeState.initialSize, delta, resizeState.resizeEdges); m_shellSurface->sendConfigure(newSize, resizeState.resizeEdges); } else if (grabberState == GrabberState::Move) { Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event)); QQuickItem *moveItem = m_item->moveItem(); if (!moveState.initialized) { - moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); + moveState.initialOffset = moveItem->mapFromItem(nullptr, event->scenePosition()); moveState.initialized = true; return true; } if (!moveItem->parentItem()) return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); + QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->scenePosition()); moveItem->setPosition(parentPos - moveState.initialOffset); } return false; diff --git a/src/compositor/extensions/qwaylandxdgshellintegration.cpp b/src/compositor/extensions/qwaylandxdgshellintegration.cpp index 9534ec942..89c1ef91b 100644 --- a/src/compositor/extensions/qwaylandxdgshellintegration.cpp +++ b/src/compositor/extensions/qwaylandxdgshellintegration.cpp @@ -94,24 +94,24 @@ bool XdgToplevelIntegration::filterMouseMoveEvent(QMouseEvent *event) if (grabberState == GrabberState::Resize) { Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); if (!resizeState.initialized) { - resizeState.initialMousePos = event->windowPos(); + resizeState.initialMousePos = event->scenePosition(); resizeState.initialized = true; return true; } - QPointF delta = m_item->mapToSurface(event->windowPos() - resizeState.initialMousePos); + QPointF delta = m_item->mapToSurface(event->scenePosition() - resizeState.initialMousePos); QSize newSize = m_toplevel->sizeForResize(resizeState.initialWindowSize, delta, resizeState.resizeEdges); m_toplevel->sendResizing(newSize); } else if (grabberState == GrabberState::Move) { Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event)); QQuickItem *moveItem = m_item->moveItem(); if (!moveState.initialized) { - moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); + moveState.initialOffset = moveItem->mapFromItem(nullptr, event->scenePosition()); moveState.initialized = true; return true; } if (!moveItem->parentItem()) return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); + QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->scenePosition()); moveItem->setPosition(parentPos - moveState.initialOffset); } return false; diff --git a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp index 2f11130fe..375f0e9fd 100644 --- a/src/compositor/extensions/qwaylandxdgshellv5integration.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv5integration.cpp @@ -91,24 +91,24 @@ bool XdgShellV5Integration::filterMouseMoveEvent(QMouseEvent *event) if (grabberState == GrabberState::Resize) { Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); if (!resizeState.initialized) { - resizeState.initialMousePos = event->windowPos(); + resizeState.initialMousePos = event->scenePosition(); resizeState.initialized = true; return true; } - QPointF delta = m_item->mapToSurface(event->windowPos() - resizeState.initialMousePos); + QPointF delta = m_item->mapToSurface(event->scenePosition() - resizeState.initialMousePos); QSize newSize = m_xdgSurface->sizeForResize(resizeState.initialWindowSize, delta, resizeState.resizeEdges); m_xdgSurface->sendResizing(newSize); } else if (grabberState == GrabberState::Move) { Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event)); QQuickItem *moveItem = m_item->moveItem(); if (!moveState.initialized) { - moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); + moveState.initialOffset = moveItem->mapFromItem(nullptr, event->scenePosition()); moveState.initialized = true; return true; } if (!moveItem->parentItem()) return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); + QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->scenePosition()); moveItem->setPosition(parentPos - moveState.initialOffset); } return false; diff --git a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp b/src/compositor/extensions/qwaylandxdgshellv6integration.cpp index a86151dad..f4a8a399f 100644 --- a/src/compositor/extensions/qwaylandxdgshellv6integration.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv6integration.cpp @@ -96,24 +96,24 @@ bool XdgToplevelV6Integration::filterMouseMoveEvent(QMouseEvent *event) if (grabberState == GrabberState::Resize) { Q_ASSERT(resizeState.seat == m_item->compositor()->seatFor(event)); if (!resizeState.initialized) { - resizeState.initialMousePos = event->windowPos(); + resizeState.initialMousePos = event->scenePosition(); resizeState.initialized = true; return true; } - QPointF delta = m_item->mapToSurface(event->windowPos() - resizeState.initialMousePos); + QPointF delta = m_item->mapToSurface(event->scenePosition() - resizeState.initialMousePos); QSize newSize = m_toplevel->sizeForResize(resizeState.initialWindowSize, delta, resizeState.resizeEdges); m_toplevel->sendResizing(newSize); } else if (grabberState == GrabberState::Move) { Q_ASSERT(moveState.seat == m_item->compositor()->seatFor(event)); QQuickItem *moveItem = m_item->moveItem(); if (!moveState.initialized) { - moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); + moveState.initialOffset = moveItem->mapFromItem(nullptr, event->scenePosition()); moveState.initialized = true; return true; } if (!moveItem->parentItem()) return true; - QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); + QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->scenePosition()); moveItem->setPosition(parentPos - moveState.initialOffset); } return false; diff --git a/src/compositor/extensions/qwlqttouch.cpp b/src/compositor/extensions/qwlqttouch.cpp index f9d1a368f..ca92cc2c8 100644 --- a/src/compositor/extensions/qwlqttouch.cpp +++ b/src/compositor/extensions/qwlqttouch.cpp @@ -29,8 +29,8 @@ #include "qwlqttouch_p.h" #include "qwaylandview.h" +#include <QPointingDevice> #include <QTouchEvent> -#include <QTouchDevice> #include <QWindow> QT_BEGIN_NAMESPACE @@ -89,7 +89,7 @@ bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, QWaylandSurface *s uint32_t id = tp.id(); uint32_t state = (tp.state() & 0xFFFF) | (sentPointCount << 16); - uint32_t flags = (tp.flags() & 0xFFFF) | (int(event->device()->capabilities()) << 16); + uint32_t flags = (tp.flags() & 0xFFFF) | (int(event->pointingDevice()->capabilities()) << 16); int x = toFixed(tp.pos().x()); int y = toFixed(tp.pos().y()); diff --git a/tests/auto/client/seatv4/tst_seatv4.cpp b/tests/auto/client/seatv4/tst_seatv4.cpp index 1c1e7a02b..b6394652b 100644 --- a/tests/auto/client/seatv4/tst_seatv4.cpp +++ b/tests/auto/client/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/client/seatv5/tst_seatv5.cpp b/tests/auto/client/seatv5/tst_seatv5.cpp index 2f7e70dc9..a4d4fe4dd 100644 --- a/tests/auto/client/seatv5/tst_seatv5.cpp +++ b/tests/auto/client/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/client/tabletv2/tst_tabletv2.cpp b/tests/auto/client/tabletv2/tst_tabletv2.cpp index 1c48a77f9..2cbafa35f 100644 --- a/tests/auto/client/tabletv2/tst_tabletv2.cpp +++ b/tests/auto/client/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<QTabletEvent *>(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>("toolType"); - QTest::addColumn<QTabletEvent::PointerType>("pointerType"); - QTest::addColumn<QTabletEvent::TabletDevice>("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::addColumn<QPointingDevice::PointerType>("pointerType"); + QTest::addColumn<QInputDevice::DeviceType>("tabletDevice"); + + 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) |