Skip to content

Commit e3923ad

Browse files
committed
fix(tiling): Improve focus matching across displays
1 parent 0675361 commit e3923ad

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/auto_tiler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ export class AutoTiler {
657657
return Err('ignoring focus');
658658
}
659659

660-
const prev = ext.prev_focused[0]
660+
const prev = ext.previously_focused(win)
661661

662662
if (!prev) {
663663
return Err('no window has been previously focused');

src/extension.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export class Ext extends Ecs.System<ExtEvent> {
152152
injections: Array<Injection> = new Array();
153153

154154
/** The window that was focused before the last window */
155-
prev_focused: [null | Entity, null | Entity] = [null, null];
155+
private prev_focused: [null | Entity, null | Entity] = [null, null];
156156

157157
tween_signals: Map<string, [SignalID, any]> = new Map();
158158

@@ -1070,6 +1070,17 @@ export class Ext extends Ecs.System<ExtEvent> {
10701070
}
10711071
}
10721072

1073+
previously_focused(active: Window.ShellWindow): null | Ecs.Entity {
1074+
for (const id of [1, 0]) {
1075+
const prev = this.prev_focused[id]
1076+
if (prev && ! Ecs.entity_eq(active.entity, prev)) {
1077+
return prev;
1078+
}
1079+
}
1080+
1081+
return null
1082+
}
1083+
10731084
movement_is_valid(win: Window.ShellWindow, movement: movement.Movement) {
10741085
if ((movement & Movement.SHRINK) !== 0) {
10751086
if ((movement & Movement.DOWN) !== 0) {

0 commit comments

Comments
 (0)