Skip to content

Commit

Permalink
fix(tiling): Improve focus matching across displays
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Sep 14, 2021
1 parent abae072 commit b79cc48
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/auto_tiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
13 changes: 12 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class Ext extends Ecs.System<ExtEvent> {
injections: Array<Injection> = 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<string, [SignalID, any]> = new Map();

Expand Down Expand Up @@ -1070,6 +1070,17 @@ export class Ext extends Ecs.System<ExtEvent> {
}
}

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) {
Expand Down

0 comments on commit b79cc48

Please sign in to comment.