buttonrebinds: Allow configuring tablet tool rebinds
Makes it possible to assign an action to one of the tablet tool buttons.
This commit is contained in:
parent
d0da1cf751
commit
609065528e
2 changed files with 25 additions and 0 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue