Skip to content

Commit ed3e1a0

Browse files
committed
src/auto_tiler: Sync smart_gapped on each tiling attempt.
The first window is fully maximized, and then later when a second window is opened, we don't get border for the first window when it is in focus because after tiling the first window has stale value for smart_gapped, and thus is_single_max_screen() returns true, causing permitted in show_border() to be false. Let's set smart_gapped for each window in a tree each time we tile. Closes: #1758 Signed-off-by: Siddh Raman Pant <25429745+siddhpant@users.noreply.github.com>
1 parent 7898b65 commit ed3e1a0

1 file changed

Lines changed: 38 additions & 8 deletions

File tree

src/auto_tiler.ts

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,43 @@ export class AutoTiler {
2929
this.attached = attached;
3030
}
3131

32+
private sync_smart_gapped(ext: Ext, fork: Fork) {
33+
let toplevel = fork;
34+
let parent = this.forest.parents.get(toplevel.entity);
35+
36+
/* Walk upwards to get the actual top-level root from the fork. */
37+
while (parent) {
38+
const next = this.forest.forks.get(parent);
39+
if (!next)
40+
break;
41+
42+
toplevel = next;
43+
parent = this.forest.parents.get(toplevel.entity);
44+
}
45+
46+
const smart_gapped = (
47+
toplevel.is_toplevel &&
48+
toplevel.smart_gapped &&
49+
toplevel.right === null
50+
);
51+
52+
/* Set smart_gapped for each window. */
53+
for (const branch of this.forest.iter(toplevel.entity)) {
54+
let entities: Entity[] = [];
55+
56+
if (branch.inner.kind === NodeKind.WINDOW)
57+
entities = [branch.inner.entity];
58+
else if (branch.inner.kind === NodeKind.STACK)
59+
entities = branch.inner.entities;
60+
61+
for (const entity of entities) {
62+
const win = ext.windows.get(entity);
63+
if (win)
64+
win.smart_gapped = smart_gapped;
65+
}
66+
}
67+
}
68+
3269
/** Swap window associations in the auto-tiler
3370
*
3471
* Call this when a window has swapped positions with another, so that we
@@ -106,13 +143,6 @@ export class AutoTiler {
106143
rect.height -= ext.gap_outer * 2;
107144
}
108145

109-
if (fork.left.inner.kind === 2) {
110-
const win = ext.windows.get(fork.left.inner.entity);
111-
if (win) {
112-
win.smart_gapped = fork.smart_gapped;
113-
}
114-
}
115-
116146
fork.area = fork.set_area(rect.clone());
117147
fork.length_left = Math.round(fork.prev_ratio * fork.length());
118148
this.tile(ext, fork, fork.area);
@@ -132,7 +162,6 @@ export class AutoTiler {
132162
const [entity, fork] = this.forest.create_toplevel(win.entity, rect.clone(), workspace_id);
133163
this.forest.on_attach(entity, win.entity);
134164
fork.smart_gapped = smart_gaps;
135-
win.smart_gapped = smart_gaps;
136165

137166
this.tile(ext, fork, rect);
138167
}
@@ -490,6 +519,7 @@ export class AutoTiler {
490519
}
491520

492521
tile(ext: Ext, fork: Fork, area: Rectangle) {
522+
this.sync_smart_gapped(ext, fork);
493523
this.forest.tile(ext, fork, area);
494524
}
495525

0 commit comments

Comments
 (0)