[gnome-shell] background: use of CHANGES_DONE_HINT events to avoid reloads



commit a432653c878e0468a6d92d748ee1f831cb7a6c11
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jul 31 16:17:35 2017 +0100

    background: use of CHANGES_DONE_HINT events to avoid reloads
    
    Instead of potentially loading a background mid-way when it changes, and
    loading it again for every file monitor event, leverage
    CHANGES_DONE_HINT events, which allow us to ignore CREATED and CHANGED
    signals from the file monitor.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=747794

 js/ui/background.js |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/background.js b/js/ui/background.js
index 681a5fe..1c2b83b 100644
--- a/js/ui/background.js
+++ b/js/ui/background.js
@@ -154,8 +154,12 @@ var BackgroundCache = new Lang.Class({
 
         let monitor = file.monitor(Gio.FileMonitorFlags.NONE, null);
         monitor.connect('changed',
-                        Lang.bind(this, function() {
-                            this.emit('file-changed', file);
+                        Lang.bind(this, function(obj, file, otherFile, eventType) {
+                            // Ignore CHANGED and CREATED events, since in both cases
+                            // we'll get a CHANGES_DONE_HINT event when done.
+                            if (eventType != Gio.FileMonitorEvent.CHANGED &&
+                                eventType != Gio.FileMonitorEvent.CREATED)
+                                this.emit('file-changed', file);
                         }));
 
         this._fileMonitors[key] = monitor;


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