BlueGit

timfa kwin-marble

Marble Magic Lamp: reverse animation on restore

timfa Tim Falken · pushed by timfa

Authored 2026-11-02 · 2 weeks ago

Hash
ff81859ff6ee373bed4e7c6d28f2c4db1e1e899a
Parent
9e124ca5
2 files changed +25 −6
README.md +3 −3
@@ -14,11 +14,11 @@ acceleration from rest) for 1.5 screen heights.
14 14
15 15 **NL** – `kwin6_effect_marble_minimize`: bij minimaliseren vormt het venster zich net zo om tot
16 16 een knikker, pauzeert, en valt dan in een rechte lijn met zwaartekracht (vanuit stilstand) naar
17 zijn taakbalkknop. Herstellen is een korte fade-in. Zelfde instellingen en defaults.
17 zijn taakbalkknop. Herstellen speelt de omgekeerde animatie (knikker stijgt op van de taakbalkknop, pauze, vouwt open). Zelfde instellingen en defaults.
18 18
19 19 **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 is a short
21 fade-in. Same settings and defaults. It replaces the active minimize animation (e.g. Magic Lamp).
20 then falls in a straight line under gravity (from rest) to its taskbar entry. Restore plays it in
21 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 22
23 23 ## Installatie / Installation
24 24
@@ -14,11 +14,11 @@ acceleration from rest) for 1.5 screen heights.
14
14
15**NL** – `kwin6_effect_marble_minimize`: bij minimaliseren vormt het venster zich net zo om tot
15**NL** – `kwin6_effect_marble_minimize`: bij minimaliseren vormt het venster zich net zo om tot
16een knikker, pauzeert, en valt dan in een rechte lijn met zwaartekracht (vanuit stilstand) naar
16een knikker, pauzeert, en valt dan in een rechte lijn met zwaartekracht (vanuit stilstand) naar
17zijn taakbalkknop. Herstellen is een korte fade-in. Zelfde instellingen en defaults.
17zijn taakbalkknop. Herstellen speelt de omgekeerde animatie (knikker stijgt op van de taakbalkknop, pauze, vouwt open). Zelfde instellingen en defaults.
18
18
19**EN** – `kwin6_effect_marble_minimize`: on minimize the window becomes the same marble, pauses,
19**EN** – `kwin6_effect_marble_minimize`: on minimize the window becomes the same marble, pauses,
20then falls in a straight line under gravity (from rest) to its taskbar entry. Restore is a short
20then falls in a straight line under gravity (from rest) to its taskbar entry. Restore plays it in
21fade-in. Same settings and defaults. It replaces the active minimize animation (e.g. Magic Lamp).
21reverse (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
22
23## Installatie / Installation
23## Installatie / Installation
24
24
kwin6_effect_marble_minimize/contents/code/main.js +22 −3
@@ -223,16 +223,35 @@ class BurnMyWindowsMarbleMinimizeEffect {
223 223
224 224 slotWindowUnminimized(window) {
225 225 if (effects.hasActiveFullScreenEffect) return;
226 const ir = window.iconGeometry;
226 227 this.stopAll(window);
228 if (!ir || ir.width == 0 || ir.height == 0) return;
229 // exact reverse: marble rises from the taskbar entry (reverse of the fall timing),
230 // rests, then unfolds back into the window. Window is full only at the very end.
231 const wr = window.geometry;
232 const dx = (ir.x + ir.width / 2) - (wr.x + wr.width / 2);
233 const dy = (ir.y + ir.height / 2) - (wr.y + wr.height / 2);
234 const dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
235 const fall = animationTime(Math.round(1000 * Math.sqrt(2 * dist / this.gravity)));
236 const total = this.duration + this.pause + fall;
237 effect.setUniform(this.shader, "uForOpening", 0.0);
238 effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);
239 effect.setUniform(this.shader, "uDuration", total * 0.001);
240 effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, total));
227 241 window.bmwUnminAnimation = animate({
228 window: window, curve: QEasingCurve.OutQuad, duration: animationTime(200),
229 animations: [{ type: Effect.Opacity, from: 0.0, to: 1.0 }]
242 window: window, curve: QEasingCurve.Linear, duration: total,
243 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 1.0, to: 0.0 }]
244 });
245 // OutQuad = time-reversed InQuad: fast at the taskbar, decelerating to rest
246 window.bmwRiseAnimation = animate({
247 window: window, curve: QEasingCurve.OutQuad, duration: fall,
248 animations: [{ type: Effect.Translation, from: {value1: dx, value2: dy}, to: {value1: 0.0, value2: 0.0} }]
230 249 });
231 250 }
232 251
233 252 stopAll(window) {
234 253 window.bmwFallPending = false;
235 for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwFallAnimation", "bmwUnminAnimation"]) {
254 for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwFallAnimation", "bmwUnminAnimation", "bmwRiseAnimation"]) {
236 255 if (window[k]) { cancel(window[k]); delete window[k]; }
237 256 }
238 257 }
@@ -223,16 +223,35 @@ class BurnMyWindowsMarbleMinimizeEffect {
223
223
224 slotWindowUnminimized(window) {
224 slotWindowUnminimized(window) {
225 if (effects.hasActiveFullScreenEffect) return;
225 if (effects.hasActiveFullScreenEffect) return;
226 const ir = window.iconGeometry;
226 this.stopAll(window);
227 this.stopAll(window);
228 if (!ir || ir.width == 0 || ir.height == 0) return;
229 // exact reverse: marble rises from the taskbar entry (reverse of the fall timing),
230 // rests, then unfolds back into the window. Window is full only at the very end.
231 const wr = window.geometry;
232 const dx = (ir.x + ir.width / 2) - (wr.x + wr.width / 2);
233 const dy = (ir.y + ir.height / 2) - (wr.y + wr.height / 2);
234 const dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
235 const fall = animationTime(Math.round(1000 * Math.sqrt(2 * dist / this.gravity)));
236 const total = this.duration + this.pause + fall;
237 effect.setUniform(this.shader, "uForOpening", 0.0);
238 effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);
239 effect.setUniform(this.shader, "uDuration", total * 0.001);
240 effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, total));
227 window.bmwUnminAnimation = animate({
241 window.bmwUnminAnimation = animate({
228 window: window, curve: QEasingCurve.OutQuad, duration: animationTime(200),
242 window: window, curve: QEasingCurve.Linear, duration: total,
229 animations: [{ type: Effect.Opacity, from: 0.0, to: 1.0 }]
243 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 1.0, to: 0.0 }]
244 });
245 // OutQuad = time-reversed InQuad: fast at the taskbar, decelerating to rest
246 window.bmwRiseAnimation = animate({
247 window: window, curve: QEasingCurve.OutQuad, duration: fall,
248 animations: [{ type: Effect.Translation, from: {value1: dx, value2: dy}, to: {value1: 0.0, value2: 0.0} }]
230 });
249 });
231 }
250 }
232
251
233 stopAll(window) {
252 stopAll(window) {
234 window.bmwFallPending = false;
253 window.bmwFallPending = false;
235 for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwFallAnimation", "bmwUnminAnimation"]) {
254 for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwFallAnimation", "bmwUnminAnimation", "bmwRiseAnimation"]) {
236 if (window[k]) { cancel(window[k]); delete window[k]; }
255 if (window[k]) { cancel(window[k]); delete window[k]; }
237 }
256 }
238 }
257 }