workspace: Lay out windows based on the real allocation

Instead of doing an entire recalculation of window positions when
sliding the thumbnails box, simply recalculate the position and scale
with basic aspect ratio math. This also ensures that windows won't
miraculously swap positions, even if we reposition windows while the
thumbnails box is expanded.

https://bugzilla.gnome.org/show_bug.cgi?id=694469
This commit is contained in:
Jasper St. Pierre
2013-02-25 18:34:17 -05:00
parent bde8cc3285
commit c37259b01d
2 changed files with 62 additions and 6 deletions

View File

@ -56,6 +56,7 @@ const WorkspacesView = new Lang.Class({
}));
this._fullGeometry = null;
this._actualGeometry = null;
this._spacing = 0;
this._animating = false; // tweening
@ -135,6 +136,7 @@ const WorkspacesView = new Lang.Class({
let ws = new Workspace.Workspace(null, i);
ws.setFullGeometry(monitors[i]);
ws.setActualGeometry(monitors[i]);
global.overlay_group.add_actor(ws.actor);
this._extraWorkspaces.push(ws);
}
@ -156,6 +158,16 @@ const WorkspacesView = new Lang.Class({
this._workspaces[i].setFullGeometry(geom);
},
setActualGeometry: function(geom) {
if (rectEqual(this._actualGeometry, geom))
return;
this._actualGeometry = geom;
for (let i = 0; i < this._workspaces.length; i++)
this._workspaces[i].setActualGeometry(geom);
},
_lookupWorkspaceForMetaWindow: function (metaWindow) {
for (let i = 0; i < this._workspaces.length; i++) {
if (this._workspaces[i].containsMetaWindow(metaWindow))
@ -432,6 +444,7 @@ const WorkspacesDisplay = new Lang.Class({
_init: function() {
this.actor = new St.Widget({ clip_to_allocation: true });
this.actor.connect('notify::allocation', Lang.bind(this, this._updateWorkspacesActualGeometry));
this.actor.connect('parent-set', Lang.bind(this, this._parentSet));
let clickAction = new Clutter.ClickAction()
@ -576,6 +589,7 @@ const WorkspacesDisplay = new Lang.Class({
}
this._updateWorkspacesFullGeometry();
this._updateWorkspacesActualGeometry();
for (let i = 0; i < this._workspacesViews.length; i++)
global.overlay_group.add_actor(this._workspacesViews[i].actor);
@ -660,6 +674,28 @@ const WorkspacesDisplay = new Lang.Class({
}
},
_updateWorkspacesActualGeometry: function() {
if (!this._workspacesViews.length)
return;
let [x, y] = this.actor.get_transformed_position();
let width = this.actor.allocation.x2 - this.actor.allocation.x1;
let height = this.actor.allocation.y2 - this.actor.allocation.y1;
let geometry = { x: x, y: y, width: width, height: height };
let monitors = Main.layoutManager.monitors;
let m = 0;
for (let i = 0; i < monitors.length; i++) {
if (i == this._primaryIndex) {
this._workspacesViews[m].setActualGeometry(geometry);
m++;
} else if (!this._workspacesOnlyOnPrimary) {
this._workspacesViews[m].setActualGeometry(monitors[i]);
m++;
}
}
},
_onRestacked: function(overview, stackIndices) {
for (let i = 0; i < this._workspacesViews.length; i++)
this._workspacesViews[i].syncStacking(stackIndices);