Skip to content

Commit

Permalink
fix: Also change workspace of windows in stacks on a new top level wo…
Browse files Browse the repository at this point in the history
…rkspace switch
  • Loading branch information
mmstick committed Sep 23, 2020
1 parent 5a81feb commit 3b21d27
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1172,8 +1172,19 @@ export class Ext extends Ecs.System<ExtEvent> {
on_workspace_modify(
condition: (current: number) => boolean,
modify: (current: number) => number,
change_workspace: boolean = false
change_workspace: boolean = false,
) {
function window_move(ext: Ext, entity: Entity, ws: WorkspaceID) {
if (change_workspace) {
const window = ext.windows.get(entity);
if (!window || !window.actor_exists()) return;

ext.size_signals_block(window);
window.meta.change_workspace_by_index(ws, false);
ext.size_signals_unblock(window);
}
}

if (this.auto_tiler) {
for (const [entity, monitor] of this.auto_tiler.forest.toplevel.values()) {
if (condition(monitor[1])) {
Expand All @@ -1187,17 +1198,18 @@ export class Ext extends Ecs.System<ExtEvent> {
fork = this.auto_tiler.forest.forks.get(child.inner.entity);
if (fork) fork.workspace = value;
} else if (child.inner.kind === 2) {
if (change_workspace) {
const window = this.windows.get(child.inner.entity);
if (!window || !window.actor_exists()) continue;

this.size_signals_block(window);
window.meta.change_workspace_by_index(value, true);
this.size_signals_unblock(window);
}
window_move(this, child.inner.entity, value);
} else if (child.inner.kind === 3) {
let stack = this.auto_tiler.forest.stacks.get(child.inner.idx);
if (stack) stack.workspace = value;
if (stack) {
stack.workspace = value;

for (const entity of child.inner.entities) {
window_move(this, entity, value);
}

stack.restack();
}
}
}
}
Expand Down

0 comments on commit 3b21d27

Please sign in to comment.