File gnome-shell-right-bg-with-resolution-change.patch of Package gnome-shell.1083

diff --git a/js/ui/background.js b/js/ui/background.js
index 41e67fe..885e96b 100644
--- a/js/ui/background.js
+++ b/js/ui/background.js
@@ -50,11 +50,9 @@ const BackgroundCache = new Lang.Class({
                                         effects: Meta.BackgroundEffects.NONE });
 
         let content = null;
+
         let candidateContent = null;
         for (let i = 0; i < this._patterns.length; i++) {
-            if (!this._patterns[i])
-                continue;
-
             if (this._patterns[i].get_shading() != params.shadingType)
                 continue;
 
@@ -88,7 +86,6 @@ const BackgroundCache = new Lang.Class({
         }
 
         this._patterns.push(content);
-
         return content;
     },
 
@@ -186,13 +183,17 @@ const BackgroundCache = new Lang.Class({
 
                                                   for (let j = 0; j < pendingLoad.callers.length; j++) {
                                                       if (pendingLoad.callers[j].onFinished) {
-                                                          if (content && pendingLoad.callers[j].shouldCopy) {
-                                                              content = object.copy(pendingLoad.callers[j].monitorIndex,
-                                                                                    pendingLoad.callers[j].effects);
+                                                          let newContent;
 
+                                                          if (content && pendingLoad.callers[j].shouldCopy) {
+                                                              newContent = content.copy(pendingLoad.callers[j].monitorIndex,
+                                                                                        pendingLoad.callers[j].effects);
+                                                              this._images.push(newContent);
+                                                          } else {
+                                                              newContent = content;
                                                           }
 
-                                                          pendingLoad.callers[j].onFinished(content);
+                                                          pendingLoad.callers[j].onFinished(newContent);
                                                       }
                                                   }
 
@@ -210,11 +211,9 @@ const BackgroundCache = new Lang.Class({
                                         onFinished: null });
 
         let content = null;
+
         let candidateContent = null;
         for (let i = 0; i < this._images.length; i++) {
-            if (!this._images[i])
-                continue;
-
             if (this._images[i].get_style() != params.style)
                 continue;
 
@@ -222,7 +221,7 @@ const BackgroundCache = new Lang.Class({
                 continue;
 
             if (params.style == GDesktopEnums.BackgroundStyle.SPANNED &&
-                this._images[i].monitor_index != this._monitorIndex)
+                this._images[i].monitor != params.monitorIndex)
                 continue;
 
             candidateContent = this._images[i];
@@ -315,7 +314,6 @@ const Background = new Lang.Class({
 
         this._brightness = 1.0;
         this._vignetteSharpness = 0.2;
-        this._saturation = 1.0;
         this._cancellable = new Gio.Cancellable();
         this.isLoaded = false;
 
@@ -415,29 +413,26 @@ const Background = new Lang.Class({
         this._fileWatches[filename] = signalId;
     },
 
-    _addImage: function(content, index, filename) {
-        content.saturation = this._saturation;
-        content.brightness = this._brightness;
-        content.vignette_sharpness = this._vignetteSharpness;
+    _ensureImage: function(index) {
+        if (this._images[index])
+            return;
 
         let actor = new Meta.BackgroundActor();
-        actor.content = content;
 
         // The background pattern is the first actor in
         // the group, and all images should be above that.
         this.actor.insert_child_at_index(actor, index + 1);
-
         this._images[index] = actor;
-        this._watchCacheFile(filename);
     },
 
-    _updateImage: function(content, index, filename) {
-        content.saturation = this._saturation;
+    _updateImage: function(index, content, filename) {
         content.brightness = this._brightness;
         content.vignette_sharpness = this._vignetteSharpness;
 
-        this._cache.removeImageContent(this._images[index].content);
-        this._images[index].content = content;
+        let image = this._images[index];
+        if (image.content)
+            this._cache.removeImageContent(content);
+        image.content = content;
         this._watchCacheFile(filename);
     },
 
@@ -485,11 +480,8 @@ const Background = new Lang.Class({
                                                   return;
                                               }
 
-                                              if (!this._images[i]) {
-                                                  this._addImage(content, i, files[i]);
-                                              } else {
-                                                  this._updateImage(content, i, files[i]);
-                                              }
+                                              this._ensureImage(i);
+                                              this._updateImage(i, content, files[i]);
 
                                               if (numPendingImages == 0) {
                                                   this._setLoaded();
@@ -544,24 +536,27 @@ const Background = new Lang.Class({
                                            });
     },
 
-    _loadFile: function(filename) {
+    _loadImage: function(filename) {
         this._cache.getImageContent({ monitorIndex: this._monitorIndex,
                                       effects: this._effects,
                                       style: this._style,
                                       filename: filename,
                                       cancellable: this._cancellable,
                                       onFinished: Lang.bind(this, function(content) {
-                                          if (!content) {
-                                              if (!this._cancellable.is_cancelled())
-                                                  this._loadAnimation(filename);
-                                              return;
+                                          if (content) {
+                                              this._ensureImage(0);
+                                              this._updateImage(0, content, filename);
                                           }
-
-                                          this._addImage(content, 0, filename);
                                           this._setLoaded();
                                       })
                                     });
+    },
 
+    _loadFile: function(filename) {
+        if (filename.endsWith('.xml'))
+            this._loadAnimation(filename);
+        else
+            this._loadImage(filename);
     },
 
     _load: function () {
@@ -590,24 +585,6 @@ const Background = new Lang.Class({
         this._loadFile(filename);
     },
 
-    get saturation() {
-        return this._saturation;
-    },
-
-    set saturation(saturation) {
-        this._saturation = saturation;
-
-        if (this._pattern && this._pattern.content)
-            this._pattern.content.saturation = saturation;
-
-        let keys = Object.keys(this._images);
-        for (let i = 0; i < keys.length; i++) {
-            let image = this._images[keys[i]];
-            if (image && image.content)
-                image.content.saturation = saturation;
-        }
-    },
-
     get brightness() {
         return this._brightness;
     },
@@ -659,7 +636,13 @@ const SystemBackground = new Lang.Class({
                                           this.emit('loaded');
                                       })
                                     });
-    }
+
+        this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
+    },
+
+    _onDestroy: function() {
+        this._cache.removeImageContent(this.actor.content);
+    },
 });
 Signals.addSignalMethods(SystemBackground.prototype);
 
@@ -747,11 +730,10 @@ const BackgroundManager = new Lang.Class({
         }
     },
 
-    _updateBackground: function(background, monitorIndex) {
-        let newBackground = this._createBackground(monitorIndex);
+    _updateBackground: function(background) {
+        let newBackground = this._createBackground();
         newBackground.vignetteSharpness = background.vignetteSharpness;
         newBackground.brightness = background.brightness;
-        newBackground.saturation = background.saturation;
         newBackground.visible = background.visible;
 
         newBackground.loadedSignalId = newBackground.connect('loaded',
@@ -798,7 +780,7 @@ const BackgroundManager = new Lang.Class({
         background.changeSignalId = background.connect('changed', Lang.bind(this, function() {
             background.disconnect(background.changeSignalId);
             background.changeSignalId = 0;
-            this._updateBackground(background, this._monitorIndex);
+            this._updateBackground(background);
         }));
 
         background.actor.connect('destroy', Lang.bind(this, function() {
openSUSE Build Service is sponsored by