BlueGit

timfa kwin-marble

Marble Magic Lamp: no full-window flash at end of minimize

timfa Tim Falken · pushed by timfa

Authored 2026-11-02 · 2 weeks ago

Hash
df233a395c4d2bc68cc8af106ea55c11c6f2b00c
Parent
ff81859f
1 file changed +7 −9
kwin6_effect_marble_minimize/contents/code/main.js +7 −9
@@ -203,20 +203,17 @@ class BurnMyWindowsMarbleMinimizeEffect {
203 203 const dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
204 204 // straight-line free fall from rest: d = 0.5 g t^2 -> t = sqrt(2d/g)
205 205 const fall = animationTime(Math.round(1000 * Math.sqrt(2 * dist / this.gravity)));
206 const total = this.duration + this.pause + fall;
206 const morph = this.duration + this.pause;
207 207 effect.setUniform(this.shader, "uForOpening", 0.0);
208 208 effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);
209 effect.setUniform(this.shader, "uDuration", total * 0.001);
210 effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, total));
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)
211 212 window.bmwMinAnimation = animate({
212 window: window, curve: QEasingCurve.Linear, duration: total,
213 window: window, curve: QEasingCurve.Linear, duration: morph,
213 214 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: 1.0 },
214 215 { type: Effect.Opacity, from: 1.0, to: 1.0 }]
215 216 });
216 window.bmwMarbleDone = animate({
217 window: window, curve: QEasingCurve.Linear, duration: this.duration + this.pause,
218 animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: 0.0, value2: 0.0} }]
219 });
220 217 window.bmwFall = {dx: dx, dy: dy, duration: fall};
221 218 window.bmwFallPending = true;
222 219 }
@@ -261,8 +258,9 @@ class BurnMyWindowsMarbleMinimizeEffect {
261 258 window.bmwFallPending = false;
262 259 const f = window.bmwFall;
263 260 window.bmwFallAnimation = animate({
264 window: window, curve: QEasingCurve.InQuad, duration: f.duration, keepAtTarget: true,
261 window: window, curve: QEasingCurve.InQuad, duration: f.duration,
265 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 },
266 264 { type: Effect.Opacity, from: 1.0, to: 1.0 }]
267 265 });
268 266 }
@@ -203,20 +203,17 @@ class BurnMyWindowsMarbleMinimizeEffect {
203 const dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
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)
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)));
205 const fall = animationTime(Math.round(1000 * Math.sqrt(2 * dist / this.gravity)));
206 const total = this.duration + this.pause + fall;
206 const morph = this.duration + this.pause;
207 effect.setUniform(this.shader, "uForOpening", 0.0);
207 effect.setUniform(this.shader, "uForOpening", 0.0);
208 effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);
208 effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);
209 effect.setUniform(this.shader, "uDuration", total * 0.001);
209 effect.setUniform(this.shader, "uDuration", (morph + fall) * 0.001);
210 effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, total));
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)
211 window.bmwMinAnimation = animate({
212 window.bmwMinAnimation = animate({
212 window: window, curve: QEasingCurve.Linear, duration: total,
213 window: window, curve: QEasingCurve.Linear, duration: morph,
213 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: 1.0 },
214 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: 1.0 },
214 { type: Effect.Opacity, from: 1.0, to: 1.0 }]
215 { type: Effect.Opacity, from: 1.0, to: 1.0 }]
215 });
216 });
216 window.bmwMarbleDone = animate({
217 window: window, curve: QEasingCurve.Linear, duration: this.duration + this.pause,
218 animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: 0.0, value2: 0.0} }]
219 });
220 window.bmwFall = {dx: dx, dy: dy, duration: fall};
217 window.bmwFall = {dx: dx, dy: dy, duration: fall};
221 window.bmwFallPending = true;
218 window.bmwFallPending = true;
222 }
219 }
@@ -261,8 +258,9 @@ class BurnMyWindowsMarbleMinimizeEffect {
261 window.bmwFallPending = false;
258 window.bmwFallPending = false;
262 const f = window.bmwFall;
259 const f = window.bmwFall;
263 window.bmwFallAnimation = animate({
260 window.bmwFallAnimation = animate({
264 window: window, curve: QEasingCurve.InQuad, duration: f.duration, keepAtTarget: true,
261 window: window, curve: QEasingCurve.InQuad, duration: f.duration,
265 animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: f.dx, value2: f.dy} },
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 },
266 { type: Effect.Opacity, from: 1.0, to: 1.0 }]
264 { type: Effect.Opacity, from: 1.0, to: 1.0 }]
267 });
265 });
268 }
266 }