From 16f74986fb51ee7d4accafa62b564071df986f2a Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Tue, 11 Aug 2020 18:49:17 +0200 Subject: [PATCH] Expose effect ID to scripting via `effect.pluginId` This can be used to avoid code duplication by installing an effect multiple times and tweaking behavior slightly based on the returned ID. Internally it is called `scriptName` but for consistency with other similar APIs the name `pluginId` is chosen, and returns e.g. `kwin4_effect_maximize` --- scripting/scriptedeffect.cpp | 5 +++++ scripting/scriptedeffect.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/scripting/scriptedeffect.cpp b/scripting/scriptedeffect.cpp index 2d71866a1..a63b3cf56 100644 --- a/scripting/scriptedeffect.cpp +++ b/scripting/scriptedeffect.cpp @@ -694,6 +694,11 @@ void ScriptedEffect::animationEnded(KWin::EffectWindow *w, Attribute a, uint met emit animationEnded(w, 0); } +QString ScriptedEffect::pluginId() const +{ + return m_effectName; +} + bool ScriptedEffect::isActiveFullScreenEffect() const { return effects->activeFullScreenEffect() == this; diff --git a/scripting/scriptedeffect.h b/scripting/scriptedeffect.h index 26a239395..d6cbb6504 100644 --- a/scripting/scriptedeffect.h +++ b/scripting/scriptedeffect.h @@ -28,6 +28,10 @@ class KWIN_EXPORT ScriptedEffect : public KWin::AnimationEffect Q_ENUMS(MetaType) Q_ENUMS(EasingCurve) Q_ENUMS(SessionState) + /** + * The plugin ID of the effect + */ + Q_PROPERTY(QString pluginId READ pluginId CONSTANT) /** * True if we are the active fullscreen effect */ @@ -108,6 +112,8 @@ public: return m_screenEdgeCallbacks; } + QString pluginId() const; + bool isActiveFullScreenEffect() const; bool registerTouchScreenCallback(int edge, QScriptValue callback);