blob: 893832915fb002541cc72558ae78fbbd851dc5f6 (
plain) (
blame)
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
|
import QtQuick
import QtQuick.Effects
import Quickshell
import Quickshell.Io
import Quickshell.Widgets
import Quickshell.Wayland
import Quickshell.Hyprland
import Qt5Compat.GraphicalEffects
Item {
id: thumbContainer
property var hWin: null
property var wHandle:null
property string winKey: ''
property real thumbW: -1
property real thumbH: -1
property var clientInfo: {}
property bool hovered: false
property real targetX: -1000
property real targetY: -1000
property real targetZ: 0
property real targetRotation: 0
property bool moveCursorToActiveWindow: false
width: thumbW
height: thumbH
x: 0
y: 0
z: targetZ
rotation: 0
visible: !!wHandle
NumberAnimation {
id: animX
target: thumbContainer
property: "x"
duration: root.animateWindows ? 100 : 0
easing.type: Easing.OutQuad
}
NumberAnimation {
id: animY
target: thumbContainer
property: "y"
duration: root.animateWindows ? 100 : 0
easing.type: Easing.OutQuad
}
NumberAnimation {
id: animRotation
target: thumbContainer
property: "rotation"
duration: 400
easing.type: Easing.OutBack // Effetto rimbalzo/inerzia
easing.overshoot: 1.2
}
function updateLastPos() {
var lp = root.lastPositions || ({})
var prev = lp[winKey] || ({})
prev.x = x
prev.y = y
lp[winKey] = prev
root.lastPositions = lp
}
onTargetXChanged: {
if (!root.animateWindows) {
x = targetX
updateLastPos()
return
}
var lp = root.lastPositions || ({})
var prev = lp[winKey]
var startX = (prev && prev.x !== undefined) ? prev.x : targetX
if (startX === targetX) {
x = targetX
updateLastPos()
return
}
animX.stop()
animX.from = startX
animX.to = targetX
animX.start()
}
onTargetYChanged: {
if (!root.animateWindows) {
y = targetY
updateLastPos()
return
}
var lp = root.lastPositions || ({})
var prev = lp[winKey]
var startY = (prev && prev.y !== undefined) ? prev.y : targetY
if (startY === targetY) {
y = targetY
updateLastPos()
return
}
animY.stop()
animY.from = startY
animY.to = targetY
animY.start()
}
onTargetRotationChanged: {
rotation = targetRotation
animRotation.stop()
animRotation.from = 0
animRotation.to = targetRotation
animRotation.start()
}
onXChanged: updateLastPos()
onYChanged: updateLastPos()
Component.onCompleted: {
rotation = targetRotation
if (!root.animateWindows) {
x = targetX
y = targetY
updateLastPos()
}
}
function activateWindow() {
if (!hWin) return
var targetIsSpecial = (hWin?.workspace ?? 0) < 0 || (hWin?.workspace?.name ?? "").startsWith("special")
if (root.specialActive && !targetIsSpecial) {
Hyprland.dispatch("togglespecialworkspace")
}
if (hWin.workspace) {
hWin.workspace.activate()
}
root.toggleExpose()
Hyprland.dispatch("focuswindow address:0x" + hWin.address)
Hyprland.dispatch("alterzorder top")
if (thumbContainer.moveCursorToActiveWindow) {
var cx = clientInfo.at[0] + (clientInfo.size[0]/2)
var cy = clientInfo.at[1] + (clientInfo.size[1]/2)
Hyprland.dispatch("movecursor " + cx + " " + cy)
}
}
function closeWindow() {
if (!hWin) return
Hyprland.dispatch("closewindow address:0x" + hWin.address)
}
function refreshThumb() {
if (thumbLoader.item) {
thumbLoader.item.captureFrame()
}
}
Item {
id: card
anchors.fill: parent
scale: thumbContainer.hovered ? 1.05 : 0.95
transformOrigin: Item.Center
Behavior on scale {
NumberAnimation { duration: 100; easing.type: Easing.OutQuad }
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
onEntered: {
exposeArea.currentIndex = index
}
onClicked: event => {
exposeArea.currentIndex = index
if (event.button === Qt.LeftButton) {
thumbContainer.activateWindow()
}
if (event.button === Qt.MiddleButton) {
thumbContainer.closeWindow()
}
}
onExited: {
if (exposeArea.currentIndex === index) {
exposeArea.currentIndex = -1
}
}
}
RectangularShadow {
anchors.fill: parent
radius: 16
blur: 24
spread: 10
color: "#55000000"
cached: true
}
Loader {
id: thumbLoader
anchors.fill: parent
active: root.isActive && !!thumbContainer.wHandle
sourceComponent: ScreencopyView {
id: thumb
anchors.fill: parent
captureSource: thumbContainer.wHandle
live: root.liveCapture && root.isActive
paintCursor: false
visible: root.isActive && thumbContainer.wHandle && hasContent
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Rectangle {
width: thumb.width
height: thumb.height
radius: 16
}
}
Rectangle {
anchors.fill: parent
color: thumbContainer.hovered ? "transparent": "#33000000"
border.width : thumbContainer.hovered ? 3 : 1
border.color : thumbContainer.hovered ? m3.m3Primary : m3.m3Secondary
radius: 16
}
}
}
Rectangle {
id: badge
z: 100
width: Math.min(titleText.implicitWidth + 24, thumbContainer.thumbW * 0.75)
height: titleText.implicitHeight + 12
x: (card.width - width) / 2
y: card.height - height - (card.height * 0.08)
radius: 12
color: thumbContainer.hovered ? "#FF000000" : "#CC000000"
border.width : 1
border.color : "#ff464646"
Text {
id: titleText
anchors.centerIn: parent
width: parent.width - 16
text: hWin.title
color: "white"
font.pixelSize: thumbContainer.hovered ? 13 : 12
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
}
}
|