From 0698691856299e9c18f7d39896ee665c4f8926d7 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 23 Oct 2024 17:39:46 +0300 Subject: [PATCH] Lookup TabletV2Interface by sysname This gets rid of some libinput specific logic and makes the code more generic. --- src/backends/libinput/connection.cpp | 2 +- src/backends/libinput/device.cpp | 6 ------ src/backends/libinput/device.h | 2 -- src/input.cpp | 3 ++- src/input_event.h | 1 - src/wayland/tablet_v2.cpp | 6 ++++++ src/wayland/tablet_v2.h | 1 + 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/backends/libinput/connection.cpp b/src/backends/libinput/connection.cpp index d2199317cd..d8f4d5b1ea 100644 --- a/src/backends/libinput/connection.cpp +++ b/src/backends/libinput/connection.cpp @@ -245,7 +245,7 @@ KWin::TabletToolId createTabletId(libinput_tablet_tool *tool, Device *dev) if (libinput_tablet_tool_has_wheel(tool)) { capabilities << InputRedirection::Wheel; } - return {dev->sysName(), toolType, capabilities, serial, toolId, dev->groupUserData(), dev->name()}; + return {dev->sysName(), toolType, capabilities, serial, toolId, dev->name()}; } void Connection::processEvents() diff --git a/src/backends/libinput/device.cpp b/src/backends/libinput/device.cpp index 650c00d405..1d23fe2171 100644 --- a/src/backends/libinput/device.cpp +++ b/src/backends/libinput/device.cpp @@ -542,12 +542,6 @@ int Device::ringsCount() const return libinput_device_tablet_pad_get_num_rings(m_device); } -void *Device::groupUserData() const -{ - auto deviceGroup = libinput_device_get_device_group(m_device); - return libinput_device_group_get_user_data(deviceGroup); -} - #define CONFIG(method, condition, function, variable, key) \ void Device::method(bool set) \ { \ diff --git a/src/backends/libinput/device.h b/src/backends/libinput/device.h index 76a6b94b31..e845775758 100644 --- a/src/backends/libinput/device.h +++ b/src/backends/libinput/device.h @@ -632,8 +632,6 @@ public: int stripsCount() const; int ringsCount() const; - void *groupUserData() const; - Output *output() const; void setOutput(Output *output); diff --git a/src/input.cpp b/src/input.cpp index 85c48dcb0a..d8e70bcef4 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -2043,7 +2043,8 @@ public: // NOTE: tablet will be nullptr as the device is removed (see ::removeDevice) but events from the tool // may still happen (e.g. Release or ProximityOut events) - auto tablet = static_cast(event->toolId().m_deviceGroupData); + TabletSeatV2Interface *seat = waylandServer()->tabletManagerV2()->seat(waylandServer()->seat()); + auto tablet = seat->tabletByName(event->device()->sysName()); Window *window = input()->findToplevel(event->globalPosF()); if (!window || !window->surface()) { diff --git a/src/input_event.h b/src/input_event.h index f3278dcc51..be9f6d1de3 100644 --- a/src/input_event.h +++ b/src/input_event.h @@ -202,7 +202,6 @@ public: QList m_capabilities; quint64 m_serialId; quint64 m_uniqueId; - void *m_deviceGroupData; QString m_name; }; diff --git a/src/wayland/tablet_v2.cpp b/src/wayland/tablet_v2.cpp index cee6deb459..c10556cf8b 100644 --- a/src/wayland/tablet_v2.cpp +++ b/src/wayland/tablet_v2.cpp @@ -918,6 +918,12 @@ TabletToolV2Interface *TabletSeatV2Interface::toolByHardwareSerial(quint64 hardw return nullptr; } +TabletV2Interface *TabletSeatV2Interface::tabletByName(const QString &name) const +{ + Q_ASSERT(d->m_tablets.contains(name)); + return d->m_tablets.value(name); +} + TabletPadV2Interface *TabletSeatV2Interface::padByName(const QString &name) const { Q_ASSERT(d->m_pads.contains(name)); diff --git a/src/wayland/tablet_v2.h b/src/wayland/tablet_v2.h index 04491135a4..6e2ae20eaa 100644 --- a/src/wayland/tablet_v2.h +++ b/src/wayland/tablet_v2.h @@ -290,6 +290,7 @@ public: TabletToolV2Interface *toolByHardwareId(quint64 hardwareId) const; TabletToolV2Interface *toolByHardwareSerial(quint64 hardwareSerial, TabletToolV2Interface::Type type) const; + TabletV2Interface *tabletByName(const QString &sysname) const; TabletPadV2Interface *padByName(const QString &sysname) const; void removeDevice(const QString &sysname);