background: always copy background content when loading into cache

Copying is actually a lightweight operation, so trying to avoid it just adds
code complexity for little gain.

Based on work from Jasper St. Pierre <jstpierre@macheye.net>

https://bugzilla.gnome.org/show_bug.cgi?id=722149
This commit is contained in:
Ray Strode 2014-02-26 14:35:38 -05:00 committed by Jasper St. Pierre
parent 60f3c09f90
commit ec6facb9e7

View File

@ -143,8 +143,7 @@ const BackgroundCache = new Lang.Class({
for (let i = 0; i < this._pendingFileLoads.length; i++) {
if (this._pendingFileLoads[i].filename == params.filename &&
this._pendingFileLoads[i].style == params.style) {
this._pendingFileLoads[i].callers.push({ shouldCopy: true,
monitorIndex: params.monitorIndex,
this._pendingFileLoads[i].callers.push({ monitorIndex: params.monitorIndex,
effects: params.effects,
onFinished: params.onFinished });
return;
@ -153,14 +152,11 @@ const BackgroundCache = new Lang.Class({
this._pendingFileLoads.push({ filename: params.filename,
style: params.style,
callers: [{ shouldCopy: false,
monitorIndex: params.monitorIndex,
callers: [{ monitorIndex: params.monitorIndex,
effects: params.effects,
onFinished: params.onFinished }] });
let content = new Meta.Background({ meta_screen: global.screen,
monitor: params.monitorIndex,
effects: params.effects });
let content = new Meta.Background({ meta_screen: global.screen });
content.load_file_async(params.filename,
params.style,
@ -171,7 +167,6 @@ const BackgroundCache = new Lang.Class({
content.load_file_finish(result);
this._monitorFile(params.filename);
this._images.push(content);
} catch(e) {
content = null;
}
@ -186,12 +181,10 @@ const BackgroundCache = new Lang.Class({
if (pendingLoad.callers[j].onFinished) {
let newContent;
if (content && pendingLoad.callers[j].shouldCopy) {
if (content) {
newContent = content.copy(pendingLoad.callers[j].monitorIndex,
pendingLoad.callers[j].effects);
this._images.push(newContent);
} else {
newContent = content;
}
pendingLoad.callers[j].onFinished(newContent);