2012-12-24 09:20:39 -05:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
// READ THIS FIRST
|
|
|
|
// Background handling is a maze of objects, both objects in this file, and
|
|
|
|
// also objects inside Mutter. They all have a role.
|
|
|
|
//
|
|
|
|
// BackgroundManager
|
|
|
|
// The only object that other parts of GNOME Shell deal with; a
|
|
|
|
// BackgroundManager creates background actors and adds them to
|
|
|
|
// the specified container. When the background is changed by the
|
|
|
|
// user it will fade out the old actor and fade in the new actor.
|
|
|
|
// (This is separate from the fading for an animated background,
|
|
|
|
// since using two actors is quite inefficient.)
|
|
|
|
//
|
|
|
|
// MetaBackgroundImage
|
|
|
|
// An object represented an image file that will be used for drawing
|
|
|
|
// the background. MetaBackgroundImage objects asynchronously load,
|
|
|
|
// so they are first created in an unloaded state, then later emit
|
|
|
|
// a ::loaded signal when the Cogl object becomes available.
|
|
|
|
//
|
|
|
|
// MetaBackgroundImageCache
|
|
|
|
// A cache from filename to MetaBackgroundImage.
|
|
|
|
//
|
|
|
|
// BackgroundSource
|
|
|
|
// An object that is created for each GSettings schema (separate
|
|
|
|
// settings schemas are used for the lock screen and main background),
|
|
|
|
// and holds a reference to shared Background objects.
|
|
|
|
//
|
|
|
|
// MetaBackground
|
|
|
|
// Holds the specification of a background - a background color
|
|
|
|
// or gradient and one or two images blended together.
|
|
|
|
//
|
|
|
|
// Background
|
|
|
|
// JS delegate object that Connects a MetaBackground to the GSettings
|
|
|
|
// schema for the background.
|
|
|
|
//
|
|
|
|
// Animation
|
|
|
|
// A helper object that handles loading a XML-based animation; it is a
|
|
|
|
// wrapper for GnomeDesktop.BGSlideShow
|
|
|
|
//
|
|
|
|
// MetaBackgroundActor
|
|
|
|
// An actor that draws the background for a single monitor
|
|
|
|
//
|
|
|
|
// BackgroundCache
|
|
|
|
// A cache of Settings schema => BackgroundSource and of a single Animation.
|
|
|
|
// Also used to share file monitors.
|
|
|
|
//
|
|
|
|
// A static image, background color or gradient is relatively straightforward. The
|
|
|
|
// calling code creates a separate BackgroundManager for each monitor. Since they
|
|
|
|
// are created for the same GSettings schema, they will use the same BackgroundSource
|
|
|
|
// object, which provides a single Background and correspondingly a single
|
|
|
|
// MetaBackground object.
|
|
|
|
//
|
|
|
|
// BackgroundManager BackgroundManager
|
|
|
|
// | \ / |
|
|
|
|
// | BackgroundSource | looked up in BackgroundCache
|
|
|
|
// | | |
|
|
|
|
// | Background |
|
|
|
|
// | | |
|
|
|
|
// MetaBackgroundActor | MetaBackgroundActor
|
|
|
|
// \ | /
|
|
|
|
// `------- MetaBackground ------'
|
|
|
|
// |
|
|
|
|
// MetaBackgroundImage looked up in MetaBackgroundImageCache
|
|
|
|
//
|
|
|
|
// The animated case is tricker because the animation XML file can specify different
|
|
|
|
// files for different monitor resolutions and aspect ratios. For this reason,
|
|
|
|
// the BackgroundSource provides different Background share a single Animation object,
|
|
|
|
// which tracks the animation, but use different MetaBackground objects. In the
|
|
|
|
// common case, the different MetaBackground objects will be created for the
|
|
|
|
// same filename and look up the *same* MetaBackgroundImage object, so there is
|
|
|
|
// little wasted memory:
|
|
|
|
//
|
|
|
|
// BackgroundManager BackgroundManager
|
|
|
|
// | \ / |
|
|
|
|
// | BackgroundSource | looked up in BackgroundCache
|
|
|
|
// | / \ |
|
|
|
|
// | Background Background |
|
|
|
|
// | | \ / | |
|
|
|
|
// | | Animation | | looked up in BackgroundCache
|
|
|
|
// MetaBackgroundA|tor Me|aBackgroundActor
|
|
|
|
// \ | | /
|
|
|
|
// MetaBackground MetaBackground
|
|
|
|
// \ /
|
|
|
|
// MetaBackgroundImage looked up in MetaBackgroundImageCache
|
|
|
|
// MetaBackgroundImage
|
|
|
|
//
|
|
|
|
// But the case of different filenames and different background images
|
|
|
|
// is possible as well:
|
|
|
|
// ....
|
|
|
|
// MetaBackground MetaBackground
|
|
|
|
// | |
|
|
|
|
// MetaBackgroundImage MetaBackgroundImage
|
|
|
|
// MetaBackgroundImage MetaBackgroundImage
|
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
const GDesktopEnums = imports.gi.GDesktopEnums;
|
|
|
|
const Gio = imports.gi.Gio;
|
|
|
|
const GLib = imports.gi.GLib;
|
2013-02-04 16:50:36 -05:00
|
|
|
const GnomeDesktop = imports.gi.GnomeDesktop;
|
2012-12-24 09:20:39 -05:00
|
|
|
const Lang = imports.lang;
|
|
|
|
const Meta = imports.gi.Meta;
|
|
|
|
const Signals = imports.signals;
|
|
|
|
|
2016-10-21 08:09:32 -04:00
|
|
|
const LoginManager = imports.misc.loginManager;
|
2012-12-24 09:20:39 -05:00
|
|
|
const Main = imports.ui.main;
|
|
|
|
const Params = imports.misc.params;
|
|
|
|
const Tweener = imports.ui.tweener;
|
|
|
|
|
2014-10-16 16:45:02 -04:00
|
|
|
const DEFAULT_BACKGROUND_COLOR = Clutter.Color.from_pixel(0x2e3436ff);
|
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
const BACKGROUND_SCHEMA = 'org.gnome.desktop.background';
|
|
|
|
const PRIMARY_COLOR_KEY = 'primary-color';
|
|
|
|
const SECONDARY_COLOR_KEY = 'secondary-color';
|
|
|
|
const COLOR_SHADING_TYPE_KEY = 'color-shading-type';
|
|
|
|
const BACKGROUND_STYLE_KEY = 'picture-options';
|
|
|
|
const PICTURE_OPACITY_KEY = 'picture-opacity';
|
|
|
|
const PICTURE_URI_KEY = 'picture-uri';
|
|
|
|
|
|
|
|
const FADE_ANIMATION_TIME = 1.0;
|
|
|
|
|
2013-02-04 16:50:36 -05:00
|
|
|
// These parameters affect how often we redraw.
|
|
|
|
// The first is how different (percent crossfaded) the slide show
|
|
|
|
// has to look before redrawing and the second is the minimum
|
|
|
|
// frequency (in seconds) we're willing to wake up
|
|
|
|
const ANIMATION_OPACITY_STEP_INCREMENT = 4.0;
|
|
|
|
const ANIMATION_MIN_WAKEUP_INTERVAL = 1.0;
|
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
let _backgroundCache = null;
|
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
function _fileEqual0(file1, file2) {
|
|
|
|
if (file1 == file2)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!file1 || !file2)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return file1.equal(file2);
|
|
|
|
}
|
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
const BackgroundCache = new Lang.Class({
|
|
|
|
Name: 'BackgroundCache',
|
|
|
|
|
|
|
|
_init: function() {
|
2014-08-11 12:15:45 -04:00
|
|
|
this._fileMonitors = {};
|
|
|
|
this._backgroundSources = {};
|
2014-12-12 15:57:11 -05:00
|
|
|
this._animations = {};
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
monitorFile: function(file) {
|
|
|
|
let key = file.hash();
|
|
|
|
if (this._fileMonitors[key])
|
2012-12-24 09:20:39 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
let monitor = file.monitor(Gio.FileMonitorFlags.NONE, null);
|
2014-08-11 12:15:45 -04:00
|
|
|
monitor.connect('changed',
|
|
|
|
Lang.bind(this, function() {
|
2014-09-18 21:32:52 -04:00
|
|
|
this.emit('file-changed', file);
|
2014-08-11 12:15:45 -04:00
|
|
|
}));
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
this._fileMonitors[key] = monitor;
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
|
|
|
|
2013-02-04 16:50:36 -05:00
|
|
|
getAnimation: function(params) {
|
2014-09-18 21:32:52 -04:00
|
|
|
params = Params.parse(params, { file: null,
|
2014-12-12 15:57:11 -05:00
|
|
|
settingsSchema: null,
|
2013-02-04 16:50:36 -05:00
|
|
|
onLoaded: null });
|
|
|
|
|
2017-03-30 11:56:30 -04:00
|
|
|
let animation = this._animations[params.settingsSchema];
|
|
|
|
if (animation && _fileEqual0(animation.file, params.file)) {
|
2013-02-04 16:50:36 -05:00
|
|
|
if (params.onLoaded) {
|
2014-04-10 13:26:52 -04:00
|
|
|
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, function() {
|
2014-12-12 15:57:11 -05:00
|
|
|
params.onLoaded(this._animations[params.settingsSchema]);
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2013-02-04 16:50:36 -05:00
|
|
|
}));
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(id, '[gnome-shell] params.onLoaded');
|
2013-02-04 16:50:36 -05:00
|
|
|
}
|
2014-10-27 11:45:31 -04:00
|
|
|
return;
|
2013-02-04 16:50:36 -05:00
|
|
|
}
|
|
|
|
|
2017-03-30 11:56:30 -04:00
|
|
|
animation = new Animation({ file: params.file });
|
2013-02-04 16:50:36 -05:00
|
|
|
|
|
|
|
animation.load(Lang.bind(this, function() {
|
2014-12-12 15:57:11 -05:00
|
|
|
this._animations[params.settingsSchema] = animation;
|
2013-02-04 16:50:36 -05:00
|
|
|
|
|
|
|
if (params.onLoaded) {
|
2014-04-10 13:26:52 -04:00
|
|
|
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, function() {
|
2014-12-12 15:57:11 -05:00
|
|
|
params.onLoaded(this._animations[params.settingsSchema]);
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2013-02-04 16:50:36 -05:00
|
|
|
}));
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(id, '[gnome-shell] params.onLoaded');
|
2013-02-04 16:50:36 -05:00
|
|
|
}
|
|
|
|
}));
|
2014-08-11 12:15:45 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
getBackgroundSource: function(layoutManager, settingsSchema) {
|
|
|
|
// The layoutManager is always the same one; we pass in it since
|
|
|
|
// Main.layoutManager may not be set yet
|
|
|
|
|
|
|
|
if (!(settingsSchema in this._backgroundSources)) {
|
|
|
|
this._backgroundSources[settingsSchema] = new BackgroundSource(layoutManager, settingsSchema);
|
|
|
|
this._backgroundSources[settingsSchema]._useCount = 1;
|
|
|
|
} else {
|
|
|
|
this._backgroundSources[settingsSchema]._useCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._backgroundSources[settingsSchema];
|
|
|
|
},
|
|
|
|
|
|
|
|
releaseBackgroundSource: function(settingsSchema) {
|
|
|
|
if (settingsSchema in this._backgroundSources) {
|
|
|
|
let source = this._backgroundSources[settingsSchema];
|
|
|
|
source._useCount--;
|
|
|
|
if (source._useCount == 0) {
|
|
|
|
delete this._backgroundSources[settingsSchema];
|
|
|
|
source.destroy();
|
|
|
|
}
|
|
|
|
}
|
2012-12-24 09:20:39 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(BackgroundCache.prototype);
|
|
|
|
|
|
|
|
function getBackgroundCache() {
|
|
|
|
if (!_backgroundCache)
|
|
|
|
_backgroundCache = new BackgroundCache();
|
|
|
|
return _backgroundCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Background = new Lang.Class({
|
|
|
|
Name: 'Background',
|
|
|
|
|
|
|
|
_init: function(params) {
|
|
|
|
params = Params.parse(params, { monitorIndex: 0,
|
2013-02-04 16:50:36 -05:00
|
|
|
layoutManager: Main.layoutManager,
|
2014-08-11 08:35:52 -04:00
|
|
|
settings: null,
|
2014-09-18 21:32:52 -04:00
|
|
|
file: null,
|
2014-08-11 12:15:45 -04:00
|
|
|
style: null });
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
this.background = new Meta.Background({ meta_screen: global.screen });
|
|
|
|
this.background._delegate = this;
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2013-08-19 18:48:56 -04:00
|
|
|
this._settings = params.settings;
|
2014-09-18 21:32:52 -04:00
|
|
|
this._file = params.file;
|
2014-08-11 12:15:45 -04:00
|
|
|
this._style = params.style;
|
2012-12-24 09:20:39 -05:00
|
|
|
this._monitorIndex = params.monitorIndex;
|
2013-02-04 16:50:36 -05:00
|
|
|
this._layoutManager = params.layoutManager;
|
2012-12-24 09:20:39 -05:00
|
|
|
this._fileWatches = {};
|
|
|
|
this._cancellable = new Gio.Cancellable();
|
|
|
|
this.isLoaded = false;
|
|
|
|
|
2015-12-02 10:44:05 -05:00
|
|
|
this._clock = new GnomeDesktop.WallClock();
|
|
|
|
this._timezoneChangedId = this._clock.connect('notify::timezone',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
if (this._animation)
|
|
|
|
this._loadAnimation(this._animation.file);
|
|
|
|
}));
|
|
|
|
|
2017-01-30 07:29:13 -05:00
|
|
|
let loginManager = LoginManager.getLoginManager();
|
|
|
|
this._prepareForSleepId = loginManager.connect('prepare-for-sleep',
|
2016-10-21 08:09:32 -04:00
|
|
|
(lm, aboutToSuspend) => {
|
|
|
|
if (aboutToSuspend)
|
|
|
|
return;
|
|
|
|
this._refreshAnimation();
|
|
|
|
});
|
|
|
|
|
2013-10-02 09:29:30 -04:00
|
|
|
this._settingsChangedSignalId = this._settings.connect('changed', Lang.bind(this, function() {
|
|
|
|
this.emit('changed');
|
|
|
|
}));
|
2012-12-24 09:20:39 -05:00
|
|
|
|
|
|
|
this._load();
|
|
|
|
},
|
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
destroy: function() {
|
2012-12-24 09:20:39 -05:00
|
|
|
this._cancellable.cancel();
|
2014-09-12 17:07:31 -04:00
|
|
|
this._removeAnimationTimeout();
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2013-02-04 16:50:36 -05:00
|
|
|
let i;
|
2012-12-24 09:20:39 -05:00
|
|
|
let keys = Object.keys(this._fileWatches);
|
|
|
|
for (i = 0; i < keys.length; i++) {
|
|
|
|
this._cache.disconnect(this._fileWatches[keys[i]]);
|
|
|
|
}
|
|
|
|
this._fileWatches = null;
|
|
|
|
|
2015-12-02 10:44:05 -05:00
|
|
|
if (this._timezoneChangedId != 0)
|
|
|
|
this._clock.disconnect(this._timezoneChangedId);
|
|
|
|
this._timezoneChangedId = 0;
|
|
|
|
|
2017-01-30 07:29:13 -05:00
|
|
|
if (this._prepareForSleepId != 0)
|
|
|
|
LoginManager.getLoginManager().disconnect(this._prepareForSleepId);
|
|
|
|
this._prepareForSleepId = 0;
|
|
|
|
|
2013-10-02 09:29:30 -04:00
|
|
|
if (this._settingsChangedSignalId != 0)
|
|
|
|
this._settings.disconnect(this._settingsChangedSignalId);
|
|
|
|
this._settingsChangedSignalId = 0;
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
|
|
|
|
2014-09-12 17:07:31 -04:00
|
|
|
updateResolution: function() {
|
2016-10-21 08:09:32 -04:00
|
|
|
if (this._animation)
|
|
|
|
this._refreshAnimation();
|
|
|
|
},
|
|
|
|
|
|
|
|
_refreshAnimation: function() {
|
|
|
|
if (!this._animation)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._removeAnimationTimeout();
|
|
|
|
this._updateAnimation();
|
2014-09-12 17:07:31 -04:00
|
|
|
},
|
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
_setLoaded: function() {
|
|
|
|
if (this.isLoaded)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.isLoaded = true;
|
|
|
|
|
2014-04-10 13:26:52 -04:00
|
|
|
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, function() {
|
2012-12-24 09:20:39 -05:00
|
|
|
this.emit('loaded');
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2012-12-24 09:20:39 -05:00
|
|
|
}));
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(id, '[gnome-shell] this.emit');
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_loadPattern: function() {
|
|
|
|
let colorString, res, color, secondColor;
|
|
|
|
|
|
|
|
colorString = this._settings.get_string(PRIMARY_COLOR_KEY);
|
|
|
|
[res, color] = Clutter.Color.from_string(colorString);
|
|
|
|
colorString = this._settings.get_string(SECONDARY_COLOR_KEY);
|
|
|
|
[res, secondColor] = Clutter.Color.from_string(colorString);
|
|
|
|
|
|
|
|
let shadingType = this._settings.get_enum(COLOR_SHADING_TYPE_KEY);
|
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
if (shadingType == GDesktopEnums.BackgroundShading.SOLID)
|
|
|
|
this.background.set_color(color);
|
|
|
|
else
|
|
|
|
this.background.set_gradient(shadingType, color, secondColor);
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
_watchFile: function(file) {
|
|
|
|
let key = file.hash();
|
|
|
|
if (this._fileWatches[key])
|
2012-12-24 09:20:39 -05:00
|
|
|
return;
|
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
this._cache.monitorFile(file);
|
2012-12-24 09:20:39 -05:00
|
|
|
let signalId = this._cache.connect('file-changed',
|
|
|
|
Lang.bind(this, function(cache, changedFile) {
|
2014-09-18 21:32:52 -04:00
|
|
|
if (changedFile.equal(file)) {
|
2014-09-24 16:40:00 -04:00
|
|
|
let imageCache = Meta.BackgroundImageCache.get_default();
|
|
|
|
imageCache.purge(changedFile);
|
2012-12-24 09:20:39 -05:00
|
|
|
this.emit('changed');
|
|
|
|
}
|
|
|
|
}));
|
2014-09-18 21:32:52 -04:00
|
|
|
this._fileWatches[key] = signalId;
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
|
|
|
|
2014-09-12 17:07:31 -04:00
|
|
|
_removeAnimationTimeout: function() {
|
|
|
|
if (this._updateAnimationTimeoutId) {
|
|
|
|
GLib.source_remove(this._updateAnimationTimeoutId);
|
|
|
|
this._updateAnimationTimeoutId = 0;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-02-04 16:50:36 -05:00
|
|
|
_updateAnimation: function() {
|
2013-03-14 17:00:57 -04:00
|
|
|
this._updateAnimationTimeoutId = 0;
|
2013-02-04 16:50:36 -05:00
|
|
|
|
2013-03-14 17:03:25 -04:00
|
|
|
this._animation.update(this._layoutManager.monitors[this._monitorIndex]);
|
|
|
|
let files = this._animation.keyFrameFiles;
|
2013-02-04 16:50:36 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
let finish = Lang.bind(this, function() {
|
2013-02-04 16:50:36 -05:00
|
|
|
this._setLoaded();
|
2014-08-11 12:15:45 -04:00
|
|
|
if (files.length > 1) {
|
|
|
|
this.background.set_blend(files[0], files[1],
|
|
|
|
this._animation.transitionProgress,
|
|
|
|
this._style);
|
|
|
|
} else if (files.length > 0) {
|
2014-09-18 21:32:52 -04:00
|
|
|
this.background.set_file(files[0], this._style);
|
2014-08-11 12:15:45 -04:00
|
|
|
} else {
|
2014-09-18 21:32:52 -04:00
|
|
|
this.background.set_file(null, this._style);
|
2014-08-11 12:15:45 -04:00
|
|
|
}
|
2013-03-14 17:00:57 -04:00
|
|
|
this._queueUpdateAnimation();
|
2014-08-11 12:15:45 -04:00
|
|
|
});
|
2013-02-04 16:50:36 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
let cache = Meta.BackgroundImageCache.get_default();
|
2013-02-04 16:50:36 -05:00
|
|
|
let numPendingImages = files.length;
|
|
|
|
for (let i = 0; i < files.length; i++) {
|
2014-08-11 12:15:45 -04:00
|
|
|
this._watchFile(files[i]);
|
|
|
|
let image = cache.load(files[i]);
|
|
|
|
if (image.is_loaded()) {
|
2013-02-04 16:50:36 -05:00
|
|
|
numPendingImages--;
|
|
|
|
if (numPendingImages == 0)
|
2014-08-11 12:15:45 -04:00
|
|
|
finish();
|
|
|
|
} else {
|
|
|
|
let id = image.connect('loaded',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
image.disconnect(id);
|
|
|
|
numPendingImages--;
|
|
|
|
if (numPendingImages == 0)
|
|
|
|
finish();
|
|
|
|
}));
|
2013-02-04 16:50:36 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-03-14 17:00:57 -04:00
|
|
|
_queueUpdateAnimation: function() {
|
|
|
|
if (this._updateAnimationTimeoutId != 0)
|
2013-02-04 16:50:36 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!this._cancellable || this._cancellable.is_cancelled())
|
|
|
|
return;
|
|
|
|
|
2013-03-14 16:58:52 -04:00
|
|
|
if (!this._animation.transitionDuration)
|
2013-02-04 16:50:36 -05:00
|
|
|
return;
|
|
|
|
|
2013-03-14 16:58:20 -04:00
|
|
|
let nSteps = 255 / ANIMATION_OPACITY_STEP_INCREMENT;
|
2013-03-14 16:58:52 -04:00
|
|
|
let timePerStep = (this._animation.transitionDuration * 1000) / nSteps;
|
2013-03-14 16:58:20 -04:00
|
|
|
|
2013-02-04 16:50:36 -05:00
|
|
|
let interval = Math.max(ANIMATION_MIN_WAKEUP_INTERVAL * 1000,
|
2013-03-14 16:58:20 -04:00
|
|
|
timePerStep);
|
2013-03-25 10:42:21 -04:00
|
|
|
|
|
|
|
if (interval > GLib.MAXUINT32)
|
|
|
|
return;
|
|
|
|
|
2013-03-14 17:00:57 -04:00
|
|
|
this._updateAnimationTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
|
2013-02-04 16:50:36 -05:00
|
|
|
interval,
|
|
|
|
Lang.bind(this, function() {
|
2013-03-14 17:00:57 -04:00
|
|
|
this._updateAnimationTimeoutId = 0;
|
2013-02-04 16:50:36 -05:00
|
|
|
this._updateAnimation();
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2013-02-04 16:50:36 -05:00
|
|
|
}));
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(this._updateAnimationTimeoutId, '[gnome-shell] this._updateAnimation');
|
2013-02-04 16:50:36 -05:00
|
|
|
},
|
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
_loadAnimation: function(file) {
|
|
|
|
this._cache.getAnimation({ file: file,
|
2014-12-12 15:57:11 -05:00
|
|
|
settingsSchema: this._settings.schema_id,
|
2015-09-07 00:49:55 -04:00
|
|
|
onLoaded: Lang.bind(this, function(animation) {
|
|
|
|
this._animation = animation;
|
2013-02-04 16:50:36 -05:00
|
|
|
|
2015-09-07 00:49:55 -04:00
|
|
|
if (!this._animation || this._cancellable.is_cancelled()) {
|
|
|
|
this._setLoaded();
|
|
|
|
return;
|
|
|
|
}
|
2013-02-04 16:50:36 -05:00
|
|
|
|
2015-09-07 00:49:55 -04:00
|
|
|
this._updateAnimation();
|
|
|
|
this._watchFile(file);
|
|
|
|
})
|
2014-09-18 21:32:52 -04:00
|
|
|
});
|
2013-02-04 16:50:36 -05:00
|
|
|
},
|
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
_loadImage: function(file) {
|
|
|
|
this.background.set_file(file, this._style);
|
|
|
|
this._watchFile(file);
|
2014-08-11 12:15:45 -04:00
|
|
|
|
|
|
|
let cache = Meta.BackgroundImageCache.get_default();
|
2014-09-18 21:32:52 -04:00
|
|
|
let image = cache.load(file);
|
2014-08-11 12:15:45 -04:00
|
|
|
if (image.is_loaded())
|
|
|
|
this._setLoaded();
|
|
|
|
else {
|
|
|
|
let id = image.connect('loaded',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this._setLoaded();
|
|
|
|
image.disconnect(id);
|
|
|
|
}));
|
|
|
|
}
|
2013-12-03 15:56:12 -05:00
|
|
|
},
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
_loadFile: function(file) {
|
|
|
|
if (file.get_basename().endsWith('.xml'))
|
|
|
|
this._loadAnimation(file);
|
2013-12-03 15:56:12 -05:00
|
|
|
else
|
2014-09-18 21:32:52 -04:00
|
|
|
this._loadImage(file);
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_load: function () {
|
|
|
|
this._cache = getBackgroundCache();
|
|
|
|
|
2014-01-13 18:21:03 -05:00
|
|
|
this._loadPattern();
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
if (!this._file) {
|
2013-06-13 15:48:32 -04:00
|
|
|
this._setLoaded();
|
|
|
|
return;
|
|
|
|
}
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
this._loadFile(this._file);
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
2014-08-11 12:15:45 -04:00
|
|
|
});
|
|
|
|
Signals.addSignalMethods(Background.prototype);
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
let _systemBackground;
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
const SystemBackground = new Lang.Class({
|
|
|
|
Name: 'SystemBackground',
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
_init: function() {
|
2014-09-18 22:24:46 -04:00
|
|
|
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/noise-texture.png');
|
2014-08-11 12:15:45 -04:00
|
|
|
|
|
|
|
if (_systemBackground == null) {
|
|
|
|
_systemBackground = new Meta.Background({ meta_screen: global.screen });
|
2014-10-16 16:45:02 -04:00
|
|
|
_systemBackground.set_color(DEFAULT_BACKGROUND_COLOR);
|
2014-09-18 21:32:52 -04:00
|
|
|
_systemBackground.set_file(file, GDesktopEnums.BackgroundStyle.WALLPAPER);
|
2014-08-11 12:15:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
this.actor = new Meta.BackgroundActor({ meta_screen: global.screen,
|
|
|
|
monitor: 0,
|
|
|
|
background: _systemBackground });
|
|
|
|
|
|
|
|
let cache = Meta.BackgroundImageCache.get_default();
|
2014-09-18 21:32:52 -04:00
|
|
|
let image = cache.load(file);
|
2014-08-11 12:15:45 -04:00
|
|
|
if (image.is_loaded()) {
|
|
|
|
image = null;
|
|
|
|
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, function() {
|
|
|
|
this.emit('loaded');
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
}));
|
|
|
|
GLib.Source.set_name_by_id(id, '[gnome-shell] SystemBackground.loaded');
|
|
|
|
} else {
|
|
|
|
let id = image.connect('loaded',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this.emit('loaded');
|
|
|
|
image.disconnect(id);
|
|
|
|
image = null;
|
|
|
|
}));
|
2013-02-04 16:50:36 -05:00
|
|
|
}
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
2014-08-11 12:15:45 -04:00
|
|
|
});
|
|
|
|
Signals.addSignalMethods(SystemBackground.prototype);
|
|
|
|
|
|
|
|
const BackgroundSource = new Lang.Class({
|
|
|
|
Name: 'BackgroundSource',
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
_init: function(layoutManager, settingsSchema) {
|
|
|
|
// Allow override the background image setting for performance testing
|
|
|
|
this._layoutManager = layoutManager;
|
|
|
|
this._overrideImage = GLib.getenv('SHELL_BACKGROUND_IMAGE');
|
|
|
|
this._settings = new Gio.Settings({ schema_id: settingsSchema });
|
|
|
|
this._backgrounds = [];
|
2014-09-12 17:07:31 -04:00
|
|
|
|
|
|
|
this._monitorsChangedId = global.screen.connect('monitors-changed',
|
|
|
|
Lang.bind(this, this._onMonitorsChanged));
|
|
|
|
},
|
|
|
|
|
|
|
|
_onMonitorsChanged: function() {
|
|
|
|
for (let monitorIndex in this._backgrounds) {
|
|
|
|
let background = this._backgrounds[monitorIndex];
|
|
|
|
|
|
|
|
if (monitorIndex < this._layoutManager.monitors.length) {
|
|
|
|
background.updateResolution();
|
|
|
|
} else {
|
|
|
|
background.disconnect(background._changedId);
|
|
|
|
background.destroy();
|
|
|
|
delete this._backgrounds[monitorIndex];
|
|
|
|
}
|
|
|
|
}
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
getBackground: function(monitorIndex) {
|
2014-09-18 21:32:52 -04:00
|
|
|
let file = null;
|
2014-08-11 12:15:45 -04:00
|
|
|
let style;
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2015-03-20 15:39:01 -04:00
|
|
|
// We don't watch changes to settings here,
|
|
|
|
// instead we rely on Background to watch those
|
|
|
|
// and emit 'changed' at the right time
|
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
if (this._overrideImage != null) {
|
2014-09-18 21:32:52 -04:00
|
|
|
file = Gio.File.new_for_path(this._overrideImage);
|
2014-08-11 12:15:45 -04:00
|
|
|
style = GDesktopEnums.BackgroundStyle.ZOOM; // Hardcode
|
|
|
|
} else {
|
|
|
|
style = this._settings.get_enum(BACKGROUND_STYLE_KEY);
|
|
|
|
if (style != GDesktopEnums.BackgroundStyle.NONE) {
|
|
|
|
let uri = this._settings.get_string(PICTURE_URI_KEY);
|
2014-09-18 21:32:52 -04:00
|
|
|
file = Gio.File.new_for_commandline_arg(uri);
|
2014-08-11 12:15:45 -04:00
|
|
|
}
|
2013-02-04 16:50:36 -05:00
|
|
|
}
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
// Animated backgrounds are (potentially) per-monitor, since
|
|
|
|
// they can have variants that depend on the aspect ratio and
|
|
|
|
// size of the monitor; for other backgrounds we can use the
|
|
|
|
// same background object for all monitors.
|
2014-09-18 21:32:52 -04:00
|
|
|
if (file == null || !file.get_basename().endsWith('.xml'))
|
2014-08-11 12:15:45 -04:00
|
|
|
monitorIndex = 0;
|
|
|
|
|
|
|
|
if (!(monitorIndex in this._backgrounds)) {
|
|
|
|
let background = new Background({
|
|
|
|
monitorIndex: monitorIndex,
|
|
|
|
layoutManager: this._layoutManager,
|
|
|
|
settings: this._settings,
|
2014-09-18 21:32:52 -04:00
|
|
|
file: file,
|
2014-08-11 12:15:45 -04:00
|
|
|
style: style
|
|
|
|
});
|
|
|
|
|
2014-09-12 17:07:31 -04:00
|
|
|
background._changedId = background.connect('changed', Lang.bind(this, function() {
|
|
|
|
background.disconnect(background._changedId);
|
2014-08-11 12:15:45 -04:00
|
|
|
background.destroy();
|
|
|
|
delete this._backgrounds[monitorIndex];
|
|
|
|
}));
|
|
|
|
|
|
|
|
this._backgrounds[monitorIndex] = background;
|
|
|
|
}
|
2013-02-21 14:32:23 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
return this._backgrounds[monitorIndex];
|
2013-12-03 17:05:06 -05:00
|
|
|
},
|
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
destroy: function() {
|
2014-09-12 17:07:31 -04:00
|
|
|
global.screen.disconnect(this._monitorsChangedId);
|
|
|
|
|
|
|
|
for (let monitorIndex in this._backgrounds) {
|
|
|
|
let background = this._backgrounds[monitorIndex];
|
|
|
|
background.disconnect(background._changedId);
|
|
|
|
background.destroy();
|
|
|
|
}
|
2014-06-26 12:45:06 -04:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
this._backgrounds = null;
|
|
|
|
}
|
2013-02-21 14:32:23 -05:00
|
|
|
});
|
|
|
|
|
2013-02-04 16:50:36 -05:00
|
|
|
const Animation = new Lang.Class({
|
|
|
|
Name: 'Animation',
|
|
|
|
|
|
|
|
_init: function(params) {
|
2014-09-18 21:32:52 -04:00
|
|
|
params = Params.parse(params, { file: null });
|
2013-02-04 16:50:36 -05:00
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
this.file = params.file;
|
2013-03-14 17:03:25 -04:00
|
|
|
this.keyFrameFiles = [];
|
2013-02-04 16:50:36 -05:00
|
|
|
this.transitionProgress = 0.0;
|
2013-03-14 16:58:52 -04:00
|
|
|
this.transitionDuration = 0.0;
|
2013-02-04 16:50:36 -05:00
|
|
|
this.loaded = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
load: function(callback) {
|
2014-09-18 21:32:52 -04:00
|
|
|
this._show = new GnomeDesktop.BGSlideShow({ filename: this.file.get_path() });
|
2013-02-04 16:50:36 -05:00
|
|
|
|
|
|
|
this._show.load_async(null,
|
|
|
|
Lang.bind(this,
|
|
|
|
function(object, result) {
|
|
|
|
this.loaded = true;
|
|
|
|
if (callback)
|
|
|
|
callback();
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
2013-03-14 17:03:25 -04:00
|
|
|
update: function(monitor) {
|
|
|
|
this.keyFrameFiles = [];
|
|
|
|
|
2013-02-04 16:50:36 -05:00
|
|
|
if (!this._show)
|
2013-03-14 17:03:25 -04:00
|
|
|
return;
|
2013-02-04 16:50:36 -05:00
|
|
|
|
|
|
|
if (this._show.get_num_slides() < 1)
|
2013-03-14 17:03:25 -04:00
|
|
|
return;
|
2013-02-04 16:50:36 -05:00
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
let [progress, duration, isFixed, filename1, filename2] = this._show.get_current_slide(monitor.width, monitor.height);
|
2013-02-04 16:50:36 -05:00
|
|
|
|
2013-03-14 16:58:52 -04:00
|
|
|
this.transitionDuration = duration;
|
2013-02-04 16:50:36 -05:00
|
|
|
this.transitionProgress = progress;
|
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
if (filename1)
|
|
|
|
this.keyFrameFiles.push(Gio.File.new_for_path(filename1));
|
2013-02-04 16:50:36 -05:00
|
|
|
|
2014-09-18 21:32:52 -04:00
|
|
|
if (filename2)
|
|
|
|
this.keyFrameFiles.push(Gio.File.new_for_path(filename2));
|
2013-02-04 16:50:36 -05:00
|
|
|
},
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(Animation.prototype);
|
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
const BackgroundManager = new Lang.Class({
|
|
|
|
Name: 'BackgroundManager',
|
|
|
|
|
|
|
|
_init: function(params) {
|
|
|
|
params = Params.parse(params, { container: null,
|
|
|
|
layoutManager: Main.layoutManager,
|
|
|
|
monitorIndex: null,
|
2014-08-11 12:15:45 -04:00
|
|
|
vignette: false,
|
2013-08-19 18:48:56 -04:00
|
|
|
controlPosition: true,
|
|
|
|
settingsSchema: BACKGROUND_SCHEMA });
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
let cache = getBackgroundCache();
|
|
|
|
this._settingsSchema = params.settingsSchema;
|
|
|
|
this._backgroundSource = cache.getBackgroundSource(params.layoutManager, params.settingsSchema);
|
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
this._container = params.container;
|
|
|
|
this._layoutManager = params.layoutManager;
|
2014-08-11 12:15:45 -04:00
|
|
|
this._vignette = params.vignette;
|
2012-12-24 09:20:39 -05:00
|
|
|
this._monitorIndex = params.monitorIndex;
|
ScreenShield: fix positioning of background with multimonitor
Previously, we would create one StBin per monitor, but each was positioned
at 0,0 and sized as the screen, so they would overlap and draw the box shadows
on top of the other backgrounds.
Instead, we need to size appropriately the bin, and then we need to position
the actual MetaBacgroundActor at 0,0, so add a flag to BackgroundManager
for this.
Also, get rid of MetaBackgroundGroup, they do nothing because the screenshield
is not a descendant of the MetaWindowGroup and because the widget in between
blocks the propagation of the visible region. At the same time, use a
widget, not a bin, because StBin requires you to set .child, not call add_child().
https://bugzilla.gnome.org/show_bug.cgi?id=694394
2013-02-21 17:32:25 -05:00
|
|
|
this._controlPosition = params.controlPosition;
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
this.backgroundActor = this._createBackgroundActor();
|
|
|
|
this._newBackgroundActor = null;
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
2014-08-11 12:15:45 -04:00
|
|
|
let cache = getBackgroundCache();
|
|
|
|
cache.releaseBackgroundSource(this._settingsSchema);
|
|
|
|
this._backgroundSource = null;
|
|
|
|
|
|
|
|
if (this._newBackgroundActor) {
|
|
|
|
this._newBackgroundActor.destroy();
|
|
|
|
this._newBackgroundActor = null;
|
2012-12-24 09:20:39 -05:00
|
|
|
}
|
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
if (this.backgroundActor) {
|
|
|
|
this.backgroundActor.destroy();
|
|
|
|
this.backgroundActor = null;
|
2012-12-24 09:20:39 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
_swapBackgroundActor: function() {
|
|
|
|
let oldBackgroundActor = this.backgroundActor;
|
|
|
|
this.backgroundActor = this._newBackgroundActor;
|
|
|
|
this._newBackgroundActor = null;
|
|
|
|
this.emit('changed');
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
Tweener.addTween(oldBackgroundActor,
|
|
|
|
{ opacity: 0,
|
|
|
|
time: FADE_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
onComplete: function() {
|
2016-06-10 06:34:48 -04:00
|
|
|
oldBackgroundActor.background.run_dispose();
|
2014-08-11 12:15:45 -04:00
|
|
|
oldBackgroundActor.destroy();
|
|
|
|
}
|
|
|
|
});
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
_updateBackgroundActor: function() {
|
|
|
|
if (this._newBackgroundActor) {
|
|
|
|
/* Skip displaying existing background queued for load */
|
|
|
|
this._newBackgroundActor.destroy();
|
|
|
|
this._newBackgroundActor = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
let newBackgroundActor = this._createBackgroundActor();
|
|
|
|
newBackgroundActor.vignette_sharpness = this.backgroundActor.vignette_sharpness;
|
|
|
|
newBackgroundActor.brightness = this.backgroundActor.brightness;
|
|
|
|
newBackgroundActor.visible = this.backgroundActor.visible;
|
|
|
|
|
|
|
|
this._newBackgroundActor = newBackgroundActor;
|
|
|
|
|
|
|
|
let background = newBackgroundActor.background._delegate;
|
|
|
|
|
|
|
|
if (background.isLoaded) {
|
|
|
|
this._swapBackgroundActor();
|
|
|
|
} else {
|
|
|
|
newBackgroundActor.loadedSignalId = background.connect('loaded',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
background.disconnect(newBackgroundActor.loadedSignalId);
|
|
|
|
newBackgroundActor.loadedSignalId = 0;
|
|
|
|
|
|
|
|
this._swapBackgroundActor();
|
|
|
|
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_createBackgroundActor: function() {
|
|
|
|
let background = this._backgroundSource.getBackground(this._monitorIndex);
|
|
|
|
let backgroundActor = new Meta.BackgroundActor({ meta_screen: global.screen,
|
|
|
|
monitor: this._monitorIndex,
|
|
|
|
background: background.background,
|
|
|
|
vignette: this._vignette,
|
|
|
|
vignette_sharpness: 0.5,
|
|
|
|
brightness: 0.5,
|
|
|
|
});
|
|
|
|
|
|
|
|
this._container.add_child(backgroundActor);
|
2012-12-24 09:20:39 -05:00
|
|
|
|
|
|
|
let monitor = this._layoutManager.monitors[this._monitorIndex];
|
ScreenShield: fix positioning of background with multimonitor
Previously, we would create one StBin per monitor, but each was positioned
at 0,0 and sized as the screen, so they would overlap and draw the box shadows
on top of the other backgrounds.
Instead, we need to size appropriately the bin, and then we need to position
the actual MetaBacgroundActor at 0,0, so add a flag to BackgroundManager
for this.
Also, get rid of MetaBackgroundGroup, they do nothing because the screenshield
is not a descendant of the MetaWindowGroup and because the widget in between
blocks the propagation of the visible region. At the same time, use a
widget, not a bin, because StBin requires you to set .child, not call add_child().
https://bugzilla.gnome.org/show_bug.cgi?id=694394
2013-02-21 17:32:25 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
backgroundActor.set_size(monitor.width, monitor.height);
|
ScreenShield: fix positioning of background with multimonitor
Previously, we would create one StBin per monitor, but each was positioned
at 0,0 and sized as the screen, so they would overlap and draw the box shadows
on top of the other backgrounds.
Instead, we need to size appropriately the bin, and then we need to position
the actual MetaBacgroundActor at 0,0, so add a flag to BackgroundManager
for this.
Also, get rid of MetaBackgroundGroup, they do nothing because the screenshield
is not a descendant of the MetaWindowGroup and because the widget in between
blocks the propagation of the visible region. At the same time, use a
widget, not a bin, because StBin requires you to set .child, not call add_child().
https://bugzilla.gnome.org/show_bug.cgi?id=694394
2013-02-21 17:32:25 -05:00
|
|
|
if (this._controlPosition) {
|
2014-08-11 12:15:45 -04:00
|
|
|
backgroundActor.set_position(monitor.x, monitor.y);
|
|
|
|
backgroundActor.lower_bottom();
|
ScreenShield: fix positioning of background with multimonitor
Previously, we would create one StBin per monitor, but each was positioned
at 0,0 and sized as the screen, so they would overlap and draw the box shadows
on top of the other backgrounds.
Instead, we need to size appropriately the bin, and then we need to position
the actual MetaBacgroundActor at 0,0, so add a flag to BackgroundManager
for this.
Also, get rid of MetaBackgroundGroup, they do nothing because the screenshield
is not a descendant of the MetaWindowGroup and because the widget in between
blocks the propagation of the visible region. At the same time, use a
widget, not a bin, because StBin requires you to set .child, not call add_child().
https://bugzilla.gnome.org/show_bug.cgi?id=694394
2013-02-21 17:32:25 -05:00
|
|
|
}
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
let changeSignalId = background.connect('changed', Lang.bind(this, function() {
|
|
|
|
background.disconnect(changeSignalId);
|
|
|
|
changeSignalId = null;
|
|
|
|
this._updateBackgroundActor();
|
2012-12-24 09:20:39 -05:00
|
|
|
}));
|
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
backgroundActor.connect('destroy', Lang.bind(this, function() {
|
|
|
|
if (changeSignalId)
|
|
|
|
background.disconnect(changeSignalId);
|
2013-03-19 15:26:05 -04:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
if (backgroundActor.loadedSignalId)
|
2014-09-04 10:01:52 -04:00
|
|
|
background.disconnect(backgroundActor.loadedSignalId);
|
2013-03-19 15:26:05 -04:00
|
|
|
}));
|
2012-12-24 09:20:39 -05:00
|
|
|
|
2014-08-11 12:15:45 -04:00
|
|
|
return backgroundActor;
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(BackgroundManager.prototype);
|