[gnome-shell/wip/exalm/gestures: 52/52] tmp: Throttle SwipeTracker updates



commit 24bfde7631c1cb701826a8671795667751138edf
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Mon Jul 8 14:31:07 2019 +0500

    tmp: Throttle SwipeTracker updates
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/605

 js/ui/swipeTracker.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/swipeTracker.js b/js/ui/swipeTracker.js
index e6ccc80a7..c40131424 100644
--- a/js/ui/swipeTracker.js
+++ b/js/ui/swipeTracker.js
@@ -279,6 +279,8 @@ var SwipeTracker = class {
             this._scrollGesture.connect('end', this._endGesture.bind(this));
         } else
             this._scrollGesture = null;
+
+        this._prevUpdate = 0;
     }
 
     get enabled() {
@@ -369,7 +371,13 @@ var SwipeTracker = class {
 
         // Clamp progress to [0,1]
         let progress = this._progress / (1 + (this._progress > 0 ? this._backExtent : this._forwardExtent) / 
this._distance);
-        this.emit('update', progress);
+
+        if (this._prevUpdate != 0)
+            Meta.later_remove(this._prevUpdate);
+        this._prevUpdate = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
+            this.emit('update', progress);
+            this._prevUpdate = 0;
+        });
 
         this._prevTime = time;
     }


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