BlueGit

timfa kwin-marble

Marble Magic Lamp: robust end (shader outlives chain, invisible tail, explicit cancel)

timfa Tim Falken · pushed by timfa

Authored 2026-11-02 · 2 weeks ago

Hash
6463ba1270cb39b6bd070e43b99e4fcd34632144
Parent
6ae3a41d
1 file changed +15 −4
kwin6_effect_marble_minimize/contents/code/main.js +15 −4
@@ -254,8 +254,11 @@ class BurnMyWindowsMarbleMinimizeEffect {
254 254 // ONE shader animation over the whole minimize (same setup as restore, which renders fine);
255 255 // a little longer than the path so the marble is drawn until the window is hidden.
256 256 window.bmwMinAnimation = animate({
257 window: window, curve: QEasingCurve.Linear, duration: total + 150,
258 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: 1.0 },
257 // runs far past the path on purpose (uProgress just goes beyond 1 = marble); it is
258 // cancelled explicitly after the invisible tail, so a late chain can never expose
259 // the unshaded window.
260 window: window, curve: QEasingCurve.Linear, duration: total + 3000,
261 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: (total + 3000) / Math.max(1, total) },
259 262 { type: Effect.Opacity, from: 1.0, to: 1.0 }]
260 263 });
261 264 // marker for the end of morph + pause; when it ends the path traversal starts
@@ -307,6 +310,13 @@ class BurnMyWindowsMarbleMinimizeEffect {
307 310 if (!window || !window.bmwMode) return;
308 311 if (window.bmwSegEnd && Date.now() < window.bmwSegEnd) return; // another animation ended
309 312 const nd = window.bmwPath.nodes, N = nd.length - 1;
313 if (window.bmwMode == "tail") {
314 // invisible tail done: now stop the shader too; the window is hidden from here on
315 window.bmwMode = null;
316 if (window.bmwMinAnimation) { cancel(window.bmwMinAnimation); delete window.bmwMinAnimation; }
317 try { effects.addRepaintFull(); } catch (e) {}
318 return;
319 }
310 320 if (window.bmwMode == "min") {
311 321 if (window.bmwSeg >= N) return; // already in the tail
312 322 window.bmwSeg++;
@@ -314,12 +324,13 @@ class BurnMyWindowsMarbleMinimizeEffect {
314 324 if (i == N) {
315 325 // arrived: invisible hold at the icon (scale 10%) until the shader animation ends
316 326 window.bmwTailAnimation = animate({
317 window: window, curve: QEasingCurve.Linear, duration: 200,
327 window: window, curve: QEasingCurve.Linear, duration: 250,
318 328 animations: [{ type: Effect.Translation, from: {value1: nd[N].x, value2: nd[N].y}, to: {value1: nd[N].x, value2: nd[N].y} },
319 329 { type: Effect.Scale, from: {value1: 0.1, value2: 0.1}, to: {value1: 0.1, value2: 0.1} },
320 330 { type: Effect.Opacity, from: 0.0, to: 0.0 }]
321 331 });
322 window.bmwMode = null;
332 window.bmwSegEnd = Date.now() + 250 - 8;
333 window.bmwMode = "tail";
323 334 return;
324 335 }
325 336 let extra = null;
@@ -254,8 +254,11 @@ class BurnMyWindowsMarbleMinimizeEffect {
254 // ONE shader animation over the whole minimize (same setup as restore, which renders fine);
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.
255 // a little longer than the path so the marble is drawn until the window is hidden.
256 window.bmwMinAnimation = animate({
256 window.bmwMinAnimation = animate({
257 window: window, curve: QEasingCurve.Linear, duration: total + 150,
257 // runs far past the path on purpose (uProgress just goes beyond 1 = marble); it is
258 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: 1.0 },
258 // cancelled explicitly after the invisible tail, so a late chain can never expose
259 // the unshaded window.
260 window: window, curve: QEasingCurve.Linear, duration: total + 3000,
261 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: (total + 3000) / Math.max(1, total) },
259 { type: Effect.Opacity, from: 1.0, to: 1.0 }]
262 { type: Effect.Opacity, from: 1.0, to: 1.0 }]
260 });
263 });
261 // marker for the end of morph + pause; when it ends the path traversal starts
264 // marker for the end of morph + pause; when it ends the path traversal starts
@@ -307,6 +310,13 @@ class BurnMyWindowsMarbleMinimizeEffect {
307 if (!window || !window.bmwMode) return;
310 if (!window || !window.bmwMode) return;
308 if (window.bmwSegEnd && Date.now() < window.bmwSegEnd) return; // another animation ended
311 if (window.bmwSegEnd && Date.now() < window.bmwSegEnd) return; // another animation ended
309 const nd = window.bmwPath.nodes, N = nd.length - 1;
312 const nd = window.bmwPath.nodes, N = nd.length - 1;
313 if (window.bmwMode == "tail") {
314 // invisible tail done: now stop the shader too; the window is hidden from here on
315 window.bmwMode = null;
316 if (window.bmwMinAnimation) { cancel(window.bmwMinAnimation); delete window.bmwMinAnimation; }
317 try { effects.addRepaintFull(); } catch (e) {}
318 return;
319 }
310 if (window.bmwMode == "min") {
320 if (window.bmwMode == "min") {
311 if (window.bmwSeg >= N) return; // already in the tail
321 if (window.bmwSeg >= N) return; // already in the tail
312 window.bmwSeg++;
322 window.bmwSeg++;
@@ -314,12 +324,13 @@ class BurnMyWindowsMarbleMinimizeEffect {
314 if (i == N) {
324 if (i == N) {
315 // arrived: invisible hold at the icon (scale 10%) until the shader animation ends
325 // arrived: invisible hold at the icon (scale 10%) until the shader animation ends
316 window.bmwTailAnimation = animate({
326 window.bmwTailAnimation = animate({
317 window: window, curve: QEasingCurve.Linear, duration: 200,
327 window: window, curve: QEasingCurve.Linear, duration: 250,
318 animations: [{ type: Effect.Translation, from: {value1: nd[N].x, value2: nd[N].y}, to: {value1: nd[N].x, value2: nd[N].y} },
328 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} },
329 { 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 }]
330 { type: Effect.Opacity, from: 0.0, to: 0.0 }]
321 });
331 });
322 window.bmwMode = null;
332 window.bmwSegEnd = Date.now() + 250 - 8;
333 window.bmwMode = "tail";
323 return;
334 return;
324 }
335 }
325 let extra = null;
336 let extra = null;