diff --git a/input.cpp b/input.cpp --- a/input.cpp +++ b/input.cpp @@ -1520,6 +1520,46 @@ } }; +/** + * Useful when there's no proper tablet support on the clients + */ +class FakeTabletInputFilter : public InputEventFilter +{ +public: + FakeTabletInputFilter() + { + } + + bool tabletToolEvent(QTabletEvent *event) override + { + if (!workspace()) { + return false; + } + + switch (event->type()) { + case QEvent::TabletMove: + case QEvent::TabletEnterProximity: + input()->pointer()->processMotion(event->globalPosF(), event->timestamp()); + break; + case QEvent::TabletPress: + input()->pointer()->processButton(KWin::buttonCodeToQt().key(Qt::LeftButton), + InputRedirection::PointerButtonPressed, event->timestamp()); + break; + case QEvent::TabletRelease: + input()->pointer()->processButton(KWin::buttonCodeToQt().key(Qt::LeftButton), + InputRedirection::PointerButtonReleased, event->timestamp()); + break; + case QEvent::TabletLeaveProximity: + break; + default: + qCWarning(KWIN_CORE) << "Unexpected tablet event type" << event; + break; + } + waylandServer()->simulateUserActivity(); + return true; + } +}; + class DragAndDropInputFilter : public InputEventFilter { public: @@ -1881,6 +1921,7 @@ if (waylandServer()) { installInputEventFilter(new WindowActionInputFilter); installInputEventFilter(new ForwardInputFilter); + installInputEventFilter(new FakeTabletInputFilter); } } diff --git a/pointer_input.h b/pointer_input.h --- a/pointer_input.h +++ b/pointer_input.h @@ -57,6 +57,8 @@ class Device; } +const QHash &buttonCodeToQt(); + class KWIN_EXPORT PointerInputRedirection : public InputDeviceHandler { Q_OBJECT diff --git a/pointer_input.cpp b/pointer_input.cpp --- a/pointer_input.cpp +++ b/pointer_input.cpp @@ -91,6 +91,10 @@ // buttons are pressed is correct and that's all we care about. return s_buttonToQtMouseButton.value(button, Qt::ExtraButton24); } + +const QHash &buttonCodeToQt() +{ + return s_buttonToQtMouseButton; } static bool screenContainsPos(const QPointF &pos)