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 <davidedmundson@kde.org>
This commit is contained in:
Shawn Rutledge 2024-09-30 16:02:06 +02:00
parent 33dcb1d7ec
commit 444e334265

View File

@ -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);