1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
import options from 'options';
import Dock from './Dock.ts';
const hyprland = await Service.import('hyprland');
const apps = await Service.import('applications');
const { Gdk, Gtk } = imports.gi;
import type Gtk from 'gi://Gtk?version=3.0';
import { type WindowProps } from 'types/widgets/window';
import { type RevealerProps } from 'types/widgets/revealer';
import { type EventBoxProps } from 'types/widgets/eventbox';
/** @param {number} monitor */
const FloatingDock = (monitor: number): Gtk.Window & WindowProps => {
const update = () => {
const ws = Hyprland.getWorkspace(Hyprland.active.workspace.id);
if (Hyprland.getMonitor(monitor)?.name === ws?.monitor) self.reveal_child = ws?.windows === 0;
};
const revealer: Gtk.Revealer & RevealerProps = Widget.Revealer({
transition: 'slide_up',
transitionDuration: 90,
child: Dock(),
setup: self => self.hook(hyprland, update, 'client-added').hook(hyprland, update, 'client-removed').hook(hyprland.active.workspace, update),
});
const window = Widget.Window({
monitor,
//halign: 'fill',
halign: 'end',
//layer: "overlay",
layer: 'dock',
name: `dock${monitor}`,
click_through: false,
class_name: 'floating-dock',
// class_name: 'floating-dock-no-gap',
// class_name: "f-dock-wrap",
typeHint: Gdk.WindowTypeHint.DOCK,
exclusivity: 'false',
anchor: ['bottom'],
child: Widget.Box({
vertical: false,
halign: 'bottom',
hpack: 'start',
children: [
revealer,
Widget.Box({
class_name: 'padding',
css: 'padding: 9px; margin: 0;',
vertical: false,
halign: 'bottom',
hpack: 'start',
}),
],
}),
});
window
.on('enter-notify-event', () => {
revealer.reveal_child = true;
})
.on('leave-notify-event', () => {
revealer.reveal_child = false;
})
.bind('visible', options.bar.position, 'value', v => v !== 'left');
return window;
};
export default FloatingDock;
|