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`
master
Kai Uwe Broulik 2020-08-11 18:49:17 +02:00
parent 6f176660fb
commit 16f74986fb
2 changed files with 11 additions and 0 deletions

View File

@ -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;

View File

@ -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);