blob: c8c017c3e05e7cdab28911b35e520e4f32012a62 (
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
import Quickshell
import QtQuick
import qs.Services
import Quickshell.Widgets
import QtQuick.Layouts
Row {
id: workspaces
property var ignoreWorkspaces: @ignore_workspaces@
height: parent.height
anchors.verticalCenter: parent.verticalCenter
spacing: 0
Repeater {
model: ScriptModel {
values: {
let currWorkspaces = NiriService.workspaces;
const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces);
currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name));
currWorkspaces.sort((a, b) => {
if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x)
return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x
if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y)
return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y
return a.idx - b.idx;
});
return currWorkspaces;
}
}
Item {
id: wsItem
property var workspaceData: modelData
width: wsLabel.contentWidth + 8
height: parent.height
anchors.verticalCenter: parent.verticalCenter
WrapperMouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
enabled: true
onClicked: {
NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {})
}
Rectangle {
anchors.fill: parent
color: {
if (mouseArea.containsMouse) {
return "#33808080";
}
return "transparent";
}
Text {
id: wsLabel
anchors.centerIn: parent
font.pointSize: 10
font.family: "Fira Sans"
color: {
if (workspaceData.is_active)
return "#23fd00";
if (workspaceData.active_window_id === null)
return "#555";
return "white";
}
text: workspaceData.name ? workspaceData.name : workspaceData.idx
}
}
}
PopupWindow {
id: tooltip
property bool nextVisible: (mouseArea.containsMouse || tooltipMouseArea.containsMouse) && [...windowsModel.values].length > 0
anchor {
item: mouseArea
edges: Edges.Bottom | Edges.Left
}
visible: false
onNextVisibleChanged: hangTimer.restart()
Timer {
id: hangTimer
interval: 100
onTriggered: tooltip.visible = tooltip.nextVisible
}
implicitWidth: tooltipContent.implicitWidth
implicitHeight: tooltipContent.implicitHeight
color: "black"
WrapperMouseArea {
id: tooltipMouseArea
hoverEnabled: true
enabled: true
anchors.fill: parent
WrapperItem {
id: tooltipContent
margin: 0
ColumnLayout {
spacing: 0
Repeater {
model: ScriptModel {
id: windowsModel
values: {
let currWindows = Array.from(NiriService.windows).filter(win => win.workspace_id == wsItem.workspaceData.id);
currWindows.sort((a, b) => {
if (a.is_floating !== b.is_floating)
return b.is_floating - a.is_floating;
if (a.layout.tile_pos_in_workspace_view?.[0] !== b.layout.tile_pos_in_workspace_view?.[0])
return a.layout.tile_pos_in_workspace_view?.[0] - b.layout.tile_pos_in_workspace_view?.[0]
if (a.layout.tile_pos_in_workspace_view?.[1] !== b.layout.tile_pos_in_workspace_view?.[1])
return a.layout.tile_pos_in_workspace_view?.[1] - b.layout.tile_pos_in_workspace_view?.[1]
if (a.layout.pos_in_scrolling_layout?.[0] !== b.layout.pos_in_scrolling_layout?.[0])
return a.layout.pos_in_scrolling_layout?.[0] - b.layout.pos_in_scrolling_layout?.[0]
if (a.layout.pos_in_scrolling_layout?.[1] !== b.layout.pos_in_scrolling_layout?.[1])
return a.layout.pos_in_scrolling_layout?.[1] - b.layout.pos_in_scrolling_layout?.[1]
if (a.app_id !== b.app_id)
return a.app_id.localeCompare(b.app_id);
return a.title.localeCompare(b.title);
});
return currWindows;
}
}
WrapperMouseArea {
id: windowMouseArea
property var windowData: modelData
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
enabled: true
Layout.fillWidth: true
onClicked: {
NiriService.sendCommand({ "Action": { "FocusWindow": { "id": windowData.id } } }, _ => {})
}
WrapperRectangle {
color: windowMouseArea.containsMouse ? "#33808080" : "transparent";
anchors.fill: parent
WrapperItem {
anchors.fill: parent
margin: 4
Text {
id: windowLabel
font.pointSize: 10
font.family: "Fira Sans"
color: {
if (windowData.is_focused)
return "#23fd00";
if (NiriService.workspaces.find(ws => ws.id == windowData.workspace_id)?.active_window_id == windowData.id)
return "white";
return "#555";
}
text: windowData.title
horizontalAlignment: Text.AlignLeft
}
}
}
}
}
}
}
}
}
}
}
}
|