KWin
Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Properties | List of all members
KWin::ScriptedEffect Class Reference

#include <scriptedeffect.h>

Inheritance diagram for KWin::ScriptedEffect:
KWin::AnimationEffect KWin::CrossFadeEffect KWin::Effect ScriptedEffectWithDebugSpy

Public Types

enum  DataRole {
  WindowAddedGrabRole = 1 , WindowClosedGrabRole , WindowMinimizedGrabRole , WindowUnminimizedGrabRole ,
  WindowForceBlurRole , WindowBlurBehindRole , WindowForceBackgroundContrastRole , WindowBackgroundContrastRole
}
 
enum  EasingCurve { GaussianCurve = 128 }
 
enum class  ShaderTrait { MapTexture = (1 << 0) , UniformColor = (1 << 1) , Modulate = (1 << 2) , AdjustSaturation = (1 << 3) }
 
- Public Types inherited from KWin::AnimationEffect
enum  Anchor {
  Left = 1 << 0 , Top = 1 << 1 , Right = 1 << 2 , Bottom = 1 << 3 ,
  Horizontal = Left | Right , Vertical = Top | Bottom , Mouse = 1 << 4
}
 
enum  Attribute {
  Opacity = 0 , Brightness , Saturation , Scale ,
  Rotation , Position , Size , Translation ,
  Clip , Generic , CrossFadePrevious , Shader ,
  ShaderUniform , NonFloatBase = Position
}
 
enum  MetaType {
  SourceAnchor , TargetAnchor , RelativeSourceX , RelativeSourceY ,
  RelativeTargetX , RelativeTargetY , Axis
}
 
enum  Direction { Forward , Backward }
 
enum  TerminationFlag { DontTerminate = 0x00 , TerminateAtSource = 0x01 , TerminateAtTarget = 0x02 }
 
- Public Types inherited from KWin::Effect
enum  {
  PAINT_WINDOW_OPAQUE = 1 << 0 , PAINT_WINDOW_TRANSLUCENT = 1 << 1 , PAINT_WINDOW_TRANSFORMED = 1 << 2 , PAINT_SCREEN_REGION = 1 << 3 ,
  PAINT_SCREEN_TRANSFORMED = 1 << 4 , PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS = 1 << 5 , PAINT_SCREEN_BACKGROUND_FIRST = 1 << 6
}
 
enum  Feature {
  Nothing = 0 , ScreenInversion , Blur , Contrast ,
  HighlightWindows
}
 
enum  ReconfigureFlag { ReconfigureAll = 1 << 0 }
 

Public Slots

bool borderActivated (ElectricBorder border) override
 
- Public Slots inherited from KWin::Effect
virtual bool borderActivated (ElectricBorder border)
 

Signals

void configChanged ()
 
void animationEnded (KWin::EffectWindow *w, quint64 animationId)
 
void isActiveFullScreenEffectChanged ()
 

Public Member Functions

const QString & scriptFile () const
 
void reconfigure (ReconfigureFlags flags) override
 
int requestedEffectChainPosition () const override
 
QString activeConfig () const
 
void setActiveConfig (const QString &name)
 
 ~ScriptedEffect () override
 
Q_SCRIPTABLE bool isGrabbed (KWin::EffectWindow *w, DataRole grabRole)
 
Q_SCRIPTABLE bool grab (KWin::EffectWindow *w, DataRole grabRole, bool force=false)
 
Q_SCRIPTABLE bool ungrab (KWin::EffectWindow *w, DataRole grabRole)
 
Q_SCRIPTABLE QJSValue readConfig (const QString &key, const QJSValue &defaultValue=QJSValue())
 
Q_SCRIPTABLE int displayWidth () const
 
Q_SCRIPTABLE int displayHeight () const
 
Q_SCRIPTABLE int animationTime (int defaultTime) const
 
Q_SCRIPTABLE void registerShortcut (const QString &objectName, const QString &text, const QString &keySequence, const QJSValue &callback)
 
Q_SCRIPTABLE bool registerScreenEdge (int edge, const QJSValue &callback)
 
Q_SCRIPTABLE bool registerRealtimeScreenEdge (int edge, const QJSValue &callback)
 
Q_SCRIPTABLE bool unregisterScreenEdge (int edge)
 
Q_SCRIPTABLE bool registerTouchScreenEdge (int edge, const QJSValue &callback)
 
Q_SCRIPTABLE bool unregisterTouchScreenEdge (int edge)
 
Q_SCRIPTABLE quint64 animate (KWin::EffectWindow *window, Attribute attribute, int ms, const QJSValue &to, const QJSValue &from=QJSValue(), uint metaData=0, int curve=QEasingCurve::Linear, int delay=0, bool fullScreen=false, bool keepAlive=true, uint shaderId=0)
 
Q_SCRIPTABLE QJSValue animate (const QJSValue &object)
 
Q_SCRIPTABLE quint64 set (KWin::EffectWindow *window, Attribute attribute, int ms, const QJSValue &to, const QJSValue &from=QJSValue(), uint metaData=0, int curve=QEasingCurve::Linear, int delay=0, bool fullScreen=false, bool keepAlive=true, uint shaderId=0)
 
Q_SCRIPTABLE QJSValue set (const QJSValue &object)
 
Q_SCRIPTABLE bool retarget (quint64 animationId, const QJSValue &newTarget, int newRemainingTime=-1)
 
Q_SCRIPTABLE bool retarget (const QList< quint64 > &animationIds, const QJSValue &newTarget, int newRemainingTime=-1)
 
Q_SCRIPTABLE bool freezeInTime (quint64 animationId, qint64 frozenTime)
 
Q_SCRIPTABLE bool freezeInTime (const QList< quint64 > &animationIds, qint64 frozenTime)
 
Q_SCRIPTABLE bool redirect (quint64 animationId, Direction direction, TerminationFlags terminationFlags=TerminateAtSource)
 
Q_SCRIPTABLE bool redirect (const QList< quint64 > &animationIds, Direction direction, TerminationFlags terminationFlags=TerminateAtSource)
 
Q_SCRIPTABLE bool complete (quint64 animationId)
 
Q_SCRIPTABLE bool complete (const QList< quint64 > &animationIds)
 
Q_SCRIPTABLE bool cancel (quint64 animationId)
 
Q_SCRIPTABLE bool cancel (const QList< quint64 > &animationIds)
 
Q_SCRIPTABLE QList< int > touchEdgesForAction (const QString &action) const
 
Q_SCRIPTABLE uint addFragmentShader (ShaderTrait traits, const QString &fragmentShaderFile={})
 
Q_SCRIPTABLE void setUniform (uint shaderId, const QString &name, const QJSValue &value)
 
QHash< int, QJSValueList > & screenEdgeCallbacks ()
 
QHash< int, QJSValueList > & realtimeScreenEdgeCallbacks ()
 
QString pluginId () const
 
bool isActiveFullScreenEffect () const
 
- Public Member Functions inherited from KWin::AnimationEffect
 AnimationEffect ()
 
 ~AnimationEffect () override
 
bool isActive () const override
 
QString debug (const QString &parameter) const override
 
void prePaintWindow (EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override
 
void paintWindow (const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override
 
void postPaintScreen () override
 
- Public Member Functions inherited from KWin::CrossFadeEffect
 CrossFadeEffect (QObject *parent=nullptr)
 
 ~CrossFadeEffect () override
 
void drawWindow (const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *window, int mask, const QRegion &region, WindowPaintData &data) override
 
void redirect (EffectWindow *window)
 
void unredirect (EffectWindow *window)
 
void setShader (EffectWindow *window, GLShader *shader)
 
- Public Member Functions inherited from KWin::Effect
 Effect (QObject *parent=nullptr)
 
 ~Effect () override
 
virtual void prePaintScreen (ScreenPrePaintData &data, std::chrono::milliseconds presentTime)
 
virtual void paintScreen (const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen)
 
virtual void postPaintWindow (EffectWindow *w)
 
virtual bool provides (Feature)
 
virtual bool perform (Feature feature, const QVariantList &arguments)
 
virtual void windowInputMouseEvent (QEvent *e)
 
virtual void grabbedKeyboardEvent (QKeyEvent *e)
 
virtual bool touchDown (qint32 id, const QPointF &pos, std::chrono::microseconds time)
 
virtual bool touchMotion (qint32 id, const QPointF &pos, std::chrono::microseconds time)
 
virtual bool touchUp (qint32 id, std::chrono::microseconds time)
 
virtual bool tabletToolEvent (QTabletEvent *event)
 
virtual bool tabletToolButtonEvent (uint button, bool pressed, quint64 tabletToolId)
 
virtual bool tabletPadButtonEvent (uint button, bool pressed, void *tabletPadId)
 
virtual bool tabletPadStripEvent (int number, int position, bool isFinger, void *tabletPadId)
 
virtual bool tabletPadRingEvent (int number, int position, bool isFinger, void *tabletPadId)
 
template<typename T >
int animationTime (int defaultDuration)
 
virtual bool blocksDirectScanout () const
 

Static Public Member Functions

static ScriptedEffectcreate (const QString &effectName, const QString &pathToScript, int chainPosition, const QString &exclusiveCategory)
 
static ScriptedEffectcreate (const KPluginMetaData &effect)
 
static bool supported ()
 
- Static Public Member Functions inherited from KWin::AnimationEffect
static int metaData (MetaType type, uint meta)
 
static void setMetaData (MetaType type, uint value, uint &meta)
 
static qreal qecGaussian (qreal progress)
 
static qint64 clock ()
 
- Static Public Member Functions inherited from KWin::CrossFadeEffect
static bool supported ()
 
- Static Public Member Functions inherited from KWin::Effect
static QPointF cursorPos ()
 
static double animationTime (const KConfigGroup &cfg, const QString &key, int defaultTime)
 
static double animationTime (int defaultTime)
 
static double interpolate (double x, double y, double a)
 
static void setPositionTransformations (WindowPaintData &data, QRect &region, EffectWindow *w, const QRect &r, Qt::AspectRatioMode aspect)
 

Protected Member Functions

 ScriptedEffect ()
 
QJSEngine * engine () const
 
bool init (const QString &effectName, const QString &pathToScript)
 
void animationEnded (KWin::EffectWindow *w, Attribute a, uint meta) override
 
- Protected Member Functions inherited from KWin::AnimationEffect
quint64 animate (EffectWindow *w, Attribute a, uint meta, int ms, const FPx2 &to, const QEasingCurve &curve=QEasingCurve(), int delay=0, const FPx2 &from=FPx2(), bool fullScreen=false, bool keepAlive=true, GLShader *shader=nullptr)
 
quint64 set (EffectWindow *w, Attribute a, uint meta, int ms, const FPx2 &to, const QEasingCurve &curve=QEasingCurve(), int delay=0, const FPx2 &from=FPx2(), bool fullScreen=false, bool keepAlive=true, GLShader *shader=nullptr)
 
bool retarget (quint64 animationId, FPx2 newTarget, int newRemainingTime=-1)
 
bool freezeInTime (quint64 animationId, qint64 frozenTime)
 
bool redirect (quint64 animationId, Direction direction, TerminationFlags terminationFlags=TerminateAtSource)
 
bool complete (quint64 animationId)
 
bool cancel (quint64 animationId)
 
virtual void genericAnimation (EffectWindow *w, WindowPaintData &data, float progress, uint meta)
 
AniMap state () const
 

Properties

QString pluginId
 
bool isActiveFullScreenEffect
 

Additional Inherited Members

- Protected Types inherited from KWin::AnimationEffect
typedef QMap< EffectWindow *, QPair< QList< AniData >, QRect > > AniMap
 

Detailed Description

Definition at line 26 of file scriptedeffect.h.

Member Enumeration Documentation

◆ DataRole

Enumerator
WindowAddedGrabRole 
WindowClosedGrabRole 
WindowMinimizedGrabRole 
WindowUnminimizedGrabRole 
WindowForceBlurRole 

For fullscreen effects to enforce blurring of windows,.

WindowBlurBehindRole 

For single windows to blur behind.

WindowForceBackgroundContrastRole 

For fullscreen effects to enforce the background contrast,.

WindowBackgroundContrastRole 

For single windows to enable Background contrast.

Definition at line 49 of file scriptedeffect.h.

◆ EasingCurve

Enumerator
GaussianCurve 

Definition at line 61 of file scriptedeffect.h.

◆ ShaderTrait

Enumerator
MapTexture 
UniformColor 
Modulate 
AdjustSaturation 

Definition at line 65 of file scriptedeffect.h.

Constructor & Destructor Documentation

◆ ~ScriptedEffect()

KWin::ScriptedEffect::~ScriptedEffect ( )
overridedefault

◆ ScriptedEffect()

KWin::ScriptedEffect::ScriptedEffect ( )
protected

Definition at line 189 of file scriptedeffect.cpp.

Member Function Documentation

◆ activeConfig()

QString KWin::ScriptedEffect::activeConfig ( ) const

◆ addFragmentShader()

uint KWin::ScriptedEffect::addFragmentShader ( ShaderTrait traits,
const QString & fragmentShaderFile = {} )

Definition at line 789 of file scriptedeffect.cpp.

◆ animate() [1/2]

QJSValue KWin::ScriptedEffect::animate ( const QJSValue & object)

Definition at line 497 of file scriptedeffect.cpp.

◆ animate() [2/2]

quint64 KWin::ScriptedEffect::animate ( KWin::EffectWindow * window,
Attribute attribute,
int ms,
const QJSValue & to,
const QJSValue & from = QJSValue(),
uint metaData = 0,
int curve = QEasingCurve::Linear,
int delay = 0,
bool fullScreen = false,
bool keepAlive = true,
uint shaderId = 0 )

Definition at line 483 of file scriptedeffect.cpp.

◆ animationEnded() [1/2]

void KWin::ScriptedEffect::animationEnded ( KWin::EffectWindow * w,
Attribute a,
uint meta )
overrideprotectedvirtual

Called whenever an animation ends.

You can reimplement this method to keep a constant transformation for the window (i.e. keep it at some opacity or position) or to start another animation.

Parameters
wThe animated window.
aThe animated attribute.
metaOriginally supplied metadata to animate() or set().
Since
4.8

Reimplemented from KWin::AnimationEffect.

Definition at line 293 of file scriptedeffect.cpp.

◆ animationEnded [2/2]

void KWin::ScriptedEffect::animationEnded ( KWin::EffectWindow * w,
quint64 animationId )
signal

◆ animationTime()

int KWin::ScriptedEffect::animationTime ( int defaultTime) const

Definition at line 684 of file scriptedeffect.cpp.

◆ borderActivated

bool KWin::ScriptedEffect::borderActivated ( ElectricBorder border)
overrideslot

Definition at line 655 of file scriptedeffect.cpp.

◆ cancel() [1/2]

bool KWin::ScriptedEffect::cancel ( const QList< quint64 > & animationIds)

Definition at line 574 of file scriptedeffect.cpp.

◆ cancel() [2/2]

bool KWin::ScriptedEffect::cancel ( quint64 animationId)

Definition at line 569 of file scriptedeffect.cpp.

◆ complete() [1/2]

bool KWin::ScriptedEffect::complete ( const QList< quint64 > & animationIds)

Definition at line 562 of file scriptedeffect.cpp.

◆ complete() [2/2]

bool KWin::ScriptedEffect::complete ( quint64 animationId)

Definition at line 557 of file scriptedeffect.cpp.

◆ configChanged

void KWin::ScriptedEffect::configChanged ( )
signal

Signal emitted whenever the effect's config changed.

◆ create() [1/2]

ScriptedEffect * KWin::ScriptedEffect::create ( const KPluginMetaData & effect)
static

Definition at line 158 of file scriptedeffect.cpp.

◆ create() [2/2]

ScriptedEffect * KWin::ScriptedEffect::create ( const QString & effectName,
const QString & pathToScript,
int chainPosition,
const QString & exclusiveCategory )
static

Definition at line 171 of file scriptedeffect.cpp.

◆ displayHeight()

int KWin::ScriptedEffect::displayHeight ( ) const

Definition at line 679 of file scriptedeffect.cpp.

◆ displayWidth()

int KWin::ScriptedEffect::displayWidth ( ) const

Definition at line 674 of file scriptedeffect.cpp.

◆ engine()

QJSEngine * KWin::ScriptedEffect::engine ( ) const
protected

Definition at line 784 of file scriptedeffect.cpp.

◆ freezeInTime() [1/2]

bool KWin::ScriptedEffect::freezeInTime ( const QList< quint64 > & animationIds,
qint64 frozenTime )

Definition at line 538 of file scriptedeffect.cpp.

◆ freezeInTime() [2/2]

bool KWin::ScriptedEffect::freezeInTime ( quint64 animationId,
qint64 frozenTime )

Definition at line 533 of file scriptedeffect.cpp.

◆ grab()

bool KWin::ScriptedEffect::grab ( KWin::EffectWindow * w,
DataRole grabRole,
bool force = false )

Grabs the window with the specified role.

Parameters
wThe window.
grabRoleThe grab role.
forceBy default, if the window is already grabbed by another effect, then that window won't be grabbed by effect that called this method. If you would like to grab a window even if it's grabbed by another effect, then pass true.
Returns
true if the window was grabbed successfully, otherwise false.

Definition at line 593 of file scriptedeffect.cpp.

◆ init()

bool KWin::ScriptedEffect::init ( const QString & effectName,
const QString & pathToScript )
protected

Definition at line 211 of file scriptedeffect.cpp.

◆ isActiveFullScreenEffect()

bool KWin::ScriptedEffect::isActiveFullScreenEffect ( ) const

Definition at line 304 of file scriptedeffect.cpp.

◆ isActiveFullScreenEffectChanged

void KWin::ScriptedEffect::isActiveFullScreenEffectChanged ( )
signal

◆ isGrabbed()

bool KWin::ScriptedEffect::isGrabbed ( KWin::EffectWindow * w,
ScriptedEffect::DataRole grabRole )

Whether another effect has grabbed the w with the given grabRole.

Parameters
wThe window to check
grabRoleThe grab role to check
Returns
true if another window has grabbed the effect, false otherwise

Definition at line 583 of file scriptedeffect.cpp.

◆ pluginId()

QString KWin::ScriptedEffect::pluginId ( ) const

Definition at line 299 of file scriptedeffect.cpp.

◆ readConfig()

QJSValue KWin::ScriptedEffect::readConfig ( const QString & key,
const QJSValue & defaultValue = QJSValue() )

Reads the value from the configuration data for the given key.

Parameters
keyThe key to search for
defaultValueThe value to return if the key is not found
Returns
The config value if present

Definition at line 666 of file scriptedeffect.cpp.

◆ realtimeScreenEdgeCallbacks()

QHash< int, QJSValueList > & KWin::ScriptedEffect::realtimeScreenEdgeCallbacks ( )
inline

Definition at line 178 of file scriptedeffect.h.

◆ reconfigure()

void KWin::ScriptedEffect::reconfigure ( ReconfigureFlags flags)
overridevirtual

Called when configuration changes (either the effect's or KWin's global).

In OpenGL based compositing, the frameworks ensures that the context is current when the Effect is reconfigured. If this method is called from within the Effect it is required to ensure that the context is current if the implementation does OpenGL calls.

Reimplemented from KWin::Effect.

Definition at line 627 of file scriptedeffect.cpp.

◆ redirect() [1/2]

bool KWin::ScriptedEffect::redirect ( const QList< quint64 > & animationIds,
Direction direction,
TerminationFlags terminationFlags = TerminateAtSource )

Definition at line 550 of file scriptedeffect.cpp.

◆ redirect() [2/2]

bool KWin::ScriptedEffect::redirect ( quint64 animationId,
Direction direction,
TerminationFlags terminationFlags = TerminateAtSource )

Definition at line 545 of file scriptedeffect.cpp.

◆ registerRealtimeScreenEdge()

bool KWin::ScriptedEffect::registerRealtimeScreenEdge ( int edge,
const QJSValue & callback )

Definition at line 706 of file scriptedeffect.cpp.

◆ registerScreenEdge()

bool KWin::ScriptedEffect::registerScreenEdge ( int edge,
const QJSValue & callback )

Definition at line 689 of file scriptedeffect.cpp.

◆ registerShortcut()

void KWin::ScriptedEffect::registerShortcut ( const QString & objectName,
const QString & text,
const QString & keySequence,
const QJSValue & callback )

Definition at line 636 of file scriptedeffect.cpp.

◆ registerTouchScreenEdge()

bool KWin::ScriptedEffect::registerTouchScreenEdge ( int edge,
const QJSValue & callback )

Definition at line 755 of file scriptedeffect.cpp.

◆ requestedEffectChainPosition()

int KWin::ScriptedEffect::requestedEffectChainPosition ( ) const
inlineoverridevirtual

Reimplement this method to indicate where in the Effect chain the Effect should be placed.

A low number indicates early chain position, thus before other Effects got called, a high number indicates a late position. The returned number should be in the interval [0, 100]. The default value is 0.

In KWin4 this information was provided in the Effect's desktop file as property X-KDE-Ordering. In the case of Scripted Effects this property is still used.

Since
5.0

Reimplemented from KWin::Effect.

Definition at line 77 of file scriptedeffect.h.

◆ retarget() [1/2]

bool KWin::ScriptedEffect::retarget ( const QList< quint64 > & animationIds,
const QJSValue & newTarget,
int newRemainingTime = -1 )

Definition at line 526 of file scriptedeffect.cpp.

◆ retarget() [2/2]

bool KWin::ScriptedEffect::retarget ( quint64 animationId,
const QJSValue & newTarget,
int newRemainingTime = -1 )

Definition at line 521 of file scriptedeffect.cpp.

◆ screenEdgeCallbacks()

QHash< int, QJSValueList > & KWin::ScriptedEffect::screenEdgeCallbacks ( )
inline

Definition at line 173 of file scriptedeffect.h.

◆ scriptFile()

const QString & KWin::ScriptedEffect::scriptFile ( ) const
inline

Definition at line 72 of file scriptedeffect.h.

◆ set() [1/2]

QJSValue KWin::ScriptedEffect::set ( const QJSValue & object)

Definition at line 516 of file scriptedeffect.cpp.

◆ set() [2/2]

quint64 KWin::ScriptedEffect::set ( KWin::EffectWindow * window,
Attribute attribute,
int ms,
const QJSValue & to,
const QJSValue & from = QJSValue(),
uint metaData = 0,
int curve = QEasingCurve::Linear,
int delay = 0,
bool fullScreen = false,
bool keepAlive = true,
uint shaderId = 0 )

Definition at line 502 of file scriptedeffect.cpp.

◆ setActiveConfig()

void KWin::ScriptedEffect::setActiveConfig ( const QString & name)

◆ setUniform()

void KWin::ScriptedEffect::setUniform ( uint shaderId,
const QString & name,
const QJSValue & value )

Definition at line 819 of file scriptedeffect.cpp.

◆ supported()

bool KWin::ScriptedEffect::supported ( )
static

Definition at line 184 of file scriptedeffect.cpp.

◆ touchEdgesForAction()

QList< int > KWin::ScriptedEffect::touchEdgesForAction ( const QString & action) const

Definition at line 309 of file scriptedeffect.cpp.

◆ ungrab()

bool KWin::ScriptedEffect::ungrab ( KWin::EffectWindow * w,
DataRole grabRole )

Ungrabs the window with the specified role.

Parameters
wThe window.
grabRoleThe grab role.
Returns
true if the window was ungrabbed successfully, otherwise false.

Definition at line 610 of file scriptedeffect.cpp.

◆ unregisterScreenEdge()

bool KWin::ScriptedEffect::unregisterScreenEdge ( int edge)

Definition at line 743 of file scriptedeffect.cpp.

◆ unregisterTouchScreenEdge()

bool KWin::ScriptedEffect::unregisterTouchScreenEdge ( int edge)

Definition at line 773 of file scriptedeffect.cpp.

Property Documentation

◆ isActiveFullScreenEffect

bool KWin::ScriptedEffect::isActiveFullScreenEffect
read

True if we are the active fullscreen effect

Definition at line 45 of file scriptedeffect.h.

◆ pluginId

QString KWin::ScriptedEffect::pluginId
read

The plugin ID of the effect

Definition at line 41 of file scriptedeffect.h.


The documentation for this class was generated from the following files: