From 06753610e81a0789d12b75cd6f86644302952a60 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Fri, 10 Sep 2021 01:04:12 +0200 Subject: [PATCH 1/4] fix(tiling): Windows launching onto window that isn't focused --- src/auto_tiler.ts | 3 ++- src/extension.ts | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/auto_tiler.ts b/src/auto_tiler.ts index b1eeb919..99708f3b 100644 --- a/src/auto_tiler.ts +++ b/src/auto_tiler.ts @@ -202,6 +202,7 @@ 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 }) } } @@ -656,7 +657,7 @@ export class AutoTiler { return Err('ignoring focus'); } - const prev = ext.prev_focused[1] + const prev = ext.prev_focused[0] if (!prev) { return Err('no window has been previously focused'); diff --git a/src/extension.ts b/src/extension.ts index c1af4d43..b60b6b12 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -792,8 +792,11 @@ export class Ext extends Ecs.System { this.exception_add(win) } - this.prev_focused[0] = this.prev_focused[1]; - this.prev_focused[1] = win.entity; + // 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; + } // Update the active tab in the stack. if (null !== this.auto_tiler && null !== win.stack) { From e3923adac70aa36a0704721759bf7b477c03aa9f Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Fri, 10 Sep 2021 19:30:43 +0200 Subject: [PATCH 2/4] fix(tiling): Improve focus matching across displays --- src/auto_tiler.ts | 2 +- src/extension.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/auto_tiler.ts b/src/auto_tiler.ts index 99708f3b..45e99b1f 100644 --- a/src/auto_tiler.ts +++ b/src/auto_tiler.ts @@ -657,7 +657,7 @@ export class AutoTiler { return Err('ignoring focus'); } - const prev = ext.prev_focused[0] + const prev = ext.previously_focused(win) if (!prev) { return Err('no window has been previously focused'); diff --git a/src/extension.ts b/src/extension.ts index b60b6b12..f0cd4c33 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 */ - prev_focused: [null | Entity, null | Entity] = [null, null]; + private prev_focused: [null | Entity, null | Entity] = [null, null]; tween_signals: Map = new Map(); @@ -1070,6 +1070,17 @@ 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) { From 4327e86c0a1266a9733b8cc2ea204c58845c2b48 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Tue, 14 Sep 2021 17:22:41 +0200 Subject: [PATCH 3/4] fix(tiling): Ignore if mouse is on separate display on window attach --- src/auto_tiler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auto_tiler.ts b/src/auto_tiler.ts index 45e99b1f..7d233e13 100644 --- a/src/auto_tiler.ts +++ b/src/auto_tiler.ts @@ -685,9 +685,9 @@ export class AutoTiler { return Err('focused window is not attached'); } - return onto.meta.get_monitor() == win.meta.get_monitor() && onto.workspace_id() == win.workspace_id() + return onto.workspace_id() == win.workspace_id() ? Ok(onto) - : Err('window is not on the same monitor or workspace'); + : Err('window is not on the same workspace'); } private toggle_orientation_(ext: Ext, focused: ShellWindow): Result { From 6864adab7b349ed8f97e9e578461ebc0a2abf4b8 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Tue, 14 Sep 2021 18:35:41 +0200 Subject: [PATCH 4/4] fix(tiling): Keep windows on same display when toggling tiling --- src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index f0cd4c33..21672a80 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -2035,7 +2035,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, false); + tiler.auto_tile(this, window, true); } } }