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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
import QtQuick
import Quickshell
import Quickshell.Wayland
import qs.Common
import qs.Services
PanelWindow {
id: root
property string blurNamespace: "dms:osd"
WlrLayershell.namespace: blurNamespace
property alias content: contentLoader.sourceComponent
property alias contentLoader: contentLoader
property var modelData
property bool shouldBeVisible: false
property int autoHideInterval: 2000
property bool enableMouseInteraction: false
property real osdWidth: Theme.iconSize + Theme.spacingS * 2
property real osdHeight: Theme.iconSize + Theme.spacingS * 2
property int animationDuration: Theme.mediumDuration
property var animationEasing: Theme.emphasizedEasing
signal osdShown
signal osdHidden
function show() {
if (SessionData.suppressOSD)
return;
if (shouldBeVisible) {
hideTimer.restart();
return;
}
OSDManager.showOSD(root);
closeTimer.stop();
shouldBeVisible = true;
visible = true;
hideTimer.restart();
osdShown();
}
function hide() {
shouldBeVisible = false;
closeTimer.restart();
}
function resetHideTimer() {
if (shouldBeVisible) {
hideTimer.restart();
}
}
function updateHoverState() {
let isHovered = (enableMouseInteraction && mouseArea.containsMouse) || osdContainer.childHovered;
if (enableMouseInteraction) {
if (isHovered) {
hideTimer.stop();
} else if (shouldBeVisible) {
hideTimer.restart();
}
}
}
function setChildHovered(hovered) {
osdContainer.childHovered = hovered;
updateHoverState();
}
screen: modelData
visible: false
Connections {
target: Quickshell
function onScreensChanged() {
if (!root.visible && !root.shouldBeVisible)
return;
const currentScreenName = root.screen?.name;
if (!currentScreenName) {
root.hide();
return;
}
for (let i = 0; i < Quickshell.screens.length; i++) {
if (Quickshell.screens[i].name === currentScreenName)
return;
}
root.shouldBeVisible = false;
root.visible = false;
hideTimer.stop();
closeTimer.stop();
osdHidden();
}
}
WlrLayershell.layer: {
switch (Quickshell.env("DMS_OSD_LAYER")) {
case "bottom":
console.warn("DankOSD: 'bottom' layer is not valid for OSDs. Defaulting to 'overlay' layer.");
return WlrLayershell.Overlay;
case "background":
console.warn("DankOSD: 'background' layer is not valid for OSDs. Defaulting to 'overlay' layer.");
return WlrLayershell.Overlay;
case "top":
return WlrLayershell.Top;
default:
return WlrLayershell.Overlay;
}
}
WlrLayershell.exclusiveZone: -1
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
WindowBlur {
targetWindow: root
blurX: shadowBuffer
blurY: shadowBuffer
blurWidth: shouldBeVisible ? alignedWidth : 0
blurHeight: shouldBeVisible ? alignedHeight : 0
blurRadius: Theme.cornerRadius
}
color: "transparent"
readonly property real dpr: CompositorService.getScreenScale(screen)
readonly property real screenWidth: screen.width
readonly property real screenHeight: screen.height
readonly property real shadowBuffer: 15
readonly property real alignedWidth: Theme.px(osdWidth, dpr)
readonly property real alignedHeight: Theme.px(osdHeight, dpr)
readonly property bool isVerticalLayout: SettingsData.osdPosition === SettingsData.Position.LeftCenter || SettingsData.osdPosition === SettingsData.Position.RightCenter
readonly property real barThickness: {
const defaultBar = SettingsData.barConfigs[0] || SettingsData.getBarConfig("default");
if (!defaultBar || !(defaultBar.visible ?? true))
return 0;
const innerPadding = defaultBar.innerPadding ?? 4;
const widgetThickness = Math.max(20, 26 + innerPadding * 0.6);
return Math.max(widgetThickness + innerPadding + 4, Theme.barHeight - 4 - (8 - innerPadding));
}
readonly property real barOffset: {
const defaultBar = SettingsData.barConfigs[0] || SettingsData.getBarConfig("default");
if (!defaultBar || !(defaultBar.visible ?? true))
return 0;
const spacing = defaultBar.spacing ?? 4;
const bottomGap = defaultBar.bottomGap ?? 0;
return barThickness + spacing + bottomGap;
}
readonly property real dockThickness: {
if (!SettingsData.showDock)
return 0;
return SettingsData.dockIconSize + SettingsData.dockSpacing * 2 + 10;
}
readonly property real dockOffset: {
if (!SettingsData.showDock || SettingsData.dockAutoHide || SettingsData.dockSmartAutoHide)
return 0;
return dockThickness + SettingsData.dockSpacing + SettingsData.dockBottomGap + SettingsData.dockMargin;
}
readonly property real alignedX: {
const margin = Theme.spacingM;
const centerX = (screenWidth - alignedWidth) / 2;
const defaultBar = SettingsData.barConfigs[0] || SettingsData.getBarConfig("default");
const barPos = defaultBar?.position ?? SettingsData.Position.Top;
switch (SettingsData.osdPosition) {
case SettingsData.Position.Left:
case SettingsData.Position.Bottom:
const leftBarOffset = barPos === SettingsData.Position.Left ? barOffset : 0;
const leftDockOffset = SettingsData.dockPosition === SettingsData.Position.Left ? dockOffset : 0;
return Theme.snap(margin + Math.max(leftBarOffset, leftDockOffset), dpr);
case SettingsData.Position.Top:
case SettingsData.Position.Right:
const rightBarOffset = barPos === SettingsData.Position.Right ? barOffset : 0;
const rightDockOffset = SettingsData.dockPosition === SettingsData.Position.Right ? dockOffset : 0;
return Theme.snap(screenWidth - alignedWidth - margin - Math.max(rightBarOffset, rightDockOffset), dpr);
case SettingsData.Position.LeftCenter:
const leftCenterBarOffset = barPos === SettingsData.Position.Left ? barOffset : 0;
const leftCenterDockOffset = SettingsData.dockPosition === SettingsData.Position.Left ? dockOffset : 0;
return Theme.snap(margin + Math.max(leftCenterBarOffset, leftCenterDockOffset), dpr);
case SettingsData.Position.RightCenter:
const rightCenterBarOffset = barPos === SettingsData.Position.Right ? barOffset : 0;
const rightCenterDockOffset = SettingsData.dockPosition === SettingsData.Position.Right ? dockOffset : 0;
return Theme.snap(screenWidth - alignedWidth - margin - Math.max(rightCenterBarOffset, rightCenterDockOffset), dpr);
case SettingsData.Position.TopCenter:
case SettingsData.Position.BottomCenter:
default:
return Theme.snap(centerX, dpr);
}
}
readonly property real alignedY: {
const margin = Theme.spacingM;
const centerY = (screenHeight - alignedHeight) / 2;
const defaultBar = SettingsData.barConfigs[0] || SettingsData.getBarConfig("default");
const barPos = defaultBar?.position ?? SettingsData.Position.Top;
switch (SettingsData.osdPosition) {
case SettingsData.Position.Top:
case SettingsData.Position.Left:
case SettingsData.Position.TopCenter:
const topBarOffset = barPos === SettingsData.Position.Top ? barOffset : 0;
const topDockOffset = SettingsData.dockPosition === SettingsData.Position.Top ? dockOffset : 0;
return Theme.snap(margin + Math.max(topBarOffset, topDockOffset), dpr);
case SettingsData.Position.Right:
case SettingsData.Position.Bottom:
case SettingsData.Position.BottomCenter:
const bottomBarOffset = barPos === SettingsData.Position.Bottom ? barOffset : 0;
const bottomDockOffset = SettingsData.dockPosition === SettingsData.Position.Bottom ? dockOffset : 0;
return Theme.snap(screenHeight - alignedHeight - margin - Math.max(bottomBarOffset, bottomDockOffset), dpr);
case SettingsData.Position.LeftCenter:
case SettingsData.Position.RightCenter:
default:
return Theme.snap(centerY, dpr);
}
}
anchors {
top: true
left: true
}
WlrLayershell.margins {
left: Math.max(0, Theme.snap(alignedX - shadowBuffer, dpr))
top: Math.max(0, Theme.snap(alignedY - shadowBuffer, dpr))
}
implicitWidth: alignedWidth + (shadowBuffer * 2)
implicitHeight: alignedHeight + (shadowBuffer * 2)
Timer {
id: hideTimer
interval: autoHideInterval
repeat: false
onTriggered: {
if (!enableMouseInteraction || !mouseArea.containsMouse) {
hide();
} else {
hideTimer.restart();
}
}
}
Timer {
id: closeTimer
interval: animationDuration + 50
onTriggered: {
if (!shouldBeVisible) {
visible = false;
osdHidden();
}
}
}
Item {
id: osdContainer
x: shadowBuffer
y: shadowBuffer
width: alignedWidth
height: alignedHeight
opacity: shouldBeVisible ? 1 : 0
scale: shouldBeVisible ? 1 : 0.9
property bool childHovered: false
readonly property real popupSurfaceAlpha: Theme.popupTransparency
Rectangle {
id: background
anchors.fill: parent
radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.surfaceContainer, osdContainer.popupSurfaceAlpha)
border.color: BlurService.enabled ? BlurService.borderColor : Theme.outlineMedium
border.width: BlurService.enabled ? BlurService.borderWidth : 1
z: -1
}
ElevationShadow {
id: bgShadowLayer
anchors.fill: parent
visible: osdContainer.popupSurfaceAlpha >= 0.95
z: -1
level: Theme.elevationLevel3
fallbackOffset: 6
targetRadius: Theme.cornerRadius
targetColor: Theme.withAlpha(Theme.surfaceContainer, osdContainer.popupSurfaceAlpha)
borderColor: Theme.outlineMedium
borderWidth: 1
shadowEnabled: Theme.elevationEnabled && SettingsData.popoutElevationEnabled && Quickshell.env("DMS_DISABLE_LAYER") !== "true" && Quickshell.env("DMS_DISABLE_LAYER") !== "1"
layer.textureSize: Qt.size(Math.round(width * root.dpr), Math.round(height * root.dpr))
layer.textureMirroring: ShaderEffectSource.MirrorVertically
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: enableMouseInteraction
acceptedButtons: Qt.NoButton
propagateComposedEvents: true
z: -1
onContainsMouseChanged: updateHoverState()
}
onChildHoveredChanged: updateHoverState()
Loader {
id: contentLoader
anchors.fill: parent
active: root.visible
asynchronous: false
}
Behavior on opacity {
NumberAnimation {
duration: animationDuration
easing.type: animationEasing
}
}
Behavior on scale {
NumberAnimation {
duration: animationDuration
easing.type: animationEasing
}
}
}
mask: Region {
item: bgShadowLayer
}
}
|