Global
Methods and properties added to the global JavaScript object.
KWin::EffectsHandler
effects
Global property to the core wrapper of KWin Effects
KWin::ScriptedEffect
effect
Global property to the actual Effect
object
Effect
Provides access to enums defined in KWin::AnimationEffect and KWin::ScriptedEffect
object
KWin
Provides access to enums defined in KWin::WorkspaceWrapper
object
QEasingCurve
Provides access to enums defined in QEasingCurve
Q_SCRIPTABLE QList<quint64>
QList<quint64> KWin::ScriptedEffect::animate
(settings)
animate
Schedules one or many animations for one window. The animations are defined through the settings object providing
a more declarative way to specify the animations than the animate call on the effect object. The settings object
supports the following attributes:
<syntaxhighlight lang="javascript">
{
window: EffectWindow, /* the window to animate, required */
duration: int, /* duration in msec, required */
curve: QEasingCurve.Type, /* global easing curve, optional */
type: Effect.Attribute, /* for first animation, optional */
from: FPx2, /* for first animation, optional */
to: FPx2, /* for first animation, optional */
delay: int, /* for first animation, optional */
shader: int, /* for first animation, optional */
animations: [ /* additional animations, optional */
{
curve: QEasingCurve.Type, /* overrides global */
type: Effect.Attribute,
from: FPx2,
to: FPx2,
delay: int,
shader: int
}
]
}
</syntaxhighlight>
At least one animation or attribute setter (see below) needs to be specified either with the top-level properties or in the animations list.
Q_SCRIPTABLE QList<quint64>
QList<quint64> KWin::ScriptedEffect::set
(settings)
set
Like animate, just that the manipulation does not implicitly end with the animation. You have to explicitly cancel it.
Until then, the manipulated attribute will remain at animation target value.
Q_SCRIPTABLE bool
bool KWin::ScriptedEffect::cancel
(QList<quint64>)
cancel
Cancel one or more present animations caused and returned by KWin::ScriptedEffect::animate or KWin::ScriptedEffect::set.
For convenience you can pass a single quint64 as well.
Q_SCRIPTABLE void
void KWin::ScriptedEffect::print
(QVariant ... values)
print
Prints all provided values to kDebug and as a D-Bus signal
Q_SCRIPTABLE int
int KWin::ScriptedEffect::animationTime
(int duration)
animationTime
Adjusts the passed in duration to the global animation time facator.
Q_SCRIPTABLE int
int KWin::ScriptedEffect::displayWidth
()
displayWidth
Width of the complete display (all screens).
Q_SCRIPTABLE int
int KWin::ScriptedEffect::displayHeight
()
displayHeight
Height of the complete display (all screens).
Q_SCRIPTABLE bool
bool KWin::ScriptedEffect::registerScreenEdge
(ElectricBorder border, QScriptValue callback)
registerScreenEdge
Registers the callback for the screen edge. When the mouse gets pushed against the given edge the callback will be invoked.
Q_SCRIPTABLE bool
bool KWin::ScriptedEffect::registerShortcut
(QString title, QString text, QString keySequence, QScriptValue callback)
registerShortcut
Registers keySequence as a global shortcut. When the shortcut is invoked the callback will be called. Title and text are used to name the shortcut and make it available to the global shortcut configuration module.
Q_SCRIPTABLE uint
uint KWin::ScriptedEffect::addFragmentShader
(ShaderTrait traits, QString fragmentShaderFile)
addFragmentShader
Creates a shader and returns an identifier which can be used in animate or set. The shader sources must be provided in the shaders sub-directory of the contents package directory. The fragment shader needs to have the file extension frag. Each shader should be provided in a GLSL 1.10 and GLSL 1.40 variant. The 1.40 variant needs to have a suffix _core. E.g. there should be a shader myCustomShader.frag and myCustomShader_core.frag. The vertex shader is generated from the ShaderTrait. The ShaderTrait enum can be used as flags in this method.
Q_SCRIPTABLE uint
void KWin::ScriptedEffect::setUniform
(uint shaderId, QString name, QJSValue value)
setUniform
Updates the uniform value of the uniform identified by @p name for the shader identified by @p shaderId. The @p value can be a floating point numeric value (integer uniform values are not supported), an array with either 2, 3 or 4 numeric values, a string to identify a color or a variant value to identify a color as returned by readConfig. This method can be used to update the state of the shader when the configuration of the effect changed.
KWin::FPx2
This class is used to describe the animation end points, that is from which FPx2 values to which FPx2 values an animation goes. This class contains two properties to describe two animation components individually (e.g. width and height). But it's also possible to just have one value (e.g. opacity). In this case the definition of an FPx2 can be replaced by a single value.
qreal
value1
qreal
value2