From 0744ee09ed6e62f44386e55d491cecfa01f6193e Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 30 Aug 2022 20:13:28 +0200 Subject: [PATCH] libinput: Include the Pad name in the TabletPadId It's helpful to identify what pad we are referring to in a cross-session way where a pointer won't hold. --- src/backends/libinput/connection.cpp | 18 +++++++++++++++--- src/input_event.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/backends/libinput/connection.cpp b/src/backends/libinput/connection.cpp index c970eee937..1734f85fc0 100644 --- a/src/backends/libinput/connection.cpp +++ b/src/backends/libinput/connection.cpp @@ -251,6 +251,18 @@ KWin::TabletToolId createTabletId(libinput_tablet_tool *tool, void *userData) return {toolType, capabilities, serial, toolId, userData}; } +static TabletPadId createTabletPadId(LibInput::Device *device) +{ + if (!device || !device->groupUserData()) { + return {}; + } + + return { + device->name(), + device->groupUserData(), + }; +} + void Connection::processEvents() { QMutexLocker locker(&m_mutex); @@ -478,7 +490,7 @@ void Connection::processEvents() auto *tabletEvent = static_cast(event.get()); Q_EMIT event->device()->tabletPadButtonEvent(tabletEvent->buttonId(), tabletEvent->isButtonPressed(), - {event->device()->groupUserData()}, tabletEvent->time()); + createTabletPadId(event->device()), tabletEvent->time()); break; } case LIBINPUT_EVENT_TABLET_PAD_RING: { @@ -487,7 +499,7 @@ void Connection::processEvents() Q_EMIT event->device()->tabletPadRingEvent(tabletEvent->number(), tabletEvent->position(), tabletEvent->source() == LIBINPUT_TABLET_PAD_RING_SOURCE_FINGER, - {event->device()->groupUserData()}, tabletEvent->time()); + createTabletPadId(event->device()), tabletEvent->time()); break; } case LIBINPUT_EVENT_TABLET_PAD_STRIP: { @@ -495,7 +507,7 @@ void Connection::processEvents() Q_EMIT event->device()->tabletPadStripEvent(tabletEvent->number(), tabletEvent->position(), tabletEvent->source() == LIBINPUT_TABLET_PAD_STRIP_SOURCE_FINGER, - {event->device()->groupUserData()}, tabletEvent->time()); + createTabletPadId(event->device()), tabletEvent->time()); break; } default: diff --git a/src/input_event.h b/src/input_event.h index 7cac99887f..84f6ea3cbf 100644 --- a/src/input_event.h +++ b/src/input_event.h @@ -196,6 +196,7 @@ public: class TabletPadId { public: + const QString name; void *data; };