Skip to content

Commit 8791171

Browse files
authored
fix(active-hint): Improvements to display of active hints
1 parent e5a80ea commit 8791171

File tree

5 files changed

+60
-18
lines changed

5 files changed

+60
-18
lines changed

dark.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
.pop-shell-active-hint {
2-
border-width: 5px;
32
border-style: solid;
43
border-color: #FBB86C;
54
border-radius: 5px;
65
box-shadow: inset 0 0 0 1px rgba(24, 23, 23, 0)
76
}
87

8+
.pop-shell-border-normal {
9+
border-width: 3px;
10+
}
11+
12+
.pop-shell-border-maximize {
13+
border-width: 3px;
14+
}
15+
916
.pop-shell-search-element:select{
1017
background: rgba(246, 246, 246, .2);
1118
border-radius: 5px;

light.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
.pop-shell-active-hint {
2-
border-width: 5px;
32
border-style: solid;
43
border-color: #FFAD00;
54
border-radius: 5px;
65
box-shadow: inset 0 0 0 1px rgba(200, 200, 200, 0);
76
}
87

8+
.pop-shell-border-normal {
9+
border-width: 3px;
10+
}
11+
12+
.pop-shell-border-maximize {
13+
border-width: 3px;
14+
}
15+
916
.pop-shell-search-element:select{
1017
background: rgba(0, 0, 0, .1);
1118
border-radius: 5px;
@@ -29,4 +36,4 @@
2936
.pop-shell-gaps-entry {
3037
/* Seems to get the width just right to fit 3 digits */
3138
width: 75px;
32-
}
39+
}

src/auto_tiler.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ import * as log from 'log';
66
import * as node from 'node';
77
import * as result from 'result';
88

9-
import type {Entity} from 'ecs';
10-
import type {Ext} from 'extension';
11-
import type {Forest} from 'forest';
12-
import type {Fork} from 'fork';
13-
import type {Rectangle} from 'rectangle';
14-
import type {Result} from 'result';
15-
import type {ShellWindow} from 'window';
16-
17-
const {Ok, Err, ERR} = result;
18-
const {NodeKind} = node;
9+
import type { Entity } from 'ecs';
10+
import type { Ext } from 'extension';
11+
import type { Forest } from 'forest';
12+
import type { Fork } from 'fork';
13+
import type { Rectangle } from 'rectangle';
14+
import type { Result } from 'result';
15+
import type { ShellWindow } from 'window';
16+
17+
const { Ok, Err, ERR } = result;
18+
const { NodeKind } = node;
1919
const Tags = Me.imports.tags;
2020

2121
export class AutoTiler {
@@ -57,6 +57,13 @@ export class AutoTiler {
5757
rect.height -= ext.gap_outer * 2;
5858
}
5959

60+
if (fork.left.kind === NodeKind.WINDOW) {
61+
const win = ext.windows.get(fork.left.entity);
62+
if (win) {
63+
win.smart_gapped = smart_gaps && fork.right === null;
64+
}
65+
}
66+
6067
fork.smart_gaps = smart_gaps;
6168

6269
let ratio;
@@ -87,6 +94,7 @@ export class AutoTiler {
8794
const [entity, fork] = this.forest.create_toplevel(win.entity, rect.clone(), workspace_id)
8895
this.attached.insert(win.entity, entity);
8996
fork.smart_gaps = smart_gaps;
97+
win.smart_gapped = smart_gaps;
9098

9199
this.tile(ext, fork, rect);
92100
this.log_tree_nodes(ext);

src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,7 @@ export class Ext extends Ecs.System<ExtEvent> {
10421042
break;
10431043
case 'smart-gaps':
10441044
this.on_smart_gap();
1045+
this.show_border_on_focused();
10451046
}
10461047
});
10471048

src/window.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ export class ShellWindow {
5252

5353
was_attached_to?: [Entity, boolean];
5454

55+
// True if this window is currently smart-gapped
56+
smart_gapped: boolean = false;
57+
5558
private was_hidden: boolean = false;
5659

5760
private window_app: any;
@@ -62,7 +65,7 @@ export class ShellWindow {
6265
xid_: new OnceCell()
6366
};
6467

65-
private _border: St.Bin = new St.Bin({ style_class: 'pop-shell-active-hint' });
68+
private _border: St.Bin = new St.Bin({ style_class: 'pop-shell-active-hint pop-shell-border-normal' });
6669

6770
private _border_size = 0;
6871

@@ -181,6 +184,15 @@ export class ShellWindow {
181184
return this.meta.get_maximized() !== 0;
182185
}
183186

187+
/**
188+
* Window is maximized, 0 gapped or smart gapped
189+
*/
190+
is_max_screen(): boolean {
191+
// log.debug(`title: ${this.meta.get_title()}`);
192+
// log.debug(`max: ${this.is_maximized()}, 0-gap: ${this.ext.settings.gap_inner() === 0}, smart: ${this.smart_gapped}`);
193+
return this.is_maximized() || this.ext.settings.gap_inner() === 0 || this.smart_gapped;
194+
}
195+
184196
is_tilable(ext: Ext): boolean {
185197
return !ext.contains_tag(this.entity, Tags.Floating)
186198
&& ext.tilable.get_or(this.entity, () => {
@@ -302,9 +314,8 @@ export class ShellWindow {
302314
show_border() {
303315
if (this.ext.settings.active_hint()) {
304316
let border = this._border;
305-
if (!this.is_maximized() &&
317+
if (!this.meta.is_fullscreen() &&
306318
!this.meta.minimized &&
307-
!this.meta.is_fullscreen() &&
308319
this.same_workspace()) {
309320
border.show();
310321
}
@@ -384,7 +395,8 @@ export class ShellWindow {
384395

385396
hide_border() {
386397
let border = this._border;
387-
border.hide();
398+
if (border)
399+
border.hide();
388400
}
389401

390402
private _update_border_layout() {
@@ -394,8 +406,15 @@ export class ShellWindow {
394406
let border = this._border;
395407
let borderSize = this._border_size;
396408

409+
if (!this.is_max_screen()) {
410+
border.remove_style_class_name('pop-shell-border-maximize');
411+
} else {
412+
borderSize = 0;
413+
border.add_style_class_name('pop-shell-border-maximize');
414+
}
415+
397416
border.set_position(frameX - borderSize, frameY - borderSize);
398-
border.set_size(frameWidth + 2 * borderSize, frameHeight + 2 * borderSize);
417+
border.set_size(frameWidth + (2 * borderSize), frameHeight + (2 * borderSize));
399418

400419
this.restack();
401420
}

0 commit comments

Comments
 (0)