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
This commit is contained in:
Giovanni Campagna 2013-02-21 23:32:25 +01:00
parent a1d37617a8
commit d5e647a191
2 changed files with 19 additions and 13 deletions

View File

@ -635,12 +635,14 @@ const BackgroundManager = new Lang.Class({
params = Params.parse(params, { container: null, params = Params.parse(params, { container: null,
layoutManager: Main.layoutManager, layoutManager: Main.layoutManager,
monitorIndex: null, monitorIndex: null,
effects: Meta.BackgroundEffects.NONE }); effects: Meta.BackgroundEffects.NONE,
controlPosition: true });
this._container = params.container; this._container = params.container;
this._layoutManager = params.layoutManager; this._layoutManager = params.layoutManager;
this._effects = params.effects; this._effects = params.effects;
this._monitorIndex = params.monitorIndex; this._monitorIndex = params.monitorIndex;
this._controlPosition = params.controlPosition;
this.background = this._createBackground(); this.background = this._createBackground();
this._newBackground = null; this._newBackground = null;
@ -700,9 +702,12 @@ const BackgroundManager = new Lang.Class({
this._container.add_child(background.actor); this._container.add_child(background.actor);
let monitor = this._layoutManager.monitors[this._monitorIndex]; let monitor = this._layoutManager.monitors[this._monitorIndex];
background.actor.set_position(monitor.x, monitor.y);
background.actor.set_size(monitor.width, monitor.height); background.actor.set_size(monitor.width, monitor.height);
background.actor.lower_bottom(); if (this._controlPosition) {
background.actor.set_position(monitor.x, monitor.y);
background.actor.lower_bottom();
}
let signalId = background.connect('changed', Lang.bind(this, function() { let signalId = background.connect('changed', Lang.bind(this, function() {
background.disconnect(signalId); background.disconnect(signalId);

View File

@ -447,7 +447,7 @@ const ScreenShield = new Lang.Class({
this._lockScreenGroup.add_actor(this._lockScreenContents); this._lockScreenGroup.add_actor(this._lockScreenContents);
this._backgroundGroup = new Meta.BackgroundGroup(); this._backgroundGroup = new Clutter.Actor();
this._lockScreenGroup.add_actor(this._backgroundGroup); this._lockScreenGroup.add_actor(this._backgroundGroup);
this._backgroundGroup.lower_bottom(); this._backgroundGroup.lower_bottom();
@ -538,21 +538,22 @@ const ScreenShield = new Lang.Class({
}, },
_createBackground: function(monitorIndex) { _createBackground: function(monitorIndex) {
let bin = new St.Bin({ style_class: 'screen-shield-background' }); let monitor = Main.layoutManager.monitors[monitorIndex];
let widget = new St.Widget({ style_class: 'screen-shield-background',
x: monitor.x,
y: monitor.y,
width: monitor.width,
height: monitor.height });
let group = new Meta.BackgroundGroup(); let bgManager = new Background.BackgroundManager({ container: widget,
bin.child = group;
let bgManager = new Background.BackgroundManager({ container: group,
monitorIndex: monitorIndex, monitorIndex: monitorIndex,
effects: Meta.BackgroundEffects.BLUR | Meta.BackgroundEffects.DESATURATE }); effects: Meta.BackgroundEffects.BLUR | Meta.BackgroundEffects.DESATURATE,
controlPosition: false });
bgManager.background.saturation = 0.6; bgManager.background.saturation = 0.6;
this._bgManagers.push(bgManager); this._bgManagers.push(bgManager);
this._backgroundGroup.add_child(bin); this._backgroundGroup.add_child(widget);
bin.lower_bottom();
}, },
_updateBackgrounds: function() { _updateBackgrounds: function() {