windowManager: Move animation into WindowDimmer

Currently WindowDimmer exposes a JS property that is used to control the
underlying effect. This works fine with Tweener, but not with Clutter
animations which we want to use ultimately.

As a first step towards that, expose a setDimmed() method instead of
the property and handle the animation internally, so it can be adapted
more easily.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/666
This commit is contained in:
Florian Müllner 2018-07-22 03:31:54 +02:00
parent 0846238f69
commit fc958f4215

View File

@ -135,14 +135,25 @@ var WindowDimmer = class {
this._syncEnabled(); this._syncEnabled();
} }
set dimFactor(factor) { setDimmed(dimmed, animate) {
this._dimFactor = factor; let factor = dimmed ? 1.0 : 0.0;
this._brightnessEffect.set_brightness(factor * DIM_BRIGHTNESS);
this._syncEnabled();
}
get dimFactor() { if (animate) {
return this._dimFactor; Tweener.addTween(this, {
_dimFactor: factor,
time: (dimmed ? DIM_TIME : UNDIM_TIME) / 1000,
transition: 'linear',
onUpdate: () => {
let brightness = this._dimFactor * DIM_BRIGHTNESS;
this._brightnessEffect.set_brightness(brightness);
this._syncEnabled();
}
});
} else {
this._dimFactor = factor;
this._brightnessEffect.set_brightness(factor * DIM_BRIGHTNESS);
this._syncEnabled();
}
} }
}; };
@ -1582,14 +1593,7 @@ var WindowManager = class {
let dimmer = getWindowDimmer(actor); let dimmer = getWindowDimmer(actor);
if (!dimmer) if (!dimmer)
return; return;
if (this._shouldAnimate()) dimmer.setDimmed(true, this._shouldAnimate());
Tweener.addTween(dimmer,
{ dimFactor: 1.0,
time: DIM_TIME / 1000,
transition: 'linear'
});
else
dimmer.dimFactor = 1.0;
} }
_undimWindow(window) { _undimWindow(window) {
@ -1599,13 +1603,7 @@ var WindowManager = class {
let dimmer = getWindowDimmer(actor); let dimmer = getWindowDimmer(actor);
if (!dimmer) if (!dimmer)
return; return;
if (this._shouldAnimate()) dimmer.setDimmed(false, this._shouldAnimate());
Tweener.addTween(dimmer,
{ dimFactor: 0.0,
time: UNDIM_TIME / 1000,
transition: 'linear' });
else
dimmer.dimFactor = 0.0;
} }
_mapWindow(shellwm, actor) { _mapWindow(shellwm, actor) {