Skip to content

Commit 4a101d3

Browse files
committed
feat: restructure dock module by introducing hot area and intellihide functionality in separated files
1 parent 49193aa commit 4a101d3

4 files changed

Lines changed: 293 additions & 279 deletions

File tree

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { Module } from "./module.ts";
88
import { MODULE_REGISTRY, type ModuleDefinition } from "./registry.ts";
99

1010
import { ThemeChanger } from "./modules/themeChanger.ts";
11-
import { Dock } from "./modules/dock.ts";
11+
import { Dock } from "./modules/dock/index.ts";
1212
import { NoOverview } from "./modules/noOverview.ts";
1313
import { PipOnTop } from "./modules/pipOnTop.ts";
1414

src/modules/dock/hotArea.ts

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// @ts-nocheck
2+
import '@girs/gjs';
3+
4+
import St from '@girs/st-17';
5+
import Clutter from '@girs/clutter-17';
6+
import GObject from '@girs/gobject-2.0';
7+
import Meta from '@girs/meta-17';
8+
import Shell from '@girs/shell-17';
9+
10+
import * as Layout from '@girs/gnome-shell/ui/layout';
11+
12+
import type { DashBounds } from '../../ui/dash.ts';
13+
14+
const HOT_AREA_TRIGGER_SPEED = 150;
15+
const HOT_AREA_TRIGGER_TIMEOUT = 550;
16+
17+
/**
18+
* Invisible input barrier at the bottom screen edge.
19+
*
20+
* Uses a GNOME Shell PressureBarrier plus a thin reactive widget to detect
21+
* when the user pushes the pointer against the bottom edge, then emits
22+
* 'triggered' so the Dock module can reveal the dash.
23+
*/
24+
@GObject.registerClass({
25+
Signals: { triggered: {} },
26+
})
27+
export class DockHotArea extends St.Widget {
28+
private _pressureBarrier: any;
29+
private _horizontalBarrier: Meta.Barrier | null = null;
30+
private _triggerAllowed = true;
31+
private _monitor: DashBounds;
32+
33+
_init(monitor: DashBounds) {
34+
super._init({ reactive: true, visible: true, name: 'aurora-dock-hot-area' });
35+
this._monitor = monitor;
36+
37+
this._pressureBarrier = new Layout.PressureBarrier(
38+
HOT_AREA_TRIGGER_SPEED,
39+
HOT_AREA_TRIGGER_TIMEOUT,
40+
Shell.ActionMode.ALL
41+
);
42+
43+
this._pressureBarrier.connectObject('trigger', () => {
44+
if (this._triggerAllowed) this.emit('triggered');
45+
}, this);
46+
47+
this.connectObject('enter-event', () => {
48+
if (this._triggerAllowed) this.emit('triggered');
49+
return Clutter.EVENT_PROPAGATE;
50+
}, this);
51+
52+
// Suppress triggers while the user is dragging a window
53+
global.display.connectObject(
54+
'grab-op-begin', (_d: any, _w: any, op: Meta.GrabOp) => {
55+
if (op === Meta.GrabOp.MOVING) this._triggerAllowed = false;
56+
},
57+
'grab-op-end', (_d: any, _w: any, op: Meta.GrabOp) => {
58+
if (op === Meta.GrabOp.MOVING) this._triggerAllowed = true;
59+
},
60+
this
61+
);
62+
}
63+
64+
setGeometry(monitor: DashBounds): void {
65+
this._monitor = monitor;
66+
this._rebuildBarrier(monitor.width);
67+
}
68+
69+
override destroy(): void {
70+
global.display.disconnectObject(this);
71+
this._destroyBarrier();
72+
73+
this._pressureBarrier?.disconnectObject?.(this);
74+
this._pressureBarrier?.destroy?.();
75+
this._pressureBarrier = null;
76+
77+
super.destroy();
78+
}
79+
80+
private _rebuildBarrier(size: number): void {
81+
if (!this._pressureBarrier) return;
82+
83+
this._destroyBarrier();
84+
85+
const width = Number.isFinite(size) ? size : 0;
86+
const left = this._monitor.x;
87+
const bottom = this._monitor.y + this._monitor.height;
88+
89+
if (width <= 0 || !Number.isFinite(left) || !Number.isFinite(bottom)) return;
90+
91+
this._horizontalBarrier = new Meta.Barrier({
92+
backend: global.backend,
93+
x1: left,
94+
x2: left + width,
95+
y1: bottom,
96+
y2: bottom,
97+
directions: Meta.BarrierDirection.POSITIVE_Y,
98+
});
99+
100+
this._pressureBarrier.addBarrier(this._horizontalBarrier);
101+
}
102+
103+
private _destroyBarrier(): void {
104+
if (!this._horizontalBarrier) return;
105+
this._pressureBarrier?.removeBarrier(this._horizontalBarrier);
106+
this._horizontalBarrier.destroy();
107+
this._horizontalBarrier = null;
108+
}
109+
}

0 commit comments

Comments
 (0)