Compare commits
7 Commits
3.13.91
...
wip/wobbly
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e7f82c66de | ||
![]() |
73977795a6 | ||
![]() |
3b3445146d | ||
![]() |
650dea017b | ||
![]() |
70099872ab | ||
![]() |
dc5618558f | ||
![]() |
62481f4b7c |
@@ -90,6 +90,7 @@
|
||||
<file>ui/windowAttentionHandler.js</file>
|
||||
<file>ui/windowMenu.js</file>
|
||||
<file>ui/windowManager.js</file>
|
||||
<file>ui/wobbly.js</file>
|
||||
<file>ui/workspace.js</file>
|
||||
<file>ui/workspaceSwitcherPopup.js</file>
|
||||
<file>ui/workspaceThumbnail.js</file>
|
||||
|
@@ -1,5 +1,98 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
|
||||
// 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
|
||||
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const GDesktopEnums = imports.gi.GDesktopEnums;
|
||||
const Gio = imports.gi.Gio;
|
||||
@@ -36,235 +129,25 @@ const BackgroundCache = new Lang.Class({
|
||||
Name: 'BackgroundCache',
|
||||
|
||||
_init: function() {
|
||||
this._patterns = [];
|
||||
this._images = [];
|
||||
this._pendingFileLoads = [];
|
||||
this._fileMonitors = {};
|
||||
this._backgroundSources = {};
|
||||
},
|
||||
|
||||
getPatternContent: function(params) {
|
||||
params = Params.parse(params, { monitorIndex: 0,
|
||||
color: null,
|
||||
secondColor: null,
|
||||
shadingType: null,
|
||||
effects: Meta.BackgroundEffects.NONE });
|
||||
|
||||
let content = null;
|
||||
|
||||
let candidateContent = null;
|
||||
for (let i = 0; i < this._patterns.length; i++) {
|
||||
if (this._patterns[i].get_shading() != params.shadingType)
|
||||
continue;
|
||||
|
||||
if (!params.color.equal(this._patterns[i].get_color()))
|
||||
continue;
|
||||
|
||||
if (params.shadingType != GDesktopEnums.BackgroundShading.SOLID &&
|
||||
!params.secondColor.equal(this._patterns[i].get_second_color()))
|
||||
continue;
|
||||
|
||||
candidateContent = this._patterns[i];
|
||||
|
||||
if (params.effects != this._patterns[i].effects)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (candidateContent) {
|
||||
content = candidateContent.copy(params.monitorIndex, params.effects);
|
||||
} else {
|
||||
content = new Meta.Background({ meta_screen: global.screen,
|
||||
monitor: params.monitorIndex,
|
||||
effects: params.effects });
|
||||
|
||||
if (params.shadingType == GDesktopEnums.BackgroundShading.SOLID) {
|
||||
content.load_color(params.color);
|
||||
} else {
|
||||
content.load_gradient(params.shadingType, params.color, params.secondColor);
|
||||
}
|
||||
}
|
||||
|
||||
this._patterns.push(content);
|
||||
return content;
|
||||
},
|
||||
|
||||
_monitorFile: function(filename) {
|
||||
monitorFile: function(filename) {
|
||||
if (this._fileMonitors[filename])
|
||||
return;
|
||||
|
||||
let file = Gio.File.new_for_path(filename);
|
||||
let monitor = file.monitor(Gio.FileMonitorFlags.NONE, null);
|
||||
|
||||
let signalId = monitor.connect('changed',
|
||||
monitor.connect('changed',
|
||||
Lang.bind(this, function() {
|
||||
for (let i = 0; i < this._images.length; i++) {
|
||||
if (this._images[i].get_filename() == filename)
|
||||
this._images.splice(i, 1);
|
||||
}
|
||||
|
||||
monitor.disconnect(signalId);
|
||||
|
||||
this.emit('file-changed', filename);
|
||||
}));
|
||||
|
||||
this._fileMonitors[filename] = monitor;
|
||||
},
|
||||
|
||||
_removeContent: function(contentList, content) {
|
||||
let index = contentList.indexOf(content);
|
||||
if (index < 0)
|
||||
throw new Error("Trying to remove invalid content: " + content);
|
||||
contentList.splice(index, 1);
|
||||
},
|
||||
|
||||
removePatternContent: function(content) {
|
||||
this._removeContent(this._patterns, content);
|
||||
},
|
||||
|
||||
removeImageContent: function(content) {
|
||||
let filename = content.get_filename();
|
||||
|
||||
let hasOtherUsers = this._images.some(function(content) { return filename == content.get_filename(); });
|
||||
if (!hasOtherUsers)
|
||||
delete this._fileMonitors[filename];
|
||||
|
||||
this._removeContent(this._images, content);
|
||||
},
|
||||
|
||||
_attachCallerToFileLoad: function(caller, fileLoad) {
|
||||
fileLoad.callers.push(caller);
|
||||
|
||||
if (!caller.cancellable)
|
||||
return;
|
||||
|
||||
caller.cancellable.connect(Lang.bind(this, function() {
|
||||
let idx = fileLoad.callers.indexOf(caller);
|
||||
fileLoad.callers.splice(idx, 1);
|
||||
|
||||
if (fileLoad.callers.length == 0) {
|
||||
fileLoad.cancellable.cancel();
|
||||
|
||||
let idx = this._pendingFileLoads.indexOf(fileLoad);
|
||||
this._pendingFileLoads.splice(idx, 1);
|
||||
}
|
||||
}));
|
||||
},
|
||||
|
||||
_loadImageContent: function(params) {
|
||||
params = Params.parse(params, { monitorIndex: 0,
|
||||
style: null,
|
||||
filename: null,
|
||||
effects: Meta.BackgroundEffects.NONE,
|
||||
cancellable: null,
|
||||
onFinished: null });
|
||||
|
||||
let caller = { monitorIndex: params.monitorIndex,
|
||||
effects: params.effects,
|
||||
cancellable: params.cancellable,
|
||||
onFinished: params.onFinished };
|
||||
|
||||
for (let i = 0; i < this._pendingFileLoads.length; i++) {
|
||||
let fileLoad = this._pendingFileLoads[i];
|
||||
|
||||
if (fileLoad.filename == params.filename &&
|
||||
fileLoad.style == params.style) {
|
||||
this._attachCallerToFileLoad(caller, fileLoad);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let fileLoad = { filename: params.filename,
|
||||
style: params.style,
|
||||
cancellable: new Gio.Cancellable(),
|
||||
callers: [] };
|
||||
this._attachCallerToFileLoad(caller, fileLoad);
|
||||
|
||||
let content = new Meta.Background({ meta_screen: global.screen });
|
||||
|
||||
content.load_file_async(params.filename,
|
||||
params.style,
|
||||
params.cancellable,
|
||||
Lang.bind(this,
|
||||
function(object, result) {
|
||||
try {
|
||||
content.load_file_finish(result);
|
||||
|
||||
this._monitorFile(params.filename);
|
||||
} catch(e) {
|
||||
content = null;
|
||||
}
|
||||
|
||||
for (let i = 0; i < fileLoad.callers.length; i++) {
|
||||
let caller = fileLoad.callers[i];
|
||||
if (caller.onFinished) {
|
||||
let newContent;
|
||||
|
||||
if (content) {
|
||||
newContent = content.copy(caller.monitorIndex, caller.effects);
|
||||
this._images.push(newContent);
|
||||
}
|
||||
|
||||
caller.onFinished(newContent);
|
||||
}
|
||||
}
|
||||
|
||||
let idx = this._pendingFileLoads.indexOf(fileLoad);
|
||||
this._pendingFileLoads.splice(idx, 1);
|
||||
}));
|
||||
},
|
||||
|
||||
getImageContent: function(params) {
|
||||
params = Params.parse(params, { monitorIndex: 0,
|
||||
style: null,
|
||||
filename: null,
|
||||
effects: Meta.BackgroundEffects.NONE,
|
||||
cancellable: null,
|
||||
onFinished: null });
|
||||
|
||||
let content = null;
|
||||
|
||||
let candidateContent = null;
|
||||
for (let i = 0; i < this._images.length; i++) {
|
||||
if (this._images[i].get_style() != params.style)
|
||||
continue;
|
||||
|
||||
if (this._images[i].get_filename() != params.filename)
|
||||
continue;
|
||||
|
||||
if (params.style == GDesktopEnums.BackgroundStyle.SPANNED &&
|
||||
this._images[i].monitor != params.monitorIndex)
|
||||
continue;
|
||||
|
||||
candidateContent = this._images[i];
|
||||
|
||||
if (params.effects != this._images[i].effects)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (candidateContent) {
|
||||
content = candidateContent.copy(params.monitorIndex, params.effects);
|
||||
|
||||
if (params.cancellable && params.cancellable.is_cancelled())
|
||||
content = null;
|
||||
else
|
||||
this._images.push(content);
|
||||
|
||||
if (params.onFinished)
|
||||
params.onFinished(content);
|
||||
} else {
|
||||
this._loadImageContent({ filename: params.filename,
|
||||
style: params.style,
|
||||
effects: params.effects,
|
||||
monitorIndex: params.monitorIndex,
|
||||
cancellable: params.cancellable,
|
||||
onFinished: params.onFinished });
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
getAnimation: function(params) {
|
||||
params = Params.parse(params, { filename: null,
|
||||
onLoaded: null });
|
||||
@@ -282,7 +165,6 @@ const BackgroundCache = new Lang.Class({
|
||||
let animation = new Animation({ filename: params.filename });
|
||||
|
||||
animation.load(Lang.bind(this, function() {
|
||||
this._monitorFile(params.filename);
|
||||
this._animationFilename = params.filename;
|
||||
this._animation = animation;
|
||||
|
||||
@@ -294,6 +176,31 @@ const BackgroundCache = new Lang.Class({
|
||||
GLib.Source.set_name_by_id(id, '[gnome-shell] params.onLoaded');
|
||||
}
|
||||
}));
|
||||
},
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Signals.addSignalMethods(BackgroundCache.prototype);
|
||||
@@ -310,28 +217,19 @@ const Background = new Lang.Class({
|
||||
_init: function(params) {
|
||||
params = Params.parse(params, { monitorIndex: 0,
|
||||
layoutManager: Main.layoutManager,
|
||||
effects: Meta.BackgroundEffects.NONE,
|
||||
settings: null,
|
||||
overrideImage: null });
|
||||
this.actor = new Meta.BackgroundGroup();
|
||||
this.actor._delegate = this;
|
||||
filename: null,
|
||||
style: null });
|
||||
|
||||
this._destroySignalId = this.actor.connect('destroy',
|
||||
Lang.bind(this, this._destroy));
|
||||
this.background = new Meta.Background({ meta_screen: global.screen });
|
||||
this.background._delegate = this;
|
||||
|
||||
this._settings = params.settings;
|
||||
this._overrideImage = params.overrideImage;
|
||||
this._filename = params.filename;
|
||||
this._style = params.style;
|
||||
this._monitorIndex = params.monitorIndex;
|
||||
this._layoutManager = params.layoutManager;
|
||||
this._effects = params.effects;
|
||||
this._fileWatches = {};
|
||||
this._pattern = null;
|
||||
// contains a single image for static backgrounds and
|
||||
// two images (from and to) for slide shows
|
||||
this._images = {};
|
||||
|
||||
this._brightness = 1.0;
|
||||
this._vignetteSharpness = 0.2;
|
||||
this._cancellable = new Gio.Cancellable();
|
||||
this.isLoaded = false;
|
||||
|
||||
@@ -342,7 +240,7 @@ const Background = new Lang.Class({
|
||||
this._load();
|
||||
},
|
||||
|
||||
_destroy: function() {
|
||||
destroy: function() {
|
||||
this._cancellable.cancel();
|
||||
|
||||
if (this._updateAnimationTimeoutId) {
|
||||
@@ -357,28 +255,6 @@ const Background = new Lang.Class({
|
||||
}
|
||||
this._fileWatches = null;
|
||||
|
||||
if (this._pattern) {
|
||||
if (this._pattern.content)
|
||||
this._cache.removePatternContent(this._pattern.content);
|
||||
|
||||
this._pattern.destroy();
|
||||
this._pattern = null;
|
||||
}
|
||||
|
||||
keys = Object.keys(this._images);
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
let actor = this._images[keys[i]];
|
||||
|
||||
if (actor.content)
|
||||
this._cache.removeImageContent(actor.content);
|
||||
|
||||
actor.destroy();
|
||||
this._images[keys[i]] = null;
|
||||
}
|
||||
|
||||
this.actor.disconnect(this._destroySignalId);
|
||||
this._destroySignalId = 0;
|
||||
|
||||
if (this._settingsChangedSignalId != 0)
|
||||
this._settings.disconnect(this._settingsChangedSignalId);
|
||||
this._settingsChangedSignalId = 0;
|
||||
@@ -407,22 +283,17 @@ const Background = new Lang.Class({
|
||||
|
||||
let shadingType = this._settings.get_enum(COLOR_SHADING_TYPE_KEY);
|
||||
|
||||
let content = this._cache.getPatternContent({ monitorIndex: this._monitorIndex,
|
||||
effects: this._effects,
|
||||
color: color,
|
||||
secondColor: secondColor,
|
||||
shadingType: shadingType });
|
||||
|
||||
this._pattern = new Meta.BackgroundActor();
|
||||
this.actor.add_child(this._pattern);
|
||||
|
||||
this._pattern.content = content;
|
||||
if (shadingType == GDesktopEnums.BackgroundShading.SOLID)
|
||||
this.background.set_color(color);
|
||||
else
|
||||
this.background.set_gradient(shadingType, color, secondColor);
|
||||
},
|
||||
|
||||
_watchCacheFile: function(filename) {
|
||||
_watchFile: function(filename) {
|
||||
if (this._fileWatches[filename])
|
||||
return;
|
||||
|
||||
this._cache.monitorFile(filename);
|
||||
let signalId = this._cache.connect('file-changed',
|
||||
Lang.bind(this, function(cache, changedFile) {
|
||||
if (changedFile == filename) {
|
||||
@@ -432,82 +303,46 @@ const Background = new Lang.Class({
|
||||
this._fileWatches[filename] = signalId;
|
||||
},
|
||||
|
||||
_ensureImage: function(index) {
|
||||
if (this._images[index])
|
||||
return;
|
||||
|
||||
let actor = new Meta.BackgroundActor();
|
||||
|
||||
// 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;
|
||||
},
|
||||
|
||||
_updateImage: function(index, content, filename) {
|
||||
content.brightness = this._brightness;
|
||||
content.vignette_sharpness = this._vignetteSharpness;
|
||||
|
||||
let image = this._images[index];
|
||||
if (image.content)
|
||||
this._cache.removeImageContent(image.content);
|
||||
image.content = content;
|
||||
this._watchCacheFile(filename);
|
||||
},
|
||||
|
||||
_updateAnimationProgress: function() {
|
||||
if (this._images[1])
|
||||
this._images[1].opacity = this._animation.transitionProgress * 255;
|
||||
|
||||
this._queueUpdateAnimation();
|
||||
},
|
||||
|
||||
_updateAnimation: function() {
|
||||
this._updateAnimationTimeoutId = 0;
|
||||
|
||||
this._animation.update(this._layoutManager.monitors[this._monitorIndex]);
|
||||
let files = this._animation.keyFrameFiles;
|
||||
|
||||
if (files.length == 0) {
|
||||
let finish = Lang.bind(this, function() {
|
||||
this._setLoaded();
|
||||
if (files.length > 1) {
|
||||
this.background.set_blend(files[0], files[1],
|
||||
this._animation.transitionProgress,
|
||||
this._style);
|
||||
} else if (files.length > 0) {
|
||||
this.background.set_filename(files[0], this._style);
|
||||
} else {
|
||||
this.background.set_filename(null, this._style);
|
||||
}
|
||||
this._queueUpdateAnimation();
|
||||
return;
|
||||
}
|
||||
|
||||
let numPendingImages = files.length;
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
if (this._images[i] && this._images[i].content &&
|
||||
this._images[i].content.get_filename() == files[i]) {
|
||||
|
||||
numPendingImages--;
|
||||
if (numPendingImages == 0)
|
||||
this._updateAnimationProgress();
|
||||
continue;
|
||||
}
|
||||
this._cache.getImageContent({ monitorIndex: this._monitorIndex,
|
||||
effects: this._effects,
|
||||
style: this._style,
|
||||
filename: files[i],
|
||||
cancellable: this._cancellable,
|
||||
onFinished: Lang.bind(this, function(content, i) {
|
||||
numPendingImages--;
|
||||
|
||||
if (!content) {
|
||||
this._setLoaded();
|
||||
if (numPendingImages == 0)
|
||||
this._updateAnimationProgress();
|
||||
return;
|
||||
}
|
||||
|
||||
this._ensureImage(i);
|
||||
this._updateImage(i, content, files[i]);
|
||||
|
||||
if (numPendingImages == 0) {
|
||||
this._setLoaded();
|
||||
this._updateAnimationProgress();
|
||||
}
|
||||
}, i)
|
||||
});
|
||||
|
||||
let cache = Meta.BackgroundImageCache.get_default();
|
||||
let numPendingImages = files.length;
|
||||
let images = [];
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
this._watchFile(files[i]);
|
||||
let image = cache.load(files[i]);
|
||||
images.push(image);
|
||||
if (image.is_loaded()) {
|
||||
numPendingImages--;
|
||||
if (numPendingImages == 0)
|
||||
finish();
|
||||
} else {
|
||||
let id = image.connect('loaded',
|
||||
Lang.bind(this, function() {
|
||||
image.disconnect(id);
|
||||
numPendingImages--;
|
||||
if (numPendingImages == 0)
|
||||
finish();
|
||||
}));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -551,25 +386,26 @@ const Background = new Lang.Class({
|
||||
}
|
||||
|
||||
this._updateAnimation();
|
||||
this._watchCacheFile(filename);
|
||||
this._watchFile(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) {
|
||||
this._ensureImage(0);
|
||||
this._updateImage(0, content, filename);
|
||||
}
|
||||
this.background.set_filename(filename, this._style);
|
||||
this._watchFile(filename);
|
||||
|
||||
let cache = Meta.BackgroundImageCache.get_default();
|
||||
let image = cache.load(filename);
|
||||
if (image.is_loaded())
|
||||
this._setLoaded();
|
||||
})
|
||||
});
|
||||
else {
|
||||
let id = image.connect('loaded',
|
||||
Lang.bind(this, function() {
|
||||
this._setLoaded();
|
||||
image.disconnect(id);
|
||||
}));
|
||||
}
|
||||
},
|
||||
|
||||
_loadFile: function(filename) {
|
||||
@@ -584,95 +420,118 @@ const Background = new Lang.Class({
|
||||
|
||||
this._loadPattern();
|
||||
|
||||
let filename;
|
||||
if (this._overrideImage != null) {
|
||||
filename = this._overrideImage;
|
||||
this._style = GDesktopEnums.BackgroundStyle.ZOOM; // Hardcode
|
||||
} else {
|
||||
this._style = this._settings.get_enum(BACKGROUND_STYLE_KEY);
|
||||
if (this._style == GDesktopEnums.BackgroundStyle.NONE) {
|
||||
if (!this._filename) {
|
||||
this._setLoaded();
|
||||
return;
|
||||
}
|
||||
|
||||
this._loadFile(this._filename);
|
||||
},
|
||||
});
|
||||
Signals.addSignalMethods(Background.prototype);
|
||||
|
||||
let _systemBackground;
|
||||
|
||||
const SystemBackground = new Lang.Class({
|
||||
Name: 'SystemBackground',
|
||||
|
||||
_init: function() {
|
||||
let filename = global.datadir + '/theme/noise-texture.png';
|
||||
|
||||
if (_systemBackground == null) {
|
||||
_systemBackground = new Meta.Background({ meta_screen: global.screen });
|
||||
_systemBackground.set_filename(filename, GDesktopEnums.BackgroundStyle.WALLPAPER);
|
||||
}
|
||||
|
||||
this.actor = new Meta.BackgroundActor({ meta_screen: global.screen,
|
||||
monitor: 0,
|
||||
background: _systemBackground });
|
||||
|
||||
let cache = Meta.BackgroundImageCache.get_default();
|
||||
let image = cache.load(filename);
|
||||
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;
|
||||
}));
|
||||
}
|
||||
},
|
||||
});
|
||||
Signals.addSignalMethods(SystemBackground.prototype);
|
||||
|
||||
const BackgroundSource = new Lang.Class({
|
||||
Name: 'BackgroundSource',
|
||||
|
||||
_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 = [];
|
||||
},
|
||||
|
||||
getBackground: function(monitorIndex) {
|
||||
let filename = null;
|
||||
let style;
|
||||
|
||||
if (this._overrideImage != null) {
|
||||
filename = this._overrideImage;
|
||||
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);
|
||||
if (GLib.uri_parse_scheme(uri) != null)
|
||||
filename = Gio.File.new_for_uri(uri).get_path();
|
||||
else
|
||||
filename = uri;
|
||||
}
|
||||
|
||||
if (!filename) {
|
||||
this._setLoaded();
|
||||
return;
|
||||
}
|
||||
|
||||
this._loadFile(filename);
|
||||
},
|
||||
// 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.
|
||||
if (filename == null || !filename.endsWith('.xml'))
|
||||
monitorIndex = 0;
|
||||
|
||||
get brightness() {
|
||||
return this._brightness;
|
||||
},
|
||||
|
||||
set brightness(factor) {
|
||||
this._brightness = factor;
|
||||
if (this._pattern && this._pattern.content)
|
||||
this._pattern.content.brightness = factor;
|
||||
|
||||
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.brightness = factor;
|
||||
}
|
||||
},
|
||||
|
||||
get vignetteSharpness() {
|
||||
return this._vignetteSharpness;
|
||||
},
|
||||
|
||||
set vignetteSharpness(sharpness) {
|
||||
this._vignetteSharpness = sharpness;
|
||||
if (this._pattern && this._pattern.content)
|
||||
this._pattern.content.vignette_sharpness = sharpness;
|
||||
|
||||
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.vignette_sharpness = sharpness;
|
||||
}
|
||||
}
|
||||
});
|
||||
Signals.addSignalMethods(Background.prototype);
|
||||
|
||||
const SystemBackground = new Lang.Class({
|
||||
Name: 'SystemBackground',
|
||||
|
||||
_init: function() {
|
||||
this._cache = getBackgroundCache();
|
||||
this.actor = new Meta.BackgroundActor();
|
||||
|
||||
this._cache.getImageContent({ style: GDesktopEnums.BackgroundStyle.WALLPAPER,
|
||||
filename: global.datadir + '/theme/noise-texture.png',
|
||||
effects: Meta.BackgroundEffects.NONE,
|
||||
onFinished: Lang.bind(this, function(content) {
|
||||
this.actor.content = content;
|
||||
this.emit('loaded');
|
||||
})
|
||||
if (!(monitorIndex in this._backgrounds)) {
|
||||
let background = new Background({
|
||||
monitorIndex: monitorIndex,
|
||||
layoutManager: this._layoutManager,
|
||||
settings: this._settings,
|
||||
filename: filename,
|
||||
style: style
|
||||
});
|
||||
|
||||
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||
let changedId = background.connect('changed', Lang.bind(this, function() {
|
||||
background.disconnect(changedId);
|
||||
background.destroy();
|
||||
delete this._backgrounds[monitorIndex];
|
||||
}));
|
||||
|
||||
this._backgrounds[monitorIndex] = background;
|
||||
}
|
||||
|
||||
return this._backgrounds[monitorIndex];
|
||||
},
|
||||
|
||||
_onDestroy: function() {
|
||||
let content = this.actor.content;
|
||||
destroy: function() {
|
||||
for (let monitorIndex in this._backgrounds)
|
||||
this._backgrounds[monitorIndex].destroy();
|
||||
|
||||
if (content)
|
||||
this._cache.removeImageContent(content);
|
||||
},
|
||||
this._backgrounds = null;
|
||||
}
|
||||
});
|
||||
Signals.addSignalMethods(SystemBackground.prototype);
|
||||
|
||||
const Animation = new Lang.Class({
|
||||
Name: 'Animation',
|
||||
@@ -731,100 +590,121 @@ const BackgroundManager = new Lang.Class({
|
||||
params = Params.parse(params, { container: null,
|
||||
layoutManager: Main.layoutManager,
|
||||
monitorIndex: null,
|
||||
effects: Meta.BackgroundEffects.NONE,
|
||||
vignette: false,
|
||||
controlPosition: true,
|
||||
settingsSchema: BACKGROUND_SCHEMA });
|
||||
|
||||
// Allow override the background image setting for performance testing
|
||||
this._overrideImage = GLib.getenv('SHELL_BACKGROUND_IMAGE');
|
||||
this._settings = new Gio.Settings({ schema_id: params.settingsSchema });
|
||||
let cache = getBackgroundCache();
|
||||
this._settingsSchema = params.settingsSchema;
|
||||
this._backgroundSource = cache.getBackgroundSource(params.layoutManager, params.settingsSchema);
|
||||
|
||||
this._container = params.container;
|
||||
this._layoutManager = params.layoutManager;
|
||||
this._effects = params.effects;
|
||||
this._vignette = params.vignette;
|
||||
this._monitorIndex = params.monitorIndex;
|
||||
this._controlPosition = params.controlPosition;
|
||||
|
||||
this.background = this._createBackground();
|
||||
this._newBackground = null;
|
||||
this.backgroundActor = this._createBackgroundActor();
|
||||
this._newBackgroundActor = null;
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
if (this._newBackground) {
|
||||
this._newBackground.actor.destroy();
|
||||
this._newBackground = null;
|
||||
let cache = getBackgroundCache();
|
||||
cache.releaseBackgroundSource(this._settingsSchema);
|
||||
this._backgroundSource = null;
|
||||
|
||||
if (this._newBackgroundActor) {
|
||||
this._newBackgroundActor.destroy();
|
||||
this._newBackgroundActor = null;
|
||||
}
|
||||
|
||||
if (this.background) {
|
||||
this.background.actor.destroy();
|
||||
this.background = null;
|
||||
if (this.backgroundActor) {
|
||||
this.backgroundActor.destroy();
|
||||
this.backgroundActor = null;
|
||||
}
|
||||
},
|
||||
|
||||
_updateBackground: function() {
|
||||
let newBackground = this._createBackground();
|
||||
newBackground.vignetteSharpness = this.background.vignetteSharpness;
|
||||
newBackground.brightness = this.background.brightness;
|
||||
newBackground.visible = this.background.visible;
|
||||
_swapBackgroundActor: function() {
|
||||
let oldBackgroundActor = this.backgroundActor;
|
||||
this.backgroundActor = this._newBackgroundActor;
|
||||
this._newBackgroundActor = null;
|
||||
this.emit('changed');
|
||||
|
||||
newBackground.loadedSignalId = newBackground.connect('loaded',
|
||||
Lang.bind(this, function() {
|
||||
newBackground.disconnect(newBackground.loadedSignalId);
|
||||
newBackground.loadedSignalId = 0;
|
||||
|
||||
if (this._newBackground != newBackground) {
|
||||
/* Not interesting, we queued another load */
|
||||
newBackground.actor.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
Tweener.addTween(this.background.actor,
|
||||
Tweener.addTween(oldBackgroundActor,
|
||||
{ opacity: 0,
|
||||
time: FADE_ANIMATION_TIME,
|
||||
transition: 'easeOutQuad',
|
||||
onComplete: Lang.bind(this, function() {
|
||||
this.background.actor.destroy();
|
||||
this.background = newBackground;
|
||||
this._newBackground = null;
|
||||
|
||||
this.emit('changed');
|
||||
})
|
||||
onComplete: function() {
|
||||
oldBackgroundActor.destroy();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
this._newBackground = newBackground;
|
||||
},
|
||||
|
||||
_createBackground: function() {
|
||||
let background = new Background({ monitorIndex: this._monitorIndex,
|
||||
layoutManager: this._layoutManager,
|
||||
effects: this._effects,
|
||||
settings: this._settings,
|
||||
overrideImage: this._overrideImage });
|
||||
this._container.add_child(background.actor);
|
||||
_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);
|
||||
|
||||
let monitor = this._layoutManager.monitors[this._monitorIndex];
|
||||
|
||||
background.actor.set_size(monitor.width, monitor.height);
|
||||
backgroundActor.set_size(monitor.width, monitor.height);
|
||||
if (this._controlPosition) {
|
||||
background.actor.set_position(monitor.x, monitor.y);
|
||||
background.actor.lower_bottom();
|
||||
backgroundActor.set_position(monitor.x, monitor.y);
|
||||
backgroundActor.lower_bottom();
|
||||
}
|
||||
|
||||
background.changeSignalId = background.connect('changed', Lang.bind(this, function() {
|
||||
background.disconnect(background.changeSignalId);
|
||||
background.changeSignalId = 0;
|
||||
this._updateBackground();
|
||||
let changeSignalId = background.connect('changed', Lang.bind(this, function() {
|
||||
background.disconnect(changeSignalId);
|
||||
changeSignalId = null;
|
||||
this._updateBackgroundActor();
|
||||
}));
|
||||
|
||||
background.actor.connect('destroy', Lang.bind(this, function() {
|
||||
if (background.changeSignalId)
|
||||
background.disconnect(background.changeSignalId);
|
||||
backgroundActor.connect('destroy', Lang.bind(this, function() {
|
||||
if (changeSignalId)
|
||||
background.disconnect(changeSignalId);
|
||||
|
||||
if (background.loadedSignalId)
|
||||
background.disconnect(background.loadedSignalId);
|
||||
if (backgroundActor.loadedSignalId)
|
||||
backgroundActor.background._delegate.disconnect(backgroundActor.loadedSignalId);
|
||||
}));
|
||||
|
||||
return background;
|
||||
return backgroundActor;
|
||||
},
|
||||
});
|
||||
Signals.addSignalMethods(BackgroundManager.prototype);
|
||||
|
@@ -361,7 +361,7 @@ const LayoutManager = new Lang.Class({
|
||||
},
|
||||
|
||||
_addBackgroundMenu: function(bgManager) {
|
||||
BackgroundMenu.addBackgroundMenu(bgManager.background.actor, this);
|
||||
BackgroundMenu.addBackgroundMenu(bgManager.backgroundActor, this);
|
||||
},
|
||||
|
||||
_createBackgroundManager: function(monitorIndex) {
|
||||
@@ -378,10 +378,10 @@ const LayoutManager = new Lang.Class({
|
||||
_showSecondaryBackgrounds: function() {
|
||||
for (let i = 0; i < this.monitors.length; i++) {
|
||||
if (i != this.primaryIndex) {
|
||||
let background = this._bgManagers[i].background;
|
||||
background.actor.show();
|
||||
background.actor.opacity = 0;
|
||||
Tweener.addTween(background.actor,
|
||||
let backgroundActor = this._bgManagers[i].backgroundActor;
|
||||
backgroundActor.show();
|
||||
backgroundActor.opacity = 0;
|
||||
Tweener.addTween(backgroundActor,
|
||||
{ opacity: 255,
|
||||
time: BACKGROUND_FADE_ANIMATION_TIME,
|
||||
transition: 'easeOutQuad' });
|
||||
@@ -404,7 +404,7 @@ const LayoutManager = new Lang.Class({
|
||||
this._bgManagers.push(bgManager);
|
||||
|
||||
if (i != this.primaryIndex && this._startingUp)
|
||||
bgManager.background.actor.hide();
|
||||
bgManager.backgroundActor.hide();
|
||||
}
|
||||
},
|
||||
|
||||
|
@@ -185,7 +185,7 @@ const Overview = new Lang.Class({
|
||||
for (let i = 0; i < Main.layoutManager.monitors.length; i++) {
|
||||
let bgManager = new Background.BackgroundManager({ container: this._backgroundGroup,
|
||||
monitorIndex: i,
|
||||
effects: Meta.BackgroundEffects.VIGNETTE });
|
||||
vignette: true });
|
||||
this._bgManagers.push(bgManager);
|
||||
}
|
||||
},
|
||||
@@ -193,11 +193,9 @@ const Overview = new Lang.Class({
|
||||
_unshadeBackgrounds: function() {
|
||||
let backgrounds = this._backgroundGroup.get_children();
|
||||
for (let i = 0; i < backgrounds.length; i++) {
|
||||
let background = backgrounds[i]._delegate;
|
||||
|
||||
Tweener.addTween(background,
|
||||
Tweener.addTween(backgrounds[i],
|
||||
{ brightness: 1.0,
|
||||
vignetteSharpness: 0.0,
|
||||
vignette_sharpness: 0.0,
|
||||
time: SHADE_ANIMATION_TIME,
|
||||
transition: 'easeOutQuad'
|
||||
});
|
||||
@@ -207,11 +205,9 @@ const Overview = new Lang.Class({
|
||||
_shadeBackgrounds: function() {
|
||||
let backgrounds = this._backgroundGroup.get_children();
|
||||
for (let i = 0; i < backgrounds.length; i++) {
|
||||
let background = backgrounds[i]._delegate;
|
||||
|
||||
Tweener.addTween(background,
|
||||
Tweener.addTween(backgrounds[i],
|
||||
{ brightness: Lightbox.VIGNETTE_BRIGHTNESS,
|
||||
vignetteSharpness: Lightbox.VIGNETTE_SHARPNESS,
|
||||
vignette_sharpness: Lightbox.VIGNETTE_SHARPNESS,
|
||||
time: SHADE_ANIMATION_TIME,
|
||||
transition: 'easeOutQuad'
|
||||
});
|
||||
|
@@ -922,8 +922,10 @@ const PopupSubMenu = new Lang.Class({
|
||||
let [minHeight, naturalHeight] = this.actor.get_preferred_height(-1);
|
||||
this.actor.height = 0;
|
||||
this.actor._arrowRotation = this._arrow.rotation_angle_z;
|
||||
let angle = this.actor._arrowRotation;
|
||||
// animate to the first multiple of 90 greater than current angle
|
||||
Tweener.addTween(this.actor,
|
||||
{ _arrowRotation: this.actor._arrowRotation + 90,
|
||||
{ _arrowRotation: angle - angle % 90 + 90,
|
||||
height: naturalHeight,
|
||||
time: 0.25,
|
||||
onUpdateScope: this,
|
||||
@@ -955,8 +957,10 @@ const PopupSubMenu = new Lang.Class({
|
||||
|
||||
if (animate) {
|
||||
this.actor._arrowRotation = this._arrow.rotation_angle_z;
|
||||
let angle = this.actor._arrowRotation;
|
||||
// animate to the first multiple of 90 less than current angle
|
||||
Tweener.addTween(this.actor,
|
||||
{ _arrowRotation: this.actor._arrowRotation - 90,
|
||||
{ _arrowRotation: (angle - 1) - (angle - 1) % 90,
|
||||
height: 0,
|
||||
time: 0.25,
|
||||
onUpdateScope: this,
|
||||
|
@@ -17,6 +17,7 @@ const Main = imports.ui.main;
|
||||
const ModalDialog = imports.ui.modalDialog;
|
||||
const Tweener = imports.ui.tweener;
|
||||
const WindowMenu = imports.ui.windowMenu;
|
||||
const Wobbly = imports.ui.wobbly;
|
||||
|
||||
const SHELL_KEYBINDINGS_SCHEMA = 'org.gnome.shell.keybindings';
|
||||
const MAXIMIZE_WINDOW_ANIMATION_TIME = 0.15;
|
||||
@@ -811,6 +812,8 @@ const WindowManager = new Lang.Class({
|
||||
gesture = new AppSwitchAction();
|
||||
gesture.connect('activated', Lang.bind(this, this._switchApp));
|
||||
global.stage.add_action(gesture);
|
||||
|
||||
this._wobblyWindows = new Wobbly.WobblyWindowManager();
|
||||
},
|
||||
|
||||
_lookupIndex: function (windows, metaWindow) {
|
||||
|
130
js/ui/wobbly.js
Normal file
130
js/ui/wobbly.js
Normal file
@@ -0,0 +1,130 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Lang = imports.lang;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Shell = imports.gi.Shell;
|
||||
|
||||
function clampAbs(v, cap) {
|
||||
if (v > cap)
|
||||
v = cap;
|
||||
if (v < -cap)
|
||||
v = -cap;
|
||||
return v;
|
||||
}
|
||||
|
||||
const ActorWobbler = new Lang.Class({
|
||||
Name: 'ActorWobbler',
|
||||
|
||||
_init: function(actor) {
|
||||
this._actor = actor;
|
||||
this._effect = new Shell.WobblyEffect();
|
||||
this._actor.add_effect(this._effect);
|
||||
this._actor._wobbler = this;
|
||||
|
||||
this._currentBend = 0;
|
||||
this._currentHeightOffset = 0;
|
||||
this._running = false;
|
||||
|
||||
this._allocationChangedId = this._actor.connect('allocation-changed', Lang.bind(this, this._allocationChanged));
|
||||
|
||||
this._timeline = new Clutter.Timeline({ duration: 100, repeat_count: -1 });
|
||||
this._timeline.connect('new-frame', Lang.bind(this, this._newFrame));
|
||||
this._timeline.start();
|
||||
},
|
||||
|
||||
start: function() {
|
||||
this._running = true;
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
this._running = false;
|
||||
},
|
||||
|
||||
_destroy: function() {
|
||||
this._timeline.run_dispose();
|
||||
this._timeline = null;
|
||||
|
||||
this._actor.disconnect(this._allocationChangedId);
|
||||
this._actor.scale_y = 1.0;
|
||||
this._actor.remove_effect(this._effect);
|
||||
this._actor._wobbler = null;
|
||||
},
|
||||
|
||||
_newFrame: function() {
|
||||
this._step();
|
||||
},
|
||||
|
||||
_step: function() {
|
||||
const DAMPEN = 0.8;
|
||||
this._currentBend *= DAMPEN;
|
||||
if (Math.abs(this._currentBend) < 1)
|
||||
this._currentBend = 0;
|
||||
this._currentHeightOffset *= DAMPEN;
|
||||
if (Math.abs(this._currentHeightOffset) < 1)
|
||||
this._currentHeightOffset = 0;
|
||||
|
||||
// Cap the bend to a 100px shift.
|
||||
const BEND_CAP = 50;
|
||||
this._currentBend = clampAbs(this._currentBend, BEND_CAP);
|
||||
this._effect.set_bend_x(this._currentBend);
|
||||
|
||||
// Cap the height change to 25px in either direction.
|
||||
const HEIGHT_OFFSET_CAP = 25;
|
||||
this._currentHeightOffset = clampAbs(this._currentHeightOffset, HEIGHT_OFFSET_CAP);
|
||||
let [minHeight, natHeight] = this._actor.get_preferred_height(-1);
|
||||
let scale = (natHeight + this._currentHeightOffset) / natHeight;
|
||||
this._actor.scale_y = scale;
|
||||
|
||||
if (!this._running && this._currentBend == 0 && this._currentHeightOffset == 0)
|
||||
this._destroy();
|
||||
},
|
||||
|
||||
_allocationChanged: function(actor, box, flags) {
|
||||
if (!this._running)
|
||||
return;
|
||||
|
||||
if (this._oldX) {
|
||||
let deltaX = box.x1 - this._oldX;
|
||||
// Every 2px the user moves the window, we bend it by 1px.
|
||||
this._currentBend -= deltaX / 2;
|
||||
}
|
||||
|
||||
if (this._oldY) {
|
||||
let deltaY = box.y1 - this._oldY;
|
||||
// Every 2px the user moves the window, we scale it by 1px.
|
||||
this._currentHeightOffset -= deltaY / 2;
|
||||
}
|
||||
|
||||
this._oldX = box.x1;
|
||||
this._oldY = box.y1;
|
||||
},
|
||||
});
|
||||
|
||||
const WobblyWindowManager = new Lang.Class({
|
||||
Name: 'WobblyWindowManager',
|
||||
|
||||
_init: function() {
|
||||
global.display.connect('grab-op-begin', Lang.bind(this, this._grabOpBegin));
|
||||
global.display.connect('grab-op-end', Lang.bind(this, this._grabOpEnd));
|
||||
},
|
||||
|
||||
_grabOpBegin: function(display, screen, window, op) {
|
||||
if (op != Meta.GrabOp.MOVING)
|
||||
return;
|
||||
|
||||
let actor = window.get_compositor_private();
|
||||
if (!actor._wobbler)
|
||||
new ActorWobbler(actor);
|
||||
actor._wobbler.start();
|
||||
},
|
||||
|
||||
_grabOpEnd: function(display, screen, window, op) {
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
let actor = window.get_compositor_private();
|
||||
if (actor._wobbler)
|
||||
actor._wobbler.stop();
|
||||
},
|
||||
});
|
@@ -306,7 +306,7 @@ const WorkspaceThumbnail = new Lang.Class({
|
||||
_createBackground: function() {
|
||||
this._bgManager = new Background.BackgroundManager({ monitorIndex: Main.layoutManager.primaryIndex,
|
||||
container: this._contents,
|
||||
effects: Meta.BackgroundEffects.NONE });
|
||||
vignette: false });
|
||||
},
|
||||
|
||||
setPorthole: function(x, y, width, height) {
|
||||
@@ -332,7 +332,7 @@ const WorkspaceThumbnail = new Lang.Class({
|
||||
let clone = this._windows[i];
|
||||
let metaWindow = clone.metaWindow;
|
||||
if (i == 0) {
|
||||
clone.setStackAbove(this._bgManager.background.actor);
|
||||
clone.setStackAbove(this._bgManager.backgroundActor);
|
||||
} else {
|
||||
let previousClone = this._windows[i - 1];
|
||||
clone.setStackAbove(previousClone.actor);
|
||||
@@ -531,7 +531,7 @@ const WorkspaceThumbnail = new Lang.Class({
|
||||
this._contents.add_actor(clone.actor);
|
||||
|
||||
if (this._windows.length == 0)
|
||||
clone.setStackAbove(this._bgManager.background.actor);
|
||||
clone.setStackAbove(this._bgManager.backgroundActor);
|
||||
else
|
||||
clone.setStackAbove(this._windows[this._windows.length - 1].actor);
|
||||
|
||||
|
@@ -102,6 +102,7 @@ shell_public_headers_h = \
|
||||
shell-util.h \
|
||||
shell-window-tracker.h \
|
||||
shell-wm.h \
|
||||
shell-wobbly-effect.h \
|
||||
$(NULL)
|
||||
|
||||
if HAVE_NETWORKMANAGER
|
||||
@@ -167,6 +168,7 @@ libgnome_shell_sources = \
|
||||
shell-util.c \
|
||||
shell-window-tracker.c \
|
||||
shell-wm.c \
|
||||
shell-wobbly-effect.c \
|
||||
$(NULL)
|
||||
|
||||
libgnome_shell_built_sources = \
|
||||
|
@@ -260,6 +260,8 @@ shell_perf_log_init (void)
|
||||
static void
|
||||
shell_a11y_init (void)
|
||||
{
|
||||
cally_accessibility_init ();
|
||||
|
||||
if (clutter_get_accessibility_enabled () == FALSE)
|
||||
{
|
||||
g_warning ("Accessibility: clutter has no accessibility enabled"
|
||||
@@ -422,10 +424,7 @@ main (int argc, char **argv)
|
||||
meta_set_wm_name (WM_NAME);
|
||||
meta_set_gnome_wm_keybindings (GNOME_WM_KEYBINDINGS);
|
||||
|
||||
/* Prevent meta_init() from causing gtk to load gail and at-bridge */
|
||||
g_setenv ("NO_AT_BRIDGE", "1", TRUE);
|
||||
meta_init ();
|
||||
g_unsetenv ("NO_AT_BRIDGE");
|
||||
|
||||
/* FIXME: Add gjs API to set this stuff and don't depend on the
|
||||
* environment. These propagate to child processes.
|
||||
|
216
src/shell-wobbly-effect.c
Normal file
216
src/shell-wobbly-effect.c
Normal file
@@ -0,0 +1,216 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Endless Mobile
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Written by:
|
||||
* Jasper St. Pierre <jstpierre@mecheye.net>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "shell-wobbly-effect.h"
|
||||
|
||||
struct _ShellWobblyEffectPrivate
|
||||
{
|
||||
int bend_x;
|
||||
|
||||
int tex_width, tex_height;
|
||||
CoglPipeline *pipeline;
|
||||
|
||||
int tex_width_uniform;
|
||||
int bend_x_uniform;
|
||||
};
|
||||
typedef struct _ShellWobblyEffectPrivate ShellWobblyEffectPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (ShellWobblyEffect, shell_wobbly_effect, CLUTTER_TYPE_OFFSCREEN_EFFECT);
|
||||
|
||||
static const gchar *wobbly_decls =
|
||||
"uniform int tex_width;\n"
|
||||
"uniform int bend_x;\n";
|
||||
static const gchar *wobbly_pre =
|
||||
"float bend_x_coord = (float(bend_x) / tex_width);\n"
|
||||
"float interp = (1 - cos(cogl_tex_coord.y * 3.1415926)) / 2;\n"
|
||||
"cogl_tex_coord.x -= (interp * bend_x_coord);\n";
|
||||
|
||||
/* XXX - clutter_effect_get_paint_volume is fucking terrible
|
||||
* and I want to kill myself */
|
||||
static gboolean
|
||||
shell_wobbly_effect_get_paint_volume (ClutterEffect *effect,
|
||||
ClutterPaintVolume *volume)
|
||||
{
|
||||
ShellWobblyEffect *self = SHELL_WOBBLY_EFFECT (effect);
|
||||
ShellWobblyEffectPrivate *priv = shell_wobbly_effect_get_instance_private (self);
|
||||
|
||||
float cur_width;
|
||||
cur_width = clutter_paint_volume_get_width (volume);
|
||||
cur_width += ABS (priv->bend_x);
|
||||
clutter_paint_volume_set_width (volume, cur_width);
|
||||
|
||||
/* Also modify the origin if it bends to the left. */
|
||||
if (priv->bend_x < 0)
|
||||
{
|
||||
ClutterVertex origin;
|
||||
clutter_paint_volume_get_origin (volume, &origin);
|
||||
origin.x += priv->bend_x;
|
||||
clutter_paint_volume_set_origin (volume, &origin);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
shell_wobbly_effect_pre_paint (ClutterEffect *effect)
|
||||
{
|
||||
ShellWobblyEffect *self = SHELL_WOBBLY_EFFECT (effect);
|
||||
ShellWobblyEffectPrivate *priv = shell_wobbly_effect_get_instance_private (self);
|
||||
|
||||
if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect)))
|
||||
return FALSE;
|
||||
|
||||
/* If we're not doing any bending, we're not needed. */
|
||||
if (priv->bend_x == 0)
|
||||
return FALSE;
|
||||
|
||||
if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
|
||||
{
|
||||
/* if we don't have support for GLSL shaders then we
|
||||
* forcibly disable the ActorMeta
|
||||
*/
|
||||
g_warning ("Unable to use the ShellWobblyEffect: the "
|
||||
"graphics hardware or the current GL driver does not "
|
||||
"implement support for the GLSL shading language. The "
|
||||
"effect will be disabled.");
|
||||
clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (effect), FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!CLUTTER_EFFECT_CLASS (shell_wobbly_effect_parent_class)->pre_paint (effect))
|
||||
return FALSE;
|
||||
|
||||
ClutterOffscreenEffect *offscreen_effect = CLUTTER_OFFSCREEN_EFFECT (effect);
|
||||
CoglObject *texture;
|
||||
|
||||
texture = clutter_offscreen_effect_get_texture (offscreen_effect);
|
||||
cogl_pipeline_set_layer_texture (priv->pipeline, 0, texture);
|
||||
|
||||
priv->tex_width = cogl_texture_get_width (texture);
|
||||
priv->tex_height = cogl_texture_get_height (texture);
|
||||
|
||||
cogl_pipeline_set_uniform_1i (priv->pipeline, priv->tex_width_uniform, priv->tex_width);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
shell_wobbly_effect_paint_target (ClutterOffscreenEffect *effect)
|
||||
{
|
||||
ShellWobblyEffect *self = SHELL_WOBBLY_EFFECT (effect);
|
||||
ShellWobblyEffectPrivate *priv = shell_wobbly_effect_get_instance_private (self);
|
||||
CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
|
||||
ClutterActor *actor;
|
||||
guint8 paint_opacity;
|
||||
|
||||
actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
|
||||
paint_opacity = clutter_actor_get_paint_opacity (actor);
|
||||
|
||||
cogl_pipeline_set_color4ub (priv->pipeline,
|
||||
paint_opacity,
|
||||
paint_opacity,
|
||||
paint_opacity,
|
||||
paint_opacity);
|
||||
|
||||
cogl_framebuffer_draw_rectangle (fb, priv->pipeline,
|
||||
0, 0, priv->tex_width, priv->tex_height);
|
||||
}
|
||||
|
||||
static void
|
||||
shell_wobbly_effect_dispose (GObject *object)
|
||||
{
|
||||
ShellWobblyEffect *self = SHELL_WOBBLY_EFFECT (object);
|
||||
ShellWobblyEffectPrivate *priv = shell_wobbly_effect_get_instance_private (self);
|
||||
|
||||
g_clear_pointer (&priv->pipeline, cogl_object_unref);
|
||||
|
||||
G_OBJECT_CLASS (shell_wobbly_effect_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
shell_wobbly_effect_class_init (ShellWobblyEffectClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
ClutterEffectClass *effect_class = CLUTTER_EFFECT_CLASS (klass);
|
||||
ClutterOffscreenEffectClass *offscreen_class = CLUTTER_OFFSCREEN_EFFECT_CLASS (klass);
|
||||
|
||||
offscreen_class->paint_target = shell_wobbly_effect_paint_target;
|
||||
effect_class->pre_paint = shell_wobbly_effect_pre_paint;
|
||||
effect_class->get_paint_volume = shell_wobbly_effect_get_paint_volume;
|
||||
object_class->dispose = shell_wobbly_effect_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
update_uniforms (ShellWobblyEffect *self)
|
||||
{
|
||||
ShellWobblyEffectPrivate *priv = shell_wobbly_effect_get_instance_private (self);
|
||||
cogl_pipeline_set_uniform_1i (priv->pipeline, priv->bend_x_uniform, priv->bend_x);
|
||||
}
|
||||
|
||||
static void
|
||||
shell_wobbly_effect_init (ShellWobblyEffect *self)
|
||||
{
|
||||
static CoglPipeline *pipeline_template;
|
||||
|
||||
ShellWobblyEffectPrivate *priv = shell_wobbly_effect_get_instance_private (self);
|
||||
|
||||
if (G_UNLIKELY (pipeline_template == NULL))
|
||||
{
|
||||
CoglSnippet *snippet;
|
||||
CoglContext *ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
||||
|
||||
pipeline_template = cogl_pipeline_new (ctx);
|
||||
|
||||
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_LOOKUP, wobbly_decls, NULL);
|
||||
cogl_snippet_set_pre (snippet, wobbly_pre);
|
||||
cogl_pipeline_add_layer_snippet (pipeline_template, 0, snippet);
|
||||
cogl_object_unref (snippet);
|
||||
|
||||
cogl_pipeline_set_layer_null_texture (pipeline_template,
|
||||
0, /* layer number */
|
||||
COGL_TEXTURE_TYPE_2D);
|
||||
}
|
||||
|
||||
priv->pipeline = cogl_pipeline_copy (pipeline_template);
|
||||
priv->tex_width_uniform = cogl_pipeline_get_uniform_location (priv->pipeline, "tex_width");
|
||||
priv->bend_x_uniform = cogl_pipeline_get_uniform_location (priv->pipeline, "bend_x");
|
||||
|
||||
update_uniforms (self);
|
||||
}
|
||||
|
||||
void
|
||||
shell_wobbly_effect_set_bend_x (ShellWobblyEffect *self,
|
||||
int bend_x)
|
||||
{
|
||||
ShellWobblyEffectPrivate *priv = shell_wobbly_effect_get_instance_private (self);
|
||||
|
||||
if (priv->bend_x == bend_x)
|
||||
return;
|
||||
|
||||
priv->bend_x = bend_x;
|
||||
update_uniforms (self);
|
||||
clutter_effect_queue_repaint (CLUTTER_EFFECT (self));
|
||||
}
|
55
src/shell-wobbly-effect.h
Normal file
55
src/shell-wobbly-effect.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Endless Mobile
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Written by:
|
||||
* Jasper St. Pierre <jstpierre@mecheye.net>
|
||||
*/
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#ifndef __SHELL_WOBBLY_EFFECT_H__
|
||||
#define __SHELL_WOBBLY_EFFECT_H__
|
||||
|
||||
#define SHELL_TYPE_WOBBLY_EFFECT (shell_wobbly_effect_get_type ())
|
||||
#define SHELL_WOBBLY_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SHELL_TYPE_WOBBLY_EFFECT, ShellWobblyEffect))
|
||||
#define SHELL_WOBBLY_EFFECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SHELL_TYPE_WOBBLY_EFFECT, ShellWobblyEffectClass))
|
||||
#define SHELL_IS_WOBBLY_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SHELL_TYPE_WOBBLY_EFFECT))
|
||||
#define SHELL_IS_WOBBLY_EFFECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SHELL_TYPE_WOBBLY_EFFECT))
|
||||
#define SHELL_WOBBLY_EFFECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SHELL_TYPE_WOBBLY_EFFECT, ShellWobblyEffectClass))
|
||||
|
||||
typedef struct _ShellWobblyEffect ShellWobblyEffect;
|
||||
typedef struct _ShellWobblyEffectClass ShellWobblyEffectClass;
|
||||
|
||||
struct _ShellWobblyEffect
|
||||
{
|
||||
ClutterOffscreenEffect parent;
|
||||
};
|
||||
|
||||
struct _ShellWobblyEffectClass
|
||||
{
|
||||
ClutterOffscreenEffectClass parent_class;
|
||||
};
|
||||
|
||||
GType shell_wobbly_effect_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void shell_wobbly_effect_set_bend_x (ShellWobblyEffect *self,
|
||||
int bend_x);
|
||||
|
||||
#endif /* __SHELL_WOBBLY_EFFECT_H__ */
|
Reference in New Issue
Block a user