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.
This commit is contained in:
Aleix Pol 2022-08-30 20:13:28 +02:00 committed by Aleix Pol Gonzalez
parent 6b4feccadd
commit 0744ee09ed
2 changed files with 16 additions and 3 deletions

View file

@ -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<TabletPadButtonEvent *>(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:

View file

@ -196,6 +196,7 @@ public:
class TabletPadId
{
public:
const QString name;
void *data;
};