@@ 72,6 72,16 @@ class WindowManager {
this.activeWorkspace.master.prev = newWin;
}
+ addWindow(win) {
+ // no window is present:
+ if (this.activeWorkspace.master == null) {
+ this.addMaster(win);
+ // if master is the only window
+ } else {
+ this.addNewAtBottom(win);
+ }
+ }
+
removeMasterWhenSingle() {
this.activeWorkspace.master.destroy();
this.activeWorkspace.master = null;
@@ 89,7 99,7 @@ class WindowManager {
this.activeWorkspace.master = newMaster;
}
- removeWindow(win) {
+ removeStackWindow(win, destroy) {
let currentWindow = this.activeWorkspace.master;
// go through all the windows, searching for the one that was deleted
@@ 100,14 110,39 @@ class WindowManager {
currentWindow.prev.next = currentWindow.next;
// the next widnow of the deleted should point to the prev of the deleted, skipping it
currentWindow.next.prev = currentWindow.prev;
- // set to null, gc
- currentWindow.destroy();
+ if (destroy) {
+ // set to null, gc
+ currentWindow.destroy();
+ }
break;
}
currentWindow = currentWindow.next;
} while (currentWindow != this.activeWorkspace.master);
}
+ removeWindow(win) {
+ // // because we call this event
+ // if (this.activeWorkspace.master == null) {
+ // return;
+ // }
+ // remove the master window
+ if (win == this.activeWorkspace.master.win) {
+ log('Removing the master window');
+ // the master window is the only one
+ if (this.activeWorkspace.master.next == this.activeWorkspace.master) {
+ log('Master is the only window');
+ this.removeMasterWhenSingle();
+ } else {
+ log('There are other windows');
+ this.removeMaster();
+ }
+ // remove window from stack
+ } else {
+ this.removeStackWindow(win, true);
+ }
+ }
+
+
computeAndPosition() {
log(`Arranging ${this.activeWorkspace.windowCount} windows`);
@@ 186,14 221,7 @@ class WindowManager {
let window = new Window(win);
// add new window to the linked list
- //
- // no window is present:
- if (this.activeWorkspace.master == null) {
- this.addMaster(win);
- // if master is the only window
- } else {
- this.addNewAtBottom(win);
- }
+ this.addWindow(win);
this.activeWorkspace.windowCount++;
// connect to the a signal, that fires, before the window is drawn
@@ 211,20 239,7 @@ class WindowManager {
windowDestroyed(display, win) {
log('Deleting window');
- // remove the master window
- if (win == this.activeWorkspace.master.win) {
- log('Removing the master window');
- // the master window is the only one
- if (this.activeWorkspace.master.next == this.activeWorkspace.master) {
- log('Master is the only window');
- this.removeMasterWhenSingle();
- } else {
- log('There are other windows');
- this.removeMaster();
- }
- } else {
- this.removeWindow(win);
- }
+ this.removeWindow(win);
this.activeWorkspace.windowCount--;
// reposition all windows