Commit 3332b321 authored by David Edmundson's avatar David Edmundson

[scripting] Fix effect.animate() curve argument being actually used

Summary:
One cannot use a non metatype frrom an external class inside an
invokable. https://bugreports.qt.io/browse/QTBUG-58454

End result is the script engine arguments wouldn't match up and MOC
would just use the default value.

As far as I can tell this has been broken for 6 years.
The global animate method that unboxes a QJSValue as an object is
unaffected.
No shipped kwin effect actually used it.

To some extent we didn't even actually want to enforce the enum as we
also accept custom value of ScriptedEffect::GuassianCurve, so it has
been switched for an int.

Test Plan: Unit test

Reviewers: #kwin, broulik

Reviewed By: broulik

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14669
parent 5336c9a1
......@@ -291,6 +291,7 @@ void ScriptedEffectsTest::testAnimations()
QCOMPARE(animationsForWindow[0].duration, 100);
QCOMPARE(animationsForWindow[0].to, FPx2(1.4));
QCOMPARE(animationsForWindow[0].attribute, AnimationEffect::Scale);
QCOMPARE(animationsForWindow[0].curve.type(), QEasingCurve::OutQuad);
QCOMPARE(animationsForWindow[0].keepAtTarget, false);
timePassed = animationsForWindow[0].time;
if (animationCount == 2) {
......
effects.windowAdded.connect(function(w) {
w.anim1 = effect.animate(w, Effect.Scale, 100, 1.4, 0.2);
w.anim1 = effect.animate(w, Effect.Scale, 100, 1.4, 0.2, 0, QEasingCurve.OutQuad);
sendTestResponse(typeof(w.anim1) == "number");
});
......
......@@ -4,11 +4,11 @@ effects.windowAdded.connect(function(w) {
duration: 100,
animations: [{
type: Effect.Scale,
curve: Effect.GaussianCurve,
to: 1.4
to: 1.4,
curve: QEasingCurve.OutQuad
}, {
type: Effect.Opacity,
curve: Effect.GaussianCurve,
curve: QEasingCurve.OutQuad,
to: 0.0
}]
});
......
......@@ -581,22 +581,22 @@ void ScriptedEffect::signalHandlerException(const QScriptValue &value)
}
}
quint64 ScriptedEffect::animate(KWin::EffectWindow* w, KWin::AnimationEffect::Attribute a, int ms, KWin::FPx2 to, KWin::FPx2 from, uint metaData, QEasingCurve::Type curve, int delay)
quint64 ScriptedEffect::animate(KWin::EffectWindow* w, KWin::AnimationEffect::Attribute a, int ms, KWin::FPx2 to, KWin::FPx2 from, uint metaData, int curve, int delay)
{
QEasingCurve qec;
if (curve < QEasingCurve::Custom)
qec.setType(curve);
else if (static_cast<int>(curve) == static_cast<int>(GaussianCurve))
qec.setType(static_cast<QEasingCurve::Type>(curve));
else if (curve == GaussianCurve)
qec.setCustomType(qecGaussian);
return AnimationEffect::animate(w, a, metaData, ms, to, qec, delay, from);
}
quint64 ScriptedEffect::set(KWin::EffectWindow* w, KWin::AnimationEffect::Attribute a, int ms, KWin::FPx2 to, KWin::FPx2 from, uint metaData, QEasingCurve::Type curve, int delay)
quint64 ScriptedEffect::set(KWin::EffectWindow* w, KWin::AnimationEffect::Attribute a, int ms, KWin::FPx2 to, KWin::FPx2 from, uint metaData, int curve, int delay)
{
QEasingCurve qec;
if (curve < QEasingCurve::Custom)
qec.setType(curve);
else if (static_cast<int>(curve) == static_cast<int>(GaussianCurve))
qec.setType(static_cast<QEasingCurve::Type>(curve));
else if (curve == GaussianCurve)
qec.setCustomType(qecGaussian);
return AnimationEffect::set(w, a, metaData, ms, to, qec, delay, from);
}
......
......@@ -95,8 +95,9 @@ public:
bool unregisterTouchScreenCallback(int edge);
public Q_SLOTS:
quint64 animate(KWin::EffectWindow *w, Attribute a, int ms, KWin::FPx2 to, KWin::FPx2 from = KWin::FPx2(), uint metaData = 0, QEasingCurve::Type curve = QEasingCurve::Linear, int delay = 0);
quint64 set(KWin::EffectWindow *w, Attribute a, int ms, KWin::FPx2 to, KWin::FPx2 from = KWin::FPx2(), uint metaData = 0, QEasingCurve::Type curve = QEasingCurve::Linear, int delay = 0);
//curve should be of type QEasingCurve::type or ScriptedEffect::EasingCurve
quint64 animate(KWin::EffectWindow *w, Attribute a, int ms, KWin::FPx2 to, KWin::FPx2 from = KWin::FPx2(), uint metaData = 0, int curve = QEasingCurve::Linear, int delay = 0);
quint64 set(KWin::EffectWindow *w, Attribute a, int ms, KWin::FPx2 to, KWin::FPx2 from = KWin::FPx2(), uint metaData = 0, int curve = QEasingCurve::Linear, int delay = 0);
bool retarget(quint64 animationId, KWin::FPx2 newTarget, int newRemainingTime = -1);
bool cancel(quint64 animationId) { return AnimationEffect::cancel(animationId); }
virtual bool borderActivated(ElectricBorder border);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment