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