[gnome-shell] windowManager: Move animation into WindowDimmer



commit fc958f4215255b4e396fca8bd2777a5ca4ffa173
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Jul 22 03:31:54 2018 +0200

    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

 js/ui/windowManager.js | 44 +++++++++++++++++++++-----------------------
 1 file changed, 21 insertions(+), 23 deletions(-)
---
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index d932c22fb..f7e4dc211 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -135,14 +135,25 @@ var WindowDimmer = class {
         this._syncEnabled();
     }
 
-    set dimFactor(factor) {
-        this._dimFactor = factor;
-        this._brightnessEffect.set_brightness(factor * DIM_BRIGHTNESS);
-        this._syncEnabled();
-    }
-
-    get dimFactor() {
-        return this._dimFactor;
+    setDimmed(dimmed, animate) {
+        let factor = dimmed ? 1.0 : 0.0;
+
+        if (animate) {
+            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);
         if (!dimmer)
             return;
-        if (this._shouldAnimate())
-            Tweener.addTween(dimmer,
-                             { dimFactor: 1.0,
-                               time: DIM_TIME / 1000,
-                               transition: 'linear'
-                             });
-        else
-            dimmer.dimFactor = 1.0;
+        dimmer.setDimmed(true, this._shouldAnimate());
     }
 
     _undimWindow(window) {
@@ -1599,13 +1603,7 @@ var WindowManager = class {
         let dimmer = getWindowDimmer(actor);
         if (!dimmer)
             return;
-        if (this._shouldAnimate())
-            Tweener.addTween(dimmer,
-                             { dimFactor: 0.0,
-                               time: UNDIM_TIME / 1000,
-                               transition: 'linear' });
-        else
-            dimmer.dimFactor = 0.0;
+        dimmer.setDimmed(false, this._shouldAnimate());
     }
 
     _mapWindow(shellwm, actor) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]