diff --git a/src/auto_tiler.ts b/src/auto_tiler.ts index 7d233e13..b1eeb919 100644 --- a/src/auto_tiler.ts +++ b/src/auto_tiler.ts @@ -202,7 +202,6 @@ export class AutoTiler { log.debug(`attach to workspace: ${result.value}`) this.attach_to_workspace(ext, win, ext.workspace_id(win)); } else { - log.debug(`attaching to window ${win.entity}`) this.attach_to_window(ext, result.value, win, { auto: 0 }) } } @@ -657,7 +656,7 @@ export class AutoTiler { return Err('ignoring focus'); } - const prev = ext.previously_focused(win) + const prev = ext.prev_focused[1] if (!prev) { return Err('no window has been previously focused'); @@ -685,9 +684,9 @@ export class AutoTiler { return Err('focused window is not attached'); } - return onto.workspace_id() == win.workspace_id() + return onto.meta.get_monitor() == win.meta.get_monitor() && onto.workspace_id() == win.workspace_id() ? Ok(onto) - : Err('window is not on the same workspace'); + : Err('window is not on the same monitor or workspace'); } private toggle_orientation_(ext: Ext, focused: ShellWindow): Result { diff --git a/src/extension.ts b/src/extension.ts index 6d3e4603..e9f43b2c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -152,7 +152,7 @@ export class Ext extends Ecs.System { injections: Array = new Array(); /** The window that was focused before the last window */ - private prev_focused: [null | Entity, null | Entity] = [null, null]; + prev_focused: [null | Entity, null | Entity] = [null, null]; tween_signals: Map = new Map(); @@ -788,11 +788,8 @@ export class Ext extends Ecs.System { this.exception_add(win) } - // Track history of focused windows, but do not permit duplicates. - if (this.prev_focused[1] !== win.entity) { - this.prev_focused[0] = this.prev_focused[1]; - this.prev_focused[1] = win.entity; - } + this.prev_focused[0] = this.prev_focused[1]; + this.prev_focused[1] = win.entity; // Update the active tab in the stack. if (null !== this.auto_tiler && null !== win.stack) { @@ -1066,17 +1063,6 @@ export class Ext extends Ecs.System { } } - previously_focused(active: Window.ShellWindow): null | Ecs.Entity { - for (const id of [1, 0]) { - const prev = this.prev_focused[id] - if (prev && ! Ecs.entity_eq(active.entity, prev)) { - return prev; - } - } - - return null - } - movement_is_valid(win: Window.ShellWindow, movement: movement.Movement) { if ((movement & Movement.SHRINK) !== 0) { if ((movement & Movement.DOWN) !== 0) { @@ -2048,7 +2034,7 @@ export class Ext extends Ecs.System { let actor = window.meta.get_compositor_private(); if (actor) { if (!window.meta.minimized) { - tiler.auto_tile(this, window, true); + tiler.auto_tile(this, window, false); } } }