[gnome-shell] background: Group 'changed' signal emission
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] background: Group 'changed' signal emission
- Date: Fri, 14 Jun 2019 12:41:31 +0000 (UTC)
commit 7059e31f6a2a471a020a5908516813ff9443beda
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Mon May 27 23:18:34 2019 -0500
background: Group 'changed' signal emission
Background is monitoring the whole `org.gnome.desktop.background` gsettings keys
for changes connecting to the non-specialized 'changed' signal and re-emitting
this as-is.
This means that when the background is changed via control-center, we get
multiple 'changed' signal events from GSettings, and for each one of this we
recreate a Background and a BackgroundActor.
Avoid this by using an idle to delay the emission of the 'changed' signal
grouping the events.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/558
js/ui/background.js | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/background.js b/js/ui/background.js
index d107fee1b..2a404ae9b 100644
--- a/js/ui/background.js
+++ b/js/ui/background.js
@@ -257,9 +257,8 @@ var Background = class Background {
this._refreshAnimation();
});
- this._settingsChangedSignalId = this._settings.connect('changed', () => {
- this.emit('changed');
- });
+ this._settingsChangedSignalId =
+ this._settings.connect('changed', this._emitChangedSignal.bind(this));
this._load();
}
@@ -290,6 +289,22 @@ var Background = class Background {
if (this._settingsChangedSignalId != 0)
this._settings.disconnect(this._settingsChangedSignalId);
this._settingsChangedSignalId = 0;
+
+ if (this._changedIdleId) {
+ GLib.source_remove(this._changedIdleId);
+ this._changedIdleId = 0;
+ }
+ }
+
+ _emitChangedSignal() {
+ if (this._changedIdleId)
+ return;
+
+ this._changedIdleId = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
+ this._changedIdleId = 0;
+ this.emit('changed');
+ return GLib.SOURCE_REMOVE;
+ });
}
updateResolution() {
@@ -345,7 +360,7 @@ var Background = class Background {
if (changedFile.equal(file)) {
let imageCache = Meta.BackgroundImageCache.get_default();
imageCache.purge(changedFile);
- this.emit('changed');
+ this._emitChangedSignal();
}
});
this._fileWatches[key] = signalId;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]