diff --git a/src/effects.cpp b/src/effects.cpp index 8db9b2052d..143dac77c3 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -25,6 +25,7 @@ #include "pointer_input.h" #include "renderbackend.h" #include "unmanaged.h" +#include "input_event.h" #ifdef KWIN_BUILD_TABBOX #include "tabbox.h" #endif @@ -735,6 +736,62 @@ bool EffectsHandlerImpl::touchUp(qint32 id, quint32 time) return false; } +bool EffectsHandlerImpl::tabletToolEvent(TabletEvent *event) +{ + // TODO: reverse call order? + for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) { + if (it->second->tabletToolEvent(event)) { + return true; + } + } + return false; +} + +bool EffectsHandlerImpl::tabletToolButtonEvent(uint button, bool pressed, const TabletToolId &tabletToolId) +{ + // TODO: reverse call order? + for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) { + if (it->second->tabletToolButtonEvent(button, pressed, tabletToolId.m_uniqueId)) { + return true; + } + } + return false; +} + +bool EffectsHandlerImpl::tabletPadButtonEvent(uint button, bool pressed, const TabletPadId &tabletPadId) +{ + // TODO: reverse call order? + for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) { + if (it->second->tabletPadButtonEvent(button, pressed, tabletPadId.data)) { + return true; + } + } + return false; +} + +bool EffectsHandlerImpl::tabletPadStripEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId) +{ + // TODO: reverse call order? + for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) { + if (it->second->tabletPadStripEvent(number, position, isFinger, tabletPadId.data)) { + return true; + } + } + return false; +} + +bool EffectsHandlerImpl::tabletPadRingEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId) +{ + // TODO: reverse call order? + for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) { + if (it->second->tabletPadRingEvent(number, position, isFinger, tabletPadId.data)) { + return true; + } + } + return false; +} + + void EffectsHandlerImpl::registerGlobalShortcut(const QKeySequence &shortcut, QAction *action) { input()->registerShortcut(shortcut, action); diff --git a/src/effects.h b/src/effects.h index 9dfa35f4d2..2a9445dcef 100644 --- a/src/effects.h +++ b/src/effects.h @@ -46,6 +46,9 @@ class Group; class Toplevel; class Unmanaged; class WindowPropertyNotifyX11Filter; +class TabletEvent; +class TabletPadId; +class TabletToolId; class KWIN_EXPORT EffectsHandlerImpl : public EffectsHandler { @@ -239,6 +242,12 @@ public: bool touchMotion(qint32 id, const QPointF &pos, quint32 time); bool touchUp(qint32 id, quint32 time); + bool tabletToolEvent(KWin::TabletEvent *event); + bool tabletToolButtonEvent(uint button, bool pressed, const KWin::TabletToolId &tabletToolId); + bool tabletPadButtonEvent(uint button, bool pressed, const KWin::TabletPadId &tabletPadId); + bool tabletPadStripEvent(int number, int position, bool isFinger, const KWin::TabletPadId &tabletPadId); + bool tabletPadRingEvent(int number, int position, bool isFinger, const KWin::TabletPadId &tabletPadId); + void highlightWindows(const QVector &windows); bool isPropertyTypeRegistered(xcb_atom_t atom) const { diff --git a/src/input.cpp b/src/input.cpp index 1426cd9675..bdba5f0700 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -561,6 +561,36 @@ public: } return static_cast< EffectsHandlerImpl* >(effects)->touchUp(id, time); } + bool tabletToolEvent(TabletEvent *event) override { + if (!effects) { + return false; + } + return static_cast< EffectsHandlerImpl* >(effects)->tabletToolEvent(event); + } + bool tabletToolButtonEvent(uint button, bool pressed, const TabletToolId &tabletToolId) override { + if (!effects) { + return false; + } + return static_cast< EffectsHandlerImpl* >(effects)->tabletToolButtonEvent(button, pressed, tabletToolId); + } + bool tabletPadButtonEvent(uint button, bool pressed, const TabletPadId &tabletPadId) override { + if (!effects) { + return false; + } + return static_cast< EffectsHandlerImpl* >(effects)->tabletPadButtonEvent(button, pressed, tabletPadId); + } + bool tabletPadStripEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId) override { + if (!effects) { + return false; + } + return static_cast< EffectsHandlerImpl* >(effects)->tabletPadStripEvent(number, position, isFinger, tabletPadId); + } + bool tabletPadRingEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId) override { + if (!effects) { + return false; + } + return static_cast< EffectsHandlerImpl* >(effects)->tabletPadRingEvent(number, position, isFinger, tabletPadId); + } }; class MoveResizeFilter : public InputEventFilter { diff --git a/src/libkwineffects/kwineffects.cpp b/src/libkwineffects/kwineffects.cpp index ccb5037439..88401d5222 100644 --- a/src/libkwineffects/kwineffects.cpp +++ b/src/libkwineffects/kwineffects.cpp @@ -684,6 +684,46 @@ bool Effect::perform(Feature feature, const QVariantList &arguments) return false; } +bool Effect::tabletToolEvent(QTabletEvent *event) +{ + Q_UNUSED(event) + return false; +} + +bool Effect::tabletToolButtonEvent(uint button, bool pressed, quint64 tabletToolId) +{ + Q_UNUSED(button) + Q_UNUSED(pressed) + Q_UNUSED(tabletToolId) + return false; +} + +bool Effect::tabletPadButtonEvent(uint button, bool pressed, void *tabletPadId) +{ + Q_UNUSED(button) + Q_UNUSED(pressed) + Q_UNUSED(tabletPadId) + return false; +} + +bool Effect::tabletPadStripEvent(int number, int position, bool isFinger, void *tabletPadId) +{ + Q_UNUSED(number) + Q_UNUSED(position) + Q_UNUSED(isFinger) + Q_UNUSED(tabletPadId) + return false; +} + +bool Effect::tabletPadRingEvent(int number, int position, bool isFinger, void *tabletPadId) +{ + Q_UNUSED(number) + Q_UNUSED(position) + Q_UNUSED(isFinger) + Q_UNUSED(tabletPadId) + return false; +} + bool Effect::blocksDirectScanout() const { return true; diff --git a/src/libkwineffects/kwineffects.h b/src/libkwineffects/kwineffects.h index 3e34fa8b02..8076a07088 100644 --- a/src/libkwineffects/kwineffects.h +++ b/src/libkwineffects/kwineffects.h @@ -46,6 +46,7 @@ class QFont; class QKeyEvent; class QMatrix4x4; class QAction; +class QTabletEvent; /** * Logging category to be used inside the KWin effects. @@ -603,6 +604,64 @@ public: */ virtual bool touchUp(qint32 id, quint32 time); + /** + * There has been an event from a drawing tablet tool + * + * i.e. a pen and the likes. + * + * @param event the event information + * @see QTabletEvent + * + * @since 5.25 + */ + virtual bool tabletToolEvent(QTabletEvent *event); + + /** + * There has been an event from a button on a drawing tablet tool + * + * @param button which button + * @param pressed true if pressed, false when released + * @param tabletToolId the identifier of the tool id + * + * @since 5.25 + */ + virtual bool tabletToolButtonEvent(uint button, bool pressed, quint64 tabletToolId); + + /** + * There has been an event from a button on a drawing tablet pad + * + * @param button which button + * @param pressed true if pressed, false when released + * @param tabletPadId the identifier of the tool id + * + * @since 5.25 + */ + virtual bool tabletPadButtonEvent(uint button, bool pressed, void *tabletPadId); + + /** + * There has been an event from a input strip on a drawing tablet pad + * + * @param number which strip + * @param position the value within the strip that was selected + * @param isFinger if it was activated with a finger + * @param tabletPadId the identifier of the tool id + * + * @since 5.25 + */ + virtual bool tabletPadStripEvent(int number, int position, bool isFinger, void *tabletPadId); + + /** + * There has been an event from a input ring on a drawing tablet pad + * + * @param number which ring + * @param position the value within the ring that was selected + * @param isFinger if it was activated with a finger + * @param tabletPadId the identifier of the tool id + * + * @since 5.25 + */ + virtual bool tabletPadRingEvent(int number, int position, bool isFinger, void *tabletPadId); + static QPoint cursorPos(); /**