Skip to content

Commit

Permalink
[Scale] Handle changes in workspace count dynamically.
Browse files Browse the repository at this point in the history
  • Loading branch information
autarkper committed Nov 20, 2012
1 parent 7dbb410 commit 848a925
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
8 changes: 1 addition & 7 deletions js/ui/workspace.js
Expand Up @@ -1629,6 +1629,7 @@ Workspace.prototype = {
this.currentMonitorIndex = Main.layoutManager.primaryIndex;
Main.layoutManager.monitors.forEach(function(monitor, ix) {
let m = new WorkspaceMonitor(metaWorkspace, ix, this, ix === this.currentMonitorIndex)
m.setGeometry(monitor.x, monitor.y, monitor.width, monitor.height, 0);
this._monitors.push(m);
this.actor.add_actor(m.actor);
}, this);
Expand Down Expand Up @@ -1717,13 +1718,6 @@ Workspace.prototype = {
this.actor.destroy();
},

setGeometry: function() {
this._monitors.forEach(function(monitor, index) {
let mon = Main.layoutManager.monitors[index];
monitor.setGeometry(mon.x, mon.y, mon.width, mon.height, 0);
}, this);
},

selectAnotherWindow: function(symbol) {
this._monitors[this.currentMonitorIndex].selectAnotherWindow(symbol);
},
Expand Down
27 changes: 23 additions & 4 deletions js/ui/workspacesView.js
Expand Up @@ -95,7 +95,7 @@ WorkspacesView.prototype = {
let switchWorkspaceNotifyId = global.window_manager.connect('switch-workspace',
Lang.bind(this, this._activeWorkspaceChanged));

let nWorkspacesChangedId = global.screen.connect('notify::n-workspaces', Main.overview.hide);
let nWorkspacesChangedId = global.screen.connect('notify::n-workspaces', Lang.bind(this, this._workspacesChanged));

this._disconnectHandlers = function() {
global.window_manager.disconnect(switchWorkspaceNotifyId);
Expand Down Expand Up @@ -131,9 +131,6 @@ WorkspacesView.prototype = {
this._x = x;
this._y = y;
this._workspaceRatioSpacing = spacing;

for (let i = 0; i < this._workspaces.length; i++)
this._workspaces[i].setGeometry();
},

_lookupWorkspaceForMetaWindow: function (metaWindow) {
Expand Down Expand Up @@ -262,6 +259,28 @@ WorkspacesView.prototype = {
this._workspaces[active].zoomToOverview();
},

_workspacesChanged: function() {
let removedCount = 0;
this._workspaces.slice().forEach(function(workspace, i) {
let metaWorkspace = global.screen.get_workspace_by_index(i-removedCount);
if (workspace.metaWorkspace != metaWorkspace) {
Tweener.removeTweens(workspace.actor);
workspace.destroy();
this._workspaces.splice(i - removedCount, 1);
++removedCount;
}
}, this);

while (global.screen.n_workspaces > this._workspaces.length) {
let lastWs = global.screen.get_workspace_by_index(this._workspaces.length);
let workspace = new Workspace.Workspace(lastWs, this);
this._workspaces.push(workspace)
this.actor.add_actor(workspace.actor);
}
this._animating = false;
this._updateVisibility();
},

_activeWorkspaceChanged: function(wm, from, to, direction) {
if (this._scrolling)
return;
Expand Down

0 comments on commit 848a925

Please sign in to comment.