From 444e334265735a5866e168ef5d86d34483bb0f01 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 30 Sep 2024 16:02:06 +0200 Subject: [PATCH] Client: Send mouse events with QPointingDevice instances We can't distinguish devices so far on Wayland: primaryPointingDevice() is just an assumption. But at least we know which seat sends the event. After this change, for example, the mouse seat name is visible in qtdeclarative/examples/quick/pointerhandlers/singlePointHandlerProperties.qml Task-number: QTBUG-85272 Task-number: QTBUG-115207 Task-number: QTBUG-129087 Pick-to: 6.8 Change-Id: I3822075bf5680c40b55868f413c48adaea1d3fec Reviewed-by: David Edmundson --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 8c553c27fb3..232b6503d9b 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -1188,6 +1188,9 @@ QWaylandWindow *QWaylandWindow::guessTransientParent() const void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e) { + // There's currently no way to get info about the actual hardware device in use. + // At least we get the correct seat. + const QPointingDevice *device = QPointingDevice::primaryPointingDevice(inputDevice->seatname()); if (e.type == QEvent::Leave) { if (mWindowDecorationEnabled) { if (mMouseEventsInContentArea) @@ -1211,10 +1214,10 @@ void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylan case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseMove: - QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, e.local, e.global, e.buttons, e.button, e.type, e.modifiers); + QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, device, e.local, e.global, e.buttons, e.button, e.type, e.modifiers); break; case QEvent::Wheel: - QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, e.local, e.global, + QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, device, e.local, e.global, e.pixelDelta, e.angleDelta, e.modifiers, e.phase, e.source, e.inverted); break; @@ -1378,6 +1381,9 @@ bool QWaylandWindow::handleTabletEventDecoration(QWaylandInputDevice *inputDevic void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e) { + // There's currently no way to get info about the actual hardware device in use. + // At least we get the correct seat. + const QPointingDevice *device = QPointingDevice::primaryPointingDevice(inputDevice->seatname()); if (mMousePressedInContentArea == Qt::NoButton && mWindowDecoration->handleMouse(inputDevice, e.local, e.global, e.buttons, e.modifiers)) { if (mMouseEventsInContentArea) { @@ -1411,10 +1417,10 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseMove: - QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, localTranslated, globalTranslated, e.buttons, e.button, e.type, e.modifiers); + QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, device, localTranslated, globalTranslated, e.buttons, e.button, e.type, e.modifiers); break; case QEvent::Wheel: { - QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, + QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, device, localTranslated, globalTranslated, e.pixelDelta, e.angleDelta, e.modifiers, e.phase, e.source, e.inverted);