Skip to content

Commit 1e52452

Browse files
committed
fix(dock): implement debounce for hot area trigger events
1 parent 80f8113 commit 1e52452

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/modules/dock/hotArea.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import '@girs/gjs';
44
import St from '@girs/st-17';
55
import Clutter from '@girs/clutter-17';
66
import GObject from '@girs/gobject-2.0';
7+
import GLib from '@girs/glib-2.0';
78
import Meta from '@girs/meta-17';
89
import Shell from '@girs/shell-17';
910

@@ -13,6 +14,7 @@ import type { DashBounds } from '../../ui/dash.ts';
1314

1415
const HOT_AREA_TRIGGER_SPEED = 150;
1516
const HOT_AREA_TRIGGER_TIMEOUT = 550;
17+
const HOT_AREA_DEBOUNCE_TIMEOUT = 250;
1618

1719
/**
1820
* Invisible input barrier at the bottom screen edge.
@@ -29,6 +31,7 @@ export class DockHotArea extends St.Widget {
2931
private _horizontalBarrier: Meta.Barrier | null = null;
3032
private _triggerAllowed = true;
3133
private _monitor: DashBounds;
34+
private _pointerDwellTimeoutId = 0;
3235

3336
_init(monitor: DashBounds) {
3437
super._init({ reactive: true, visible: true, name: 'aurora-dock-hot-area' });
@@ -45,7 +48,21 @@ export class DockHotArea extends St.Widget {
4548
}, this);
4649

4750
this.connectObject('enter-event', () => {
48-
if (this._triggerAllowed) this.emit('triggered');
51+
if (this._triggerAllowed) {
52+
this._pointerDwellTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, HOT_AREA_DEBOUNCE_TIMEOUT, () => {
53+
this.emit('triggered');
54+
this._pointerDwellTimeoutId = 0;
55+
return GLib.SOURCE_REMOVE;
56+
});
57+
}
58+
return Clutter.EVENT_PROPAGATE;
59+
}, this);
60+
61+
this.connectObject('leave-event', () => {
62+
if (this._pointerDwellTimeoutId) {
63+
GLib.source_remove(this._pointerDwellTimeoutId);
64+
this._pointerDwellTimeoutId = 0;
65+
}
4966
return Clutter.EVENT_PROPAGATE;
5067
}, this);
5168

@@ -70,6 +87,11 @@ export class DockHotArea extends St.Widget {
7087
global.display.disconnectObject(this);
7188
this._destroyBarrier();
7289

90+
if (this._pointerDwellTimeoutId) {
91+
GLib.source_remove(this._pointerDwellTimeoutId);
92+
this._pointerDwellTimeoutId = 0;
93+
}
94+
7395
this._pressureBarrier?.disconnectObject?.(this);
7496
this._pressureBarrier?.destroy?.();
7597
this._pressureBarrier = null;

0 commit comments

Comments
 (0)