blob: a5ae3161f6b566c0c1234ce5f706e5d91acda7a7 (
plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
pragma ComponentBehavior: Bound
import "root:/widgets"
import "root:/services"
import "root:/config"
import QtQuick
Item {
id: root
property alias vertical: layout.vertical
property color colour: Appearance.colours.mauve
readonly property list<Workspace> workspaces: layout.children.filter(c => c.isWorkspace).sort((w1, w2) => w1.ws - w2.ws)
readonly property var occupied: Hyprland.workspaces.values.reduce((acc, curr) => {
acc[curr.id] = curr.lastIpcObject.windows > 0;
return acc;
}, {})
readonly property int groupOffset: Math.floor((Hyprland.activeWsId - 1) / BarConfig.workspaces.shown) * BarConfig.workspaces.shown
implicitWidth: layout.implicitWidth
implicitHeight: layout.implicitHeight
BoxLayout {
id: layout
spacing: 0
layer.enabled: true
Repeater {
model: BarConfig.workspaces.shown
Workspace {
vertical: root.vertical
occupied: root.occupied
groupOffset: root.groupOffset
}
}
}
Loader {
active: BarConfig.workspaces.occupiedBg
asynchronous: true
z: -1
anchors.fill: parent
sourceComponent: OccupiedBg {
vertical: root.vertical
workspaces: root.workspaces
occupied: root.occupied
groupOffset: root.groupOffset
}
}
Loader {
active: BarConfig.workspaces.activeIndicator
asynchronous: true
sourceComponent: ActiveIndicator {
color: root.colour
vertical: root.vertical
workspaces: root.workspaces
mask: layout
maskWidth: root.width
maskHeight: root.height
groupOffset: root.groupOffset
}
}
MouseArea {
anchors.fill: parent
onPressed: event => {
const ws = layout.childAt(event.x, event.y).index + root.groupOffset + 1;
if (Hyprland.activeWsId !== ws)
Hyprland.dispatch(`workspace ${ws}`);
}
onWheel: event => {
const activeWs = Hyprland.activeClient?.workspace?.name;
if (activeWs?.startsWith("special:"))
Hyprland.dispatch(`togglespecialworkspace ${activeWs.slice(8)}`);
else if (event.angleDelta.y < 0 || Hyprland.activeWsId > 1)
Hyprland.dispatch(`workspace r${event.angleDelta.y > 0 ? "-" : "+"}1`);
}
}
}
|