Don't store TabletV2Interface in libinput device group user data

Device group user data is a libinput specific concept, and it's not
portable to other platforms/backends, which we need to support in long
term for proper testing of tablet stuff in CI, etc.

Note that tablet input still heavily pokes libinput specific things,
this is going to be addressed later.
wilder/Plasma/6.3
Vlad Zahorodnii 1 year ago
parent d31b9033f3
commit 4a01350f7e
  1. 6
      src/input.cpp
  2. 32
      src/tablet_input.cpp
  3. 2
      src/tablet_input.h

@ -2151,11 +2151,7 @@ public:
// NOTE: tablet may be nullptr when the device is removed (see ::removeDevice) but events from the tool
// may still happen.
TabletV2Interface *tablet = nullptr;
if (auto libinputDevice = qobject_cast<LibInput::Device *>(device)) {
auto deviceGroup = libinput_device_get_device_group(libinputDevice->device());
tablet = static_cast<TabletV2Interface *>(libinput_device_group_get_user_data(deviceGroup));
}
TabletV2Interface *tablet = input()->tablet()->tabletForPad(device);
if (!tablet) {
return nullptr;
}

@ -134,10 +134,7 @@ void TabletInputRedirection::integrateDevice(InputDevice *inputDevice)
struct udev_device *const udev_device = libinput_device_get_udev_device(device->device());
const char *devnode = udev_device_get_syspath(udev_device);
TabletV2Interface *tablet = tabletSeat->addTablet(device->vendor(), device->product(), device->sysName(), device->name(), {QString::fromUtf8(devnode)});
auto deviceGroup = libinput_device_get_device_group(device->device());
libinput_device_group_set_user_data(deviceGroup, tablet);
tabletSeat->addTablet(device->vendor(), device->product(), device->sysName(), device->name(), {QString::fromUtf8(devnode)});
}
if (device->isTabletPad()) {
@ -157,11 +154,6 @@ void TabletInputRedirection::removeDevice(InputDevice *inputDevice)
{
auto device = qobject_cast<LibInput::Device *>(inputDevice);
if (device) {
if (inputDevice->isTabletTool()) {
auto deviceGroup = libinput_device_get_device_group(device->device());
libinput_device_group_set_user_data(deviceGroup, nullptr);
}
TabletSeatV2Interface *tabletSeat = findTabletSeat();
if (tabletSeat) {
tabletSeat->removeDevice(device->sysName());
@ -268,6 +260,28 @@ TabletToolV2Interface *TabletInputRedirection::ensureTabletTool(const TabletTool
return tool;
}
TabletV2Interface *TabletInputRedirection::tabletForPad(InputDevice *device) const
{
auto pad = qobject_cast<LibInput::Device *>(device);
if (!pad) {
return nullptr;
}
const auto candidates = input()->devices();
for (InputDevice *candidate : candidates) {
if (!candidate->isTabletTool()) {
continue;
}
if (auto libinputDevice = qobject_cast<LibInput::Device *>(candidate)) {
if (libinput_device_get_device_group(pad->device()) == libinput_device_get_device_group(libinputDevice->device())) {
return findTabletSeat()->tabletByName(libinputDevice->sysName());
}
}
}
return nullptr;
}
void TabletInputRedirection::tabletToolEvent(KWin::InputRedirection::TabletEventType type, const QPointF &pos,
qreal pressure, int xTilt, int yTilt, qreal rotation, bool tipDown,
bool tipNear, const TabletToolId &toolId,

@ -21,6 +21,7 @@ class Cursor;
class Window;
class TabletToolId;
class TabletToolV2Interface;
class TabletV2Interface;
namespace Decoration
{
@ -64,6 +65,7 @@ public:
}
TabletToolV2Interface *ensureTabletTool(const TabletToolId &id);
TabletV2Interface *tabletForPad(InputDevice *device) const;
private:
void cleanupDecoration(Decoration::DecoratedClientImpl *old,

Loading…
Cancel
Save