diff --git a/src/plugins/buttonrebinds/buttonrebindsfilter.cpp b/src/plugins/buttonrebinds/buttonrebindsfilter.cpp index 1f977f32b8..393fb8e9b9 100644 --- a/src/plugins/buttonrebinds/buttonrebindsfilter.cpp +++ b/src/plugins/buttonrebinds/buttonrebindsfilter.cpp @@ -7,6 +7,7 @@ #include "buttonrebindsfilter.h" #include "buttonrebinds_debug.h" +#include "cursor.h" #include "input_event.h" #include "keyboard_input.h" #include "xkb.h" @@ -151,6 +152,22 @@ void ButtonRebindsFilter::loadConfig(const KConfigGroup &group) } } + const auto tabletToolsGroup = group.group("TabletTool"); + const auto tabletTools = tabletToolsGroup.groupList(); + for (const auto &tabletToolName : tabletTools) { + const auto toolGroup = tabletToolsGroup.group(tabletToolName); + const auto tabletToolButtons = toolGroup.keyList(); + for (const auto &buttonName : tabletToolButtons) { + const auto entry = toolGroup.readEntry(buttonName, QStringList()); + bool ok; + const uint button = buttonName.toUInt(&ok); + if (ok) { + foundActions = true; + insert(TabletTool, {tabletToolName, button}, entry); + } + } + } + if (foundActions) { KWin::input()->prependInputEventFilter(this); } @@ -170,6 +187,12 @@ bool ButtonRebindsFilter::tabletPadButtonEvent(uint button, bool pressed, const return send(TabletPad, {tabletPadId.name, button}, pressed, time); } +bool ButtonRebindsFilter::tabletToolButtonEvent(uint button, bool pressed, const KWin::TabletToolId &tabletToolId, uint time) +{ + Q_UNUSED(tabletToolId); + return send(TabletTool, {{}, button}, pressed, time); +} + void ButtonRebindsFilter::insert(TriggerType type, const Trigger &trigger, const QStringList &entry) { if (entry.size() != 2) { diff --git a/src/plugins/buttonrebinds/buttonrebindsfilter.h b/src/plugins/buttonrebinds/buttonrebindsfilter.h index dfc335ec08..05f985d656 100644 --- a/src/plugins/buttonrebinds/buttonrebindsfilter.h +++ b/src/plugins/buttonrebinds/buttonrebindsfilter.h @@ -53,6 +53,7 @@ public: enum TriggerType { Pointer, TabletPad, + TabletTool, LastType }; Q_ENUM(TriggerType); @@ -60,6 +61,7 @@ public: explicit ButtonRebindsFilter(); bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override; bool tabletPadButtonEvent(uint button, bool pressed, const KWin::TabletPadId &tabletPadId, uint time) override; + bool tabletToolButtonEvent(uint button, bool pressed, const KWin::TabletToolId &tabletToolId, uint time) override; private: void loadConfig(const KConfigGroup &group);