main, lightbox: Fix lightbox for zoomed windows
The correct way to make an actor having the same size as another is a ClutterBindConstraint. Connecting to 'allocation-changed' fails because the allocation might not change even when 'width' and 'height' properties do. This is the case of Main.uiGroup, used as parent container for zoomed window clones. In lightbox.js we bind also the position because in principle it could change, even if currently only fullscreen lightboxes are used.
This commit is contained in:
parent
fbf6e032d0
commit
0c2037875a
@ -1,5 +1,6 @@
|
|||||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
|
|
||||||
|
const Clutter = imports.gi.Clutter;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const Meta = imports.gi.Meta;
|
const Meta = imports.gi.Meta;
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
@ -57,11 +58,10 @@ const Lightbox = new Lang.Class({
|
|||||||
if (params.width && params.height) {
|
if (params.width && params.height) {
|
||||||
this.actor.width = params.width;
|
this.actor.width = params.width;
|
||||||
this.actor.height = params.height;
|
this.actor.height = params.height;
|
||||||
this._allocationChangedSignalId = 0;
|
|
||||||
} else {
|
} else {
|
||||||
this.actor.width = container.width;
|
let constraint = new Clutter.BindConstraint({ source: container,
|
||||||
this.actor.height = container.height;
|
coordinate: Clutter.BindCoordinate.ALL });
|
||||||
this._allocationChangedSignalId = container.connect('allocation-changed', Lang.bind(this, this._allocationChanged));
|
this.actor.add_constraint(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._actorAddedSignalId = container.connect('actor-added', Lang.bind(this, this._actorAdded));
|
this._actorAddedSignalId = container.connect('actor-added', Lang.bind(this, this._actorAdded));
|
||||||
@ -70,16 +70,6 @@ const Lightbox = new Lang.Class({
|
|||||||
this._highlighted = null;
|
this._highlighted = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
_allocationChanged : function(container, box, flags) {
|
|
||||||
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
|
|
||||||
this.actor.width = this.width;
|
|
||||||
this.actor.height = this.height;
|
|
||||||
return false;
|
|
||||||
}));
|
|
||||||
this.width = this._container.width;
|
|
||||||
this.height = this._container.height;
|
|
||||||
},
|
|
||||||
|
|
||||||
_actorAdded : function(container, newChild) {
|
_actorAdded : function(container, newChild) {
|
||||||
let children = this._container.get_children();
|
let children = this._container.get_children();
|
||||||
let myIndex = children.indexOf(this.actor);
|
let myIndex = children.indexOf(this.actor);
|
||||||
@ -187,8 +177,6 @@ const Lightbox = new Lang.Class({
|
|||||||
* by destroying its container or by explicitly calling this.destroy().
|
* by destroying its container or by explicitly calling this.destroy().
|
||||||
*/
|
*/
|
||||||
_onDestroy: function() {
|
_onDestroy: function() {
|
||||||
if (this._allocationChangedSignalId != 0)
|
|
||||||
this._container.disconnect(this._allocationChangedSignalId);
|
|
||||||
this._container.disconnect(this._actorAddedSignalId);
|
this._container.disconnect(this._actorAddedSignalId);
|
||||||
this._container.disconnect(this._actorRemovedSignalId);
|
this._container.disconnect(this._actorRemovedSignalId);
|
||||||
|
|
||||||
|
@ -187,6 +187,9 @@ function start() {
|
|||||||
for (let i = 0; i < children.length; i++)
|
for (let i = 0; i < children.length; i++)
|
||||||
children[i].allocate_preferred_size(flags);
|
children[i].allocate_preferred_size(flags);
|
||||||
});
|
});
|
||||||
|
let constraint = new Clutter.BindConstraint({ source: global.stage,
|
||||||
|
coordinate: Clutter.BindCoordinate.SIZE });
|
||||||
|
uiGroup.add_constraint(constraint);
|
||||||
St.set_ui_root(global.stage, uiGroup);
|
St.set_ui_root(global.stage, uiGroup);
|
||||||
global.window_group.reparent(uiGroup);
|
global.window_group.reparent(uiGroup);
|
||||||
global.overlay_group.reparent(uiGroup);
|
global.overlay_group.reparent(uiGroup);
|
||||||
|
Loading…
Reference in New Issue
Block a user