Marble Magic Lamp: S-shaped Bezier path with gravity timing, 10% scale at the end, single shader animation
@@ -13,11 +13,13 @@ acceleration from rest) for 1.5 screen heights.
13
13
## Marble Magic Lamp (minimize)
14
14
15
15
**NL** – `kwin6_effect_marble_minimize`: bij minimaliseren vormt het venster zich net zo om tot
16
een knikker, pauzeert, en valt dan in een rechte lijn met zwaartekracht (vanuit stilstand) naar
17
zijn taakbalkknop. Herstellen speelt de omgekeerde animatie (knikker stijgt op van de taakbalkknop, pauze, vouwt open). Zelfde instellingen en defaults.
16
een knikker, pauzeert, en valt dan met zwaartekracht (vanuit stilstand) langs een S-vormige Bezier-curve
17
(loodrecht uit het venster, loodrecht de taakbalk in) naar zijn taakbalkknop; in de laatste 10% krimpt
18
hij naar 10%. Herstellen speelt de omgekeerde animatie (knikker stijgt op van de taakbalkknop, pauze, vouwt open). Zelfde instellingen en defaults.
18
19
19
20
**EN** – `kwin6_effect_marble_minimize`: on minimize the window becomes the same marble, pauses,
20
then falls in a straight line under gravity (from rest) to its taskbar entry. Restore plays it in
21
then falls under gravity (from rest) along an S-shaped Bezier path (perpendicular to the
22
taskbar edge at both ends) to its taskbar entry, shrinking to 10% over the last 10% of the path. Restore plays it in
21
23
reverse (marble rises from the taskbar entry, pauses, unfolds into the window). Same settings and defaults. It replaces the active minimize animation (e.g. Magic Lamp).
22
24
23
25
## Installatie / Installation
@@ -13,11 +13,13 @@ acceleration from rest) for 1.5 screen heights.13
## Marble Magic Lamp (minimize)13
## Marble Magic Lamp (minimize)14
14
15
**NL** – `kwin6_effect_marble_minimize`: bij minimaliseren vormt het venster zich net zo om tot15
**NL** – `kwin6_effect_marble_minimize`: bij minimaliseren vormt het venster zich net zo om tot16
een knikker, pauzeert, en valt dan in een rechte lijn met zwaartekracht (vanuit stilstand) naar16
een knikker, pauzeert, en valt dan met zwaartekracht (vanuit stilstand) langs een S-vormige Bezier-curve17
zijn taakbalkknop. Herstellen speelt de omgekeerde animatie (knikker stijgt op van de taakbalkknop, pauze, vouwt open). Zelfde instellingen en defaults.17
(loodrecht uit het venster, loodrecht de taakbalk in) naar zijn taakbalkknop; in de laatste 10% krimpt18
hij naar 10%. Herstellen speelt de omgekeerde animatie (knikker stijgt op van de taakbalkknop, pauze, vouwt open). Zelfde instellingen en defaults.18
19
19
**EN** – `kwin6_effect_marble_minimize`: on minimize the window becomes the same marble, pauses,20
**EN** – `kwin6_effect_marble_minimize`: on minimize the window becomes the same marble, pauses,20
then falls in a straight line under gravity (from rest) to its taskbar entry. Restore plays it in21
then falls under gravity (from rest) along an S-shaped Bezier path (perpendicular to the22
taskbar edge at both ends) to its taskbar entry, shrinking to 10% over the last 10% of the path. Restore plays it in21
reverse (marble rises from the taskbar entry, pauses, unfolds into the window). Same settings and defaults. It replaces the active minimize animation (e.g. Magic Lamp).23
reverse (marble rises from the taskbar entry, pauses, unfolds into the window). Same settings and defaults. It replaces the active minimize animation (e.g. Magic Lamp).22
24
23
## Installatie / Installation25
## Installatie / Installation@@ -192,30 +192,79 @@ class BurnMyWindowsMarbleMinimizeEffect {
192
192
});
193
193
}
194
194
195
// ---- S-shaped cubic Bezier path from the marble (window centre) to the taskbar entry ----
196
// Start and end tangents are perpendicular to the taskbar edge (derived from where the
197
// icon sits on the screen). Returns N segments of equal arc length with gravity timing:
198
// s = 0.5 g t^2 from rest -> t(s) = sqrt(2 s / g).
199
buildPath(window, ir) {
200
const wr = window.geometry;
201
const dx = (ir.x + ir.width / 2) - (wr.x + wr.width / 2);
202
const dy = (ir.y + ir.height / 2) - (wr.y + wr.height / 2);
203
let vs = {x: 0, y: 0, width: 1920, height: 1080};
204
try { const g = effects.virtualScreenGeometry; if (g && g.width) vs = g; } catch (e) {}
205
const cx = ir.x + ir.width / 2, cy = ir.y + ir.height / 2;
206
const dist = [cy - vs.y, vs.y + vs.height - cy, cx - vs.x, vs.x + vs.width - cx]; // top,bottom,left,right
207
const normals = [[0, -1], [0, 1], [-1, 0], [1, 0]];
208
let k = 1; for (let i = 0; i < 4; i++) if (dist[i] < dist[k]) k = i; // bottom is default
209
const n = normals[k];
210
const along = Math.max(60, Math.abs(dx * n[0] + dy * n[1]));
211
const h = 0.55 * along; // tangent handle length
212
const P = [[0, 0], [n[0] * h, n[1] * h], [dx - n[0] * h, dy - n[1] * h], [dx, dy]];
213
const bez = (t) => {
214
const u = 1 - t, a = u * u * u, b = 3 * u * u * t, c = 3 * u * t * t, d = t * t * t;
215
return [a * P[0][0] + b * P[1][0] + c * P[2][0] + d * P[3][0], a * P[0][1] + b * P[1][1] + c * P[2][1] + d * P[3][1]];
216
};
217
// numeric arc length
218
const M = 200, pts = [], cum = [0];
219
for (let i = 0; i <= M; i++) pts.push(bez(i / M));
220
for (let i = 1; i <= M; i++) cum.push(cum[i - 1] + Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]));
221
const L = Math.max(1, cum[M]);
222
const N = 20, nodes = [];
223
let j = 0;
224
for (let i = 0; i <= N; i++) {
225
const s = L * i / N;
226
while (j < M && cum[j + 1] < s) j++;
227
const f = j < M ? (s - cum[j]) / Math.max(1e-6, cum[j + 1] - cum[j]) : 0;
228
const q = j < M ? [pts[j][0] + (pts[j + 1][0] - pts[j][0]) * f, pts[j][1] + (pts[j + 1][1] - pts[j][1]) * f] : pts[M];
229
nodes.push({x: q[0], y: q[1], t: animationTime(Math.round(1000 * Math.sqrt(2 * s / this.gravity)))});
230
}
231
return {nodes: nodes, length: L, total: nodes[N].t};
232
}
233
234
segAnim(window, a, b, dur, extra) {
235
const anims = [{ type: Effect.Translation, from: {value1: a.x, value2: a.y}, to: {value1: b.x, value2: b.y} },
236
{ type: Effect.Opacity, from: 1.0, to: 1.0 }];
237
if (extra) anims.push(extra);
238
window.bmwSegEnd = Date.now() + Math.max(1, dur) - 8;
239
return animate({ window: window, curve: QEasingCurve.Linear, duration: Math.max(1, dur), animations: anims });
240
}
241
195
242
slotWindowMinimized(window) {
196
243
if (effects.hasActiveFullScreenEffect) return;
197
244
const ir = window.iconGeometry;
198
245
if (!ir || ir.width == 0 || ir.height == 0) return; // no taskbar entry
199
246
this.stopAll(window);
200
const wr = window.geometry;
201
const dx = (ir.x + ir.width / 2) - (wr.x + wr.width / 2);
202
const dy = (ir.y + ir.height / 2) - (wr.y + wr.height / 2);
203
const dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
204
// straight-line free fall from rest: d = 0.5 g t^2 -> t = sqrt(2d/g)
205
const fall = animationTime(Math.round(1000 * Math.sqrt(2 * dist / this.gravity)));
247
const path = this.buildPath(window, ir);
206
248
const morph = this.duration + this.pause;
249
const total = morph + path.total;
207
250
effect.setUniform(this.shader, "uForOpening", 0.0);
208
251
effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);
209
effect.setUniform(this.shader, "uDuration", (morph + fall) * 0.001);
210
effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, morph));
211
// phase 1: morph + pause; its end starts the fall (no gap, no full-window frame)
252
effect.setUniform(this.shader, "uDuration", total * 0.001);
253
effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, total));
254
// ONE shader animation over the whole minimize (same setup as restore, which renders fine);
255
// a little longer than the path so the marble is drawn until the window is hidden.
212
256
window.bmwMinAnimation = animate({
213
window: window, curve: QEasingCurve.Linear, duration: morph,
257
window: window, curve: QEasingCurve.Linear, duration: total + 150,
214
258
animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: 1.0 },
215
259
{ type: Effect.Opacity, from: 1.0, to: 1.0 }]
216
260
});
217
window.bmwFall = {dx: dx, dy: dy, duration: fall};
218
window.bmwFallPending = true;
261
// marker for the end of morph + pause; when it ends the path traversal starts
262
window.bmwMarbleDone = animate({
263
window: window, curve: QEasingCurve.Linear, duration: morph,
264
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: 0.0, value2: 0.0} }]
265
});
266
window.bmwPath = path; window.bmwSeg = -1; window.bmwMode = "min";
267
window.bmwSegEnd = Date.now() + morph - 8;
219
268
}
220
269
221
270
slotWindowUnminimized(window) {
@@ -223,14 +272,10 @@ class BurnMyWindowsMarbleMinimizeEffect {
223
272
const ir = window.iconGeometry;
224
273
this.stopAll(window);
225
274
if (!ir || ir.width == 0 || ir.height == 0) return;
226
// exact reverse: marble rises from the taskbar entry (reverse of the fall timing),
227
// rests, then unfolds back into the window. Window is full only at the very end.
228
const wr = window.geometry;
229
const dx = (ir.x + ir.width / 2) - (wr.x + wr.width / 2);
230
const dy = (ir.y + ir.height / 2) - (wr.y + wr.height / 2);
231
const dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
232
const fall = animationTime(Math.round(1000 * Math.sqrt(2 * dist / this.gravity)));
233
const total = this.duration + this.pause + fall;
275
// exact reverse: marble comes up the same S-path (reverse gravity timing), growing from
276
// 10% to 100% over the first 10% of the path, rests, then unfolds into the window.
277
const path = this.buildPath(window, ir);
278
const total = this.duration + this.pause + path.total;
234
279
effect.setUniform(this.shader, "uForOpening", 0.0);
235
280
effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);
236
281
effect.setUniform(this.shader, "uDuration", total * 0.001);
@@ -239,30 +284,58 @@ class BurnMyWindowsMarbleMinimizeEffect {
239
284
window: window, curve: QEasingCurve.Linear, duration: total,
240
285
animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 1.0, to: 0.0 }]
241
286
});
242
// OutQuad = time-reversed InQuad: fast at the taskbar, decelerating to rest
243
window.bmwRiseAnimation = animate({
244
window: window, curve: QEasingCurve.OutQuad, duration: fall,
245
animations: [{ type: Effect.Translation, from: {value1: dx, value2: dy}, to: {value1: 0.0, value2: 0.0} }]
287
const T = path.total, nd = path.nodes, N = nd.length - 1;
288
// reversed timing: going from node N to node N-1 takes (t_N - t_{N-1}) etc.
289
window.bmwScaleAnimation = animate({
290
window: window, curve: QEasingCurve.InOutSine, duration: Math.max(1, T - nd[N - 2].t),
291
animations: [{ type: Effect.Scale, from: {value1: 0.1, value2: 0.1}, to: {value1: 1.0, value2: 1.0} }]
246
292
});
293
window.bmwPath = path; window.bmwSeg = N; window.bmwMode = "rise";
294
window.bmwSegAnimation = this.segAnim(window, nd[N], nd[N - 1], nd[N].t - nd[N - 1].t);
247
295
}
248
296
249
297
stopAll(window) {
250
window.bmwFallPending = false;
251
for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwFallAnimation", "bmwUnminAnimation", "bmwRiseAnimation"]) {
298
window.bmwMode = null;
299
for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwSegAnimation", "bmwScaleAnimation",
300
"bmwTailAnimation", "bmwUnminAnimation"]) {
252
301
if (window[k]) { cancel(window[k]); delete window[k]; }
253
302
}
254
303
}
255
304
305
// Chain the path segments. KWin reports ids as 0 here, so we use our own state.
256
306
slotAnimationEnded(window, id) {
257
if (!window || !window.bmwFallPending) return; // first end = marble marker
258
window.bmwFallPending = false;
259
const f = window.bmwFall;
260
window.bmwFallAnimation = animate({
261
window: window, curve: QEasingCurve.InQuad, duration: f.duration,
262
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: f.dx, value2: f.dy} },
263
{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 1.0, to: 1.0 },
264
{ type: Effect.Opacity, from: 1.0, to: 1.0 }]
265
});
307
if (!window || !window.bmwMode) return;
308
if (window.bmwSegEnd && Date.now() < window.bmwSegEnd) return; // another animation ended
309
const nd = window.bmwPath.nodes, N = nd.length - 1;
310
if (window.bmwMode == "min") {
311
if (window.bmwSeg >= N) return; // already in the tail
312
window.bmwSeg++;
313
const i = window.bmwSeg;
314
if (i == N) {
315
// arrived: invisible hold at the icon (scale 10%) until the shader animation ends
316
window.bmwTailAnimation = animate({
317
window: window, curve: QEasingCurve.Linear, duration: 200,
318
animations: [{ type: Effect.Translation, from: {value1: nd[N].x, value2: nd[N].y}, to: {value1: nd[N].x, value2: nd[N].y} },
319
{ type: Effect.Scale, from: {value1: 0.1, value2: 0.1}, to: {value1: 0.1, value2: 0.1} },
320
{ type: Effect.Opacity, from: 0.0, to: 0.0 }]
321
});
322
window.bmwMode = null;
323
return;
324
}
325
let extra = null;
326
if (i == N - 2) { // last 10% of arc length: 100% -> 10%
327
window.bmwScaleAnimation = animate({
328
window: window, curve: QEasingCurve.InOutSine, duration: Math.max(1, nd[N].t - nd[N - 2].t),
329
animations: [{ type: Effect.Scale, from: {value1: 1.0, value2: 1.0}, to: {value1: 0.1, value2: 0.1} }]
330
});
331
}
332
window.bmwSegAnimation = this.segAnim(window, nd[i], nd[i + 1], nd[i + 1].t - nd[i].t, extra);
333
} else if (window.bmwMode == "rise") {
334
window.bmwSeg--;
335
const i = window.bmwSeg;
336
if (i <= 0) { window.bmwMode = null; return; }
337
window.bmwSegAnimation = this.segAnim(window, nd[i], nd[i - 1], nd[i].t - nd[i - 1].t);
338
}
266
339
}
267
340
268
341
slotWindowDataChanged(window, role) {
@@ -192,30 +192,79 @@ class BurnMyWindowsMarbleMinimizeEffect {192
});192
});193
}193
}194
194
195
// ---- S-shaped cubic Bezier path from the marble (window centre) to the taskbar entry ----196
// Start and end tangents are perpendicular to the taskbar edge (derived from where the197
// icon sits on the screen). Returns N segments of equal arc length with gravity timing:198
// s = 0.5 g t^2 from rest -> t(s) = sqrt(2 s / g).199
buildPath(window, ir) {200
const wr = window.geometry;201
const dx = (ir.x + ir.width / 2) - (wr.x + wr.width / 2);202
const dy = (ir.y + ir.height / 2) - (wr.y + wr.height / 2);203
let vs = {x: 0, y: 0, width: 1920, height: 1080};204
try { const g = effects.virtualScreenGeometry; if (g && g.width) vs = g; } catch (e) {}205
const cx = ir.x + ir.width / 2, cy = ir.y + ir.height / 2;206
const dist = [cy - vs.y, vs.y + vs.height - cy, cx - vs.x, vs.x + vs.width - cx]; // top,bottom,left,right207
const normals = [[0, -1], [0, 1], [-1, 0], [1, 0]];208
let k = 1; for (let i = 0; i < 4; i++) if (dist[i] < dist[k]) k = i; // bottom is default209
const n = normals[k];210
const along = Math.max(60, Math.abs(dx * n[0] + dy * n[1]));211
const h = 0.55 * along; // tangent handle length212
const P = [[0, 0], [n[0] * h, n[1] * h], [dx - n[0] * h, dy - n[1] * h], [dx, dy]];213
const bez = (t) => {214
const u = 1 - t, a = u * u * u, b = 3 * u * u * t, c = 3 * u * t * t, d = t * t * t;215
return [a * P[0][0] + b * P[1][0] + c * P[2][0] + d * P[3][0], a * P[0][1] + b * P[1][1] + c * P[2][1] + d * P[3][1]];216
};217
// numeric arc length218
const M = 200, pts = [], cum = [0];219
for (let i = 0; i <= M; i++) pts.push(bez(i / M));220
for (let i = 1; i <= M; i++) cum.push(cum[i - 1] + Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]));221
const L = Math.max(1, cum[M]);222
const N = 20, nodes = [];223
let j = 0;224
for (let i = 0; i <= N; i++) {225
const s = L * i / N;226
while (j < M && cum[j + 1] < s) j++;227
const f = j < M ? (s - cum[j]) / Math.max(1e-6, cum[j + 1] - cum[j]) : 0;228
const q = j < M ? [pts[j][0] + (pts[j + 1][0] - pts[j][0]) * f, pts[j][1] + (pts[j + 1][1] - pts[j][1]) * f] : pts[M];229
nodes.push({x: q[0], y: q[1], t: animationTime(Math.round(1000 * Math.sqrt(2 * s / this.gravity)))});230
}231
return {nodes: nodes, length: L, total: nodes[N].t};232
}233
234
segAnim(window, a, b, dur, extra) {235
const anims = [{ type: Effect.Translation, from: {value1: a.x, value2: a.y}, to: {value1: b.x, value2: b.y} },236
{ type: Effect.Opacity, from: 1.0, to: 1.0 }];237
if (extra) anims.push(extra);238
window.bmwSegEnd = Date.now() + Math.max(1, dur) - 8;239
return animate({ window: window, curve: QEasingCurve.Linear, duration: Math.max(1, dur), animations: anims });240
}241
195
slotWindowMinimized(window) {242
slotWindowMinimized(window) {196
if (effects.hasActiveFullScreenEffect) return;243
if (effects.hasActiveFullScreenEffect) return;197
const ir = window.iconGeometry;244
const ir = window.iconGeometry;198
if (!ir || ir.width == 0 || ir.height == 0) return; // no taskbar entry245
if (!ir || ir.width == 0 || ir.height == 0) return; // no taskbar entry199
this.stopAll(window);246
this.stopAll(window);200
const wr = window.geometry;247
const path = this.buildPath(window, ir);201
const dx = (ir.x + ir.width / 2) - (wr.x + wr.width / 2);202
const dy = (ir.y + ir.height / 2) - (wr.y + wr.height / 2);203
const dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));204
// straight-line free fall from rest: d = 0.5 g t^2 -> t = sqrt(2d/g)205
const fall = animationTime(Math.round(1000 * Math.sqrt(2 * dist / this.gravity)));206
const morph = this.duration + this.pause;248
const morph = this.duration + this.pause;249
const total = morph + path.total;207
effect.setUniform(this.shader, "uForOpening", 0.0);250
effect.setUniform(this.shader, "uForOpening", 0.0);208
effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);251
effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);209
effect.setUniform(this.shader, "uDuration", (morph + fall) * 0.001);252
effect.setUniform(this.shader, "uDuration", total * 0.001);210
effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, morph));253
effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, total));211
// phase 1: morph + pause; its end starts the fall (no gap, no full-window frame)254
// ONE shader animation over the whole minimize (same setup as restore, which renders fine);255
// a little longer than the path so the marble is drawn until the window is hidden.212
window.bmwMinAnimation = animate({256
window.bmwMinAnimation = animate({213
window: window, curve: QEasingCurve.Linear, duration: morph,257
window: window, curve: QEasingCurve.Linear, duration: total + 150,214
animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: 1.0 },258
animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: 1.0 },215
{ type: Effect.Opacity, from: 1.0, to: 1.0 }]259
{ type: Effect.Opacity, from: 1.0, to: 1.0 }]216
});260
});217
window.bmwFall = {dx: dx, dy: dy, duration: fall};261
// marker for the end of morph + pause; when it ends the path traversal starts218
window.bmwFallPending = true;262
window.bmwMarbleDone = animate({263
window: window, curve: QEasingCurve.Linear, duration: morph,264
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: 0.0, value2: 0.0} }]265
});266
window.bmwPath = path; window.bmwSeg = -1; window.bmwMode = "min";267
window.bmwSegEnd = Date.now() + morph - 8;219
}268
}220
269
221
slotWindowUnminimized(window) {270
slotWindowUnminimized(window) {@@ -223,14 +272,10 @@ class BurnMyWindowsMarbleMinimizeEffect {223
const ir = window.iconGeometry;272
const ir = window.iconGeometry;224
this.stopAll(window);273
this.stopAll(window);225
if (!ir || ir.width == 0 || ir.height == 0) return;274
if (!ir || ir.width == 0 || ir.height == 0) return;226
// exact reverse: marble rises from the taskbar entry (reverse of the fall timing),275
// exact reverse: marble comes up the same S-path (reverse gravity timing), growing from227
// rests, then unfolds back into the window. Window is full only at the very end.276
// 10% to 100% over the first 10% of the path, rests, then unfolds into the window.228
const wr = window.geometry;277
const path = this.buildPath(window, ir);229
const dx = (ir.x + ir.width / 2) - (wr.x + wr.width / 2);278
const total = this.duration + this.pause + path.total;230
const dy = (ir.y + ir.height / 2) - (wr.y + wr.height / 2);231
const dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));232
const fall = animationTime(Math.round(1000 * Math.sqrt(2 * dist / this.gravity)));233
const total = this.duration + this.pause + fall;234
effect.setUniform(this.shader, "uForOpening", 0.0);279
effect.setUniform(this.shader, "uForOpening", 0.0);235
effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);280
effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);236
effect.setUniform(this.shader, "uDuration", total * 0.001);281
effect.setUniform(this.shader, "uDuration", total * 0.001);@@ -239,30 +284,58 @@ class BurnMyWindowsMarbleMinimizeEffect {239
window: window, curve: QEasingCurve.Linear, duration: total,284
window: window, curve: QEasingCurve.Linear, duration: total,240
animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 1.0, to: 0.0 }]285
animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 1.0, to: 0.0 }]241
});286
});242
// OutQuad = time-reversed InQuad: fast at the taskbar, decelerating to rest287
const T = path.total, nd = path.nodes, N = nd.length - 1;243
window.bmwRiseAnimation = animate({288
// reversed timing: going from node N to node N-1 takes (t_N - t_{N-1}) etc.244
window: window, curve: QEasingCurve.OutQuad, duration: fall,289
window.bmwScaleAnimation = animate({245
animations: [{ type: Effect.Translation, from: {value1: dx, value2: dy}, to: {value1: 0.0, value2: 0.0} }]290
window: window, curve: QEasingCurve.InOutSine, duration: Math.max(1, T - nd[N - 2].t),291
animations: [{ type: Effect.Scale, from: {value1: 0.1, value2: 0.1}, to: {value1: 1.0, value2: 1.0} }]246
});292
});293
window.bmwPath = path; window.bmwSeg = N; window.bmwMode = "rise";294
window.bmwSegAnimation = this.segAnim(window, nd[N], nd[N - 1], nd[N].t - nd[N - 1].t);247
}295
}248
296
249
stopAll(window) {297
stopAll(window) {250
window.bmwFallPending = false;298
window.bmwMode = null;251
for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwFallAnimation", "bmwUnminAnimation", "bmwRiseAnimation"]) {299
for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwSegAnimation", "bmwScaleAnimation",300
"bmwTailAnimation", "bmwUnminAnimation"]) {252
if (window[k]) { cancel(window[k]); delete window[k]; }301
if (window[k]) { cancel(window[k]); delete window[k]; }253
}302
}254
}303
}255
304
305
// Chain the path segments. KWin reports ids as 0 here, so we use our own state.256
slotAnimationEnded(window, id) {306
slotAnimationEnded(window, id) {257
if (!window || !window.bmwFallPending) return; // first end = marble marker307
if (!window || !window.bmwMode) return;258
window.bmwFallPending = false;308
if (window.bmwSegEnd && Date.now() < window.bmwSegEnd) return; // another animation ended259
const f = window.bmwFall;309
const nd = window.bmwPath.nodes, N = nd.length - 1;260
window.bmwFallAnimation = animate({310
if (window.bmwMode == "min") {261
window: window, curve: QEasingCurve.InQuad, duration: f.duration,311
if (window.bmwSeg >= N) return; // already in the tail262
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: f.dx, value2: f.dy} },312
window.bmwSeg++;263
{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 1.0, to: 1.0 },313
const i = window.bmwSeg;264
{ type: Effect.Opacity, from: 1.0, to: 1.0 }]314
if (i == N) {265
});315
// arrived: invisible hold at the icon (scale 10%) until the shader animation ends316
window.bmwTailAnimation = animate({317
window: window, curve: QEasingCurve.Linear, duration: 200,318
animations: [{ type: Effect.Translation, from: {value1: nd[N].x, value2: nd[N].y}, to: {value1: nd[N].x, value2: nd[N].y} },319
{ type: Effect.Scale, from: {value1: 0.1, value2: 0.1}, to: {value1: 0.1, value2: 0.1} },320
{ type: Effect.Opacity, from: 0.0, to: 0.0 }]321
});322
window.bmwMode = null;323
return;324
}325
let extra = null;326
if (i == N - 2) { // last 10% of arc length: 100% -> 10%327
window.bmwScaleAnimation = animate({328
window: window, curve: QEasingCurve.InOutSine, duration: Math.max(1, nd[N].t - nd[N - 2].t),329
animations: [{ type: Effect.Scale, from: {value1: 1.0, value2: 1.0}, to: {value1: 0.1, value2: 0.1} }]330
});331
}332
window.bmwSegAnimation = this.segAnim(window, nd[i], nd[i + 1], nd[i + 1].t - nd[i].t, extra);333
} else if (window.bmwMode == "rise") {334
window.bmwSeg--;335
const i = window.bmwSeg;336
if (i <= 0) { window.bmwMode = null; return; }337
window.bmwSegAnimation = this.segAnim(window, nd[i], nd[i - 1], nd[i].t - nd[i - 1].t);338
}266
}339
}267
340
268
slotWindowDataChanged(window, role) {341
slotWindowDataChanged(window, role) {