Workspace: fix window clone slot reporting

WindowOverlay was at times seeing bogus values reported as WindowClone
sizes. Fix that by storing and passing the value from the authoritative
source, that is, the LayoutStrategy.

https://bugzilla.gnome.org/show_bug.cgi?id=688234
This commit is contained in:
Giovanni Campagna 2012-12-17 00:40:48 +01:00
parent d479c936b8
commit c66068c435

View File

@ -124,6 +124,8 @@ const WindowClone = new Lang.Class({
this.actor._delegate = this; this.actor._delegate = this;
this._slot = [0, 0, 0, 0];
this._dragSlot = [0, 0, 0, 0];
this._stackAbove = null; this._stackAbove = null;
this._sizeChangedId = this.realWindow.connect('size-changed', this._sizeChangedId = this.realWindow.connect('size-changed',
@ -159,22 +161,15 @@ const WindowClone = new Lang.Class({
this._selected = false; this._selected = false;
}, },
set slot(slot) {
this._slot = slot;
},
get slot() { get slot() {
let x, y, w, h; if (this.inDrag)
return this._dragSlot;
if (this.inDrag) { else
x = this.dragOrigX; return this._slot;
y = this.dragOrigY;
w = this.actor.width * this.dragOrigScale;
h = this.actor.height * this.dragOrigScale;
} else {
x = this.actor.x;
y = this.actor.y;
w = this.actor.width * this.actor.scale_x;
h = this.actor.height * this.actor.scale_y;
}
return [x, y, w, h];
}, },
setStackAbove: function (actor) { setStackAbove: function (actor) {
@ -392,6 +387,7 @@ const WindowClone = new Lang.Class({
if (this._zooming) if (this._zooming)
this._zoomEnd(); this._zoomEnd();
this._dragSlot = this._slot;
[this.dragOrigX, this.dragOrigY] = this.actor.get_position(); [this.dragOrigX, this.dragOrigY] = this.actor.get_position();
this.dragOrigScale = this.actor.scale_x; this.dragOrigScale = this.actor.scale_x;
this.inDrag = true; this.inDrag = true;
@ -458,11 +454,7 @@ const WindowOverlay = new Lang.Class({
this._updateCaptionId = metaWindow.connect('notify::title', this._updateCaptionId = metaWindow.connect('notify::title',
Lang.bind(this, function(w) { Lang.bind(this, function(w) {
this.title.text = w.title; this.title.text = w.title;
// we need this for the next call to get_preferred_width this.relayout(false);
// to return useful results
this.title.set_size(-1, -1);
this._repositionSelf();
})); }));
let button = new St.Button({ style_class: 'window-close' }); let button = new St.Button({ style_class: 'window-close' });
@ -537,22 +529,9 @@ const WindowOverlay = new Lang.Class({
return [this.borderSize, this.borderSize]; return [this.borderSize, this.borderSize];
}, },
_repositionSelf: function() { relayout: function(animate) {
let [cloneX, cloneY, cloneWidth, cloneHeight] = this._windowClone.slot; let [cloneX, cloneY, cloneWidth, cloneHeight] = this._windowClone.slot;
this.updatePositions(cloneX, cloneY, cloneWidth, cloneHeight, false);
},
/**
* @cloneX: x position of windowClone
* @cloneY: y position of windowClone
* @cloneWidth: width of windowClone
* @cloneHeight height of windowClone
*/
// These parameters are not the values retrieved with
// get_transformed_position() and get_transformed_size(),
// as windowClone might be moving.
// See Workspace._showWindowOverlay
updatePositions: function(cloneX, cloneY, cloneWidth, cloneHeight, animate) {
let button = this.closeButton; let button = this.closeButton;
let title = this.title; let title = this.title;
@ -1194,6 +1173,7 @@ const Workspace = new Lang.Class({
continue; continue;
let [x, y, scale] = slot; let [x, y, scale] = slot;
clone.slot = [x, y, clone.actor.width * scale, clone.actor.height * scale];
if (overlay && initialPositioning) if (overlay && initialPositioning)
overlay.hide(); overlay.hide();
@ -1225,7 +1205,7 @@ const Workspace = new Lang.Class({
Tweener.removeTweens(clone.actor); Tweener.removeTweens(clone.actor);
clone.actor.set_position(x, y); clone.actor.set_position(x, y);
clone.actor.set_scale(scale, scale); clone.actor.set_scale(scale, scale);
this._updateWindowOverlayPositions(clone, overlay, x, y, scale, false); clone.overlay.relayout(false);
this._showWindowOverlay(clone, overlay, isOnCurrentWorkspace); this._showWindowOverlay(clone, overlay, isOnCurrentWorkspace);
} }
} }
@ -1260,15 +1240,7 @@ const Workspace = new Lang.Class({
}) })
}); });
this._updateWindowOverlayPositions(clone, overlay, x, y, scale, true); clone.overlay.relayout(true);
},
_updateWindowOverlayPositions: function(clone, overlay, x, y, scale, animate) {
if (!overlay)
return;
let [cloneWidth, cloneHeight] = clone.actor.get_size();
overlay.updatePositions(x, y, cloneWidth * scale, cloneHeight * scale, animate);
}, },
_showWindowOverlay: function(clone, overlay, fade) { _showWindowOverlay: function(clone, overlay, fade) {
@ -1403,9 +1375,10 @@ const Workspace = new Lang.Class({
let scale = win._overviewHint.scale; let scale = win._overviewHint.scale;
delete win._overviewHint; delete win._overviewHint;
clone.slot = [x, y, clone.actor.width * scale, clone.actor.height * scale];
clone.actor.set_position (x, y); clone.actor.set_position (x, y);
clone.actor.set_scale (scale, scale); clone.actor.set_scale (scale, scale);
this._updateWindowOverlayPositions(clone, overlay, x, y, scale, false); clone.overlay.relayout(false);
} else { } else {
// Position new windows at the top corner of the workspace rather // Position new windows at the top corner of the workspace rather
// than where they were placed for real to avoid the window // than where they were placed for real to avoid the window