Second-effect black marble: start new animations before cancelling the old ones (KWin reuses the existing window snapshot); shader falls back to a plain glass marble when KWin hands an empty snapshot
@@ -238,10 +238,8 @@ class BurnMyWindowsMarbleEffect {
238
238
if (effect.isGrabbed(window, Effect.WindowClosedGrabRole)) {
239
239
return;
240
240
}
241
if (window.bmwInAnimation) {
242
cancel(window.bmwInAnimation);
243
delete window.bmwInAnimation;
244
}
241
const oldIn = window.bmwInAnimation; // cancelled after the close animation exists (keeps the snapshot)
242
delete window.bmwInAnimation;
245
243
this.setupForcedRoles(window);
246
244
247
245
this.applyTint(window, false);
@@ -263,6 +261,7 @@ class BurnMyWindowsMarbleEffect {
263
261
to: this.prog(window, 1.0 / this.crumpleEnd())
264
262
}]
265
263
});
264
if (oldIn) cancel(oldIn);
266
265
// 2) marker animation that ends exactly when the marble is done; the fall is
267
266
// started from its animationEnded (KWin ignored the per-call delay).
268
267
window.bmwMarbleDone = animate({
@@ -238,10 +238,8 @@ class BurnMyWindowsMarbleEffect {238
if (effect.isGrabbed(window, Effect.WindowClosedGrabRole)) {238
if (effect.isGrabbed(window, Effect.WindowClosedGrabRole)) {239
return;239
return;240
}240
}241
if (window.bmwInAnimation) {241
const oldIn = window.bmwInAnimation; // cancelled after the close animation exists (keeps the snapshot)242
cancel(window.bmwInAnimation);242
delete window.bmwInAnimation;243
delete window.bmwInAnimation;244
}245
this.setupForcedRoles(window);243
this.setupForcedRoles(window);246
244
247
this.applyTint(window, false);245
this.applyTint(window, false);@@ -263,6 +261,7 @@ class BurnMyWindowsMarbleEffect {263
to: this.prog(window, 1.0 / this.crumpleEnd())261
to: this.prog(window, 1.0 / this.crumpleEnd())264
}]262
}]265
});263
});264
if (oldIn) cancel(oldIn);266
// 2) marker animation that ends exactly when the marble is done; the fall is265
// 2) marker animation that ends exactly when the marble is done; the fall is267
// started from its animationEnded (KWin ignored the per-call delay).266
// started from its animationEnded (KWin ignored the per-call delay).268
window.bmwMarbleDone = animate({267
window.bmwMarbleDone = animate({@@ -786,6 +786,9 @@ void main() {
786
786
col.a = step(0.97, col.a); // ignore the window shadow
787
787
col.a = mix(col.a, 1.0, e); // marble is solid
788
788
col.rgb = clamp(col.rgb, 0.0, 1.0);
789
// KWin gives an empty snapshot when this effect was already busy with another window:
790
// then draw a plain glass marble (no window image) instead of a black/invisible one
791
if (getInputColor(vec2(0.5)).a < 0.004) col = vec4(vec3(0.16), e);
789
792
790
793
if (uDebug > 1.5) { setOutputColor(vec4(col.rgb, col.a * clamp(-d, 0.0, 1.0))); return; }
791
794
// glossy marble shading
@@ -786,6 +786,9 @@ void main() {786
col.a = step(0.97, col.a); // ignore the window shadow786
col.a = step(0.97, col.a); // ignore the window shadow787
col.a = mix(col.a, 1.0, e); // marble is solid787
col.a = mix(col.a, 1.0, e); // marble is solid788
col.rgb = clamp(col.rgb, 0.0, 1.0);788
col.rgb = clamp(col.rgb, 0.0, 1.0);789
// KWin gives an empty snapshot when this effect was already busy with another window:790
// then draw a plain glass marble (no window image) instead of a black/invisible one791
if (getInputColor(vec2(0.5)).a < 0.004) col = vec4(vec3(0.16), e);789
792
790
if (uDebug > 1.5) { setOutputColor(vec4(col.rgb, col.a * clamp(-d, 0.0, 1.0))); return; }793
if (uDebug > 1.5) { setOutputColor(vec4(col.rgb, col.a * clamp(-d, 0.0, 1.0))); return; }791
// glossy marble shading794
// glossy marble shading@@ -787,6 +787,9 @@ void main() {
787
787
col.a = step(0.97, col.a); // ignore the window shadow
788
788
col.a = mix(col.a, 1.0, e); // marble is solid
789
789
col.rgb = clamp(col.rgb, 0.0, 1.0);
790
// KWin gives an empty snapshot when this effect was already busy with another window:
791
// then draw a plain glass marble (no window image) instead of a black/invisible one
792
if (getInputColor(vec2(0.5)).a < 0.004) col = vec4(vec3(0.16), e);
790
793
791
794
if (uDebug > 1.5) { setOutputColor(vec4(col.rgb, col.a * clamp(-d, 0.0, 1.0))); return; }
792
795
// glossy marble shading
@@ -787,6 +787,9 @@ void main() {787
col.a = step(0.97, col.a); // ignore the window shadow787
col.a = step(0.97, col.a); // ignore the window shadow788
col.a = mix(col.a, 1.0, e); // marble is solid788
col.a = mix(col.a, 1.0, e); // marble is solid789
col.rgb = clamp(col.rgb, 0.0, 1.0);789
col.rgb = clamp(col.rgb, 0.0, 1.0);790
// KWin gives an empty snapshot when this effect was already busy with another window:791
// then draw a plain glass marble (no window image) instead of a black/invisible one792
if (getInputColor(vec2(0.5)).a < 0.004) col = vec4(vec3(0.16), e);790
793
791
if (uDebug > 1.5) { setOutputColor(vec4(col.rgb, col.a * clamp(-d, 0.0, 1.0))); return; }794
if (uDebug > 1.5) { setOutputColor(vec4(col.rgb, col.a * clamp(-d, 0.0, 1.0))); return; }792
// glossy marble shading795
// glossy marble shading@@ -277,7 +277,7 @@ class BurnMyWindowsMarbleMinimizeEffect {
277
277
if (effects.hasActiveFullScreenEffect) return;
278
278
const ir = window.iconGeometry;
279
279
if (!ir || ir.width == 0 || ir.height == 0) return; // no taskbar entry
280
this.stopAll(window);
280
const old = this.takeAll(window);
281
281
const f = this.fallPlan(window, ir);
282
282
this.applyTint(window, false);
283
283
const morph = this.duration + this.pause;
@@ -297,13 +297,14 @@ class BurnMyWindowsMarbleMinimizeEffect {
297
297
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: 0.0, value2: 0.0} }]
298
298
});
299
299
window.bmwFall = f; window.bmwMode = "morph"; window.bmwSegEnd = Date.now() + morph - 8;
300
this.cancelIds(old); // after the new shader animation exists (keeps the snapshot)
300
301
}
301
302
302
303
slotWindowUnminimized(window) {
303
304
if (effects.hasActiveFullScreenEffect) return;
304
305
const ir = window.iconGeometry;
305
this.stopAll(window);
306
if (!ir || ir.width == 0 || ir.height == 0) return;
306
const old = this.takeAll(window);
307
if (!ir || ir.width == 0 || ir.height == 0) { this.cancelIds(old); return; }
307
308
// reverse: rise from the icon (same curves reversed), rest, unfold
308
309
const f = this.fallPlan(window, ir);
309
310
this.applyTint(window, true);
@@ -319,17 +320,31 @@ class BurnMyWindowsMarbleMinimizeEffect {
319
320
this.fallAnims(window, f, -1);
320
321
window.bmwFadeInAnimation = animate({ window: window, curve: QEasingCurve.InExpo, duration: 80,
321
322
animations: [{ type: Effect.Opacity, from: 0.0, to: 1.0 }] });
323
this.cancelIds(old); // after the new shader animation exists (keeps the snapshot)
322
324
}
323
325
324
stopAll(window) {
326
// Detach the running animations of this window without cancelling them yet. They are cancelled
327
// (cancelIds) only after the new animations exist: KWin's scripted shader animations draw a
328
// one-time snapshot of the window, and a snapshot taken while this effect is already active
329
// comes out empty (black/invisible marble). Keeping one shader animation alive makes KWin
330
// reuse the existing, valid snapshot for the new animation.
331
takeAll(window) {
325
332
window.bmwMode = null;
333
const ids = [];
326
334
for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwXAnimation", "bmwYAnimation", "bmwScaleAnimation", "bmwScale2Animation", "bmwCompAnimation",
327
335
"bmwTailAnimation", "bmwUnminAnimation", "bmwFadeInAnimation"]) {
328
if (window[k]) { cancel(window[k]); delete window[k]; }
336
if (window[k]) { ids.push(window[k]); delete window[k]; }
329
337
}
338
return ids;
339
}
340
341
cancelIds(ids) {
342
for (const id of ids) cancel(id);
330
343
this.repaintAll();
331
344
}
332
345
346
stopAll(window) { this.cancelIds(this.takeAll(window)); }
347
333
348
// KWin reports ids as 0 here, so we use our own state + end times.
334
349
slotAnimationEnded(window, id) {
335
350
// marble is drawn outside the window's own damage region: repaint all on every end
@@ -277,7 +277,7 @@ class BurnMyWindowsMarbleMinimizeEffect {277
if (effects.hasActiveFullScreenEffect) return;277
if (effects.hasActiveFullScreenEffect) return;278
const ir = window.iconGeometry;278
const ir = window.iconGeometry;279
if (!ir || ir.width == 0 || ir.height == 0) return; // no taskbar entry279
if (!ir || ir.width == 0 || ir.height == 0) return; // no taskbar entry280
this.stopAll(window);280
const old = this.takeAll(window);281
const f = this.fallPlan(window, ir);281
const f = this.fallPlan(window, ir);282
this.applyTint(window, false);282
this.applyTint(window, false);283
const morph = this.duration + this.pause;283
const morph = this.duration + this.pause;@@ -297,13 +297,14 @@ class BurnMyWindowsMarbleMinimizeEffect {297
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: 0.0, value2: 0.0} }]297
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: 0.0, value2: 0.0} }]298
});298
});299
window.bmwFall = f; window.bmwMode = "morph"; window.bmwSegEnd = Date.now() + morph - 8;299
window.bmwFall = f; window.bmwMode = "morph"; window.bmwSegEnd = Date.now() + morph - 8;300
this.cancelIds(old); // after the new shader animation exists (keeps the snapshot)300
}301
}301
302
302
slotWindowUnminimized(window) {303
slotWindowUnminimized(window) {303
if (effects.hasActiveFullScreenEffect) return;304
if (effects.hasActiveFullScreenEffect) return;304
const ir = window.iconGeometry;305
const ir = window.iconGeometry;305
this.stopAll(window);306
const old = this.takeAll(window);306
if (!ir || ir.width == 0 || ir.height == 0) return;307
if (!ir || ir.width == 0 || ir.height == 0) { this.cancelIds(old); return; }307
// reverse: rise from the icon (same curves reversed), rest, unfold308
// reverse: rise from the icon (same curves reversed), rest, unfold308
const f = this.fallPlan(window, ir);309
const f = this.fallPlan(window, ir);309
this.applyTint(window, true);310
this.applyTint(window, true);@@ -319,17 +320,31 @@ class BurnMyWindowsMarbleMinimizeEffect {319
this.fallAnims(window, f, -1);320
this.fallAnims(window, f, -1);320
window.bmwFadeInAnimation = animate({ window: window, curve: QEasingCurve.InExpo, duration: 80,321
window.bmwFadeInAnimation = animate({ window: window, curve: QEasingCurve.InExpo, duration: 80,321
animations: [{ type: Effect.Opacity, from: 0.0, to: 1.0 }] });322
animations: [{ type: Effect.Opacity, from: 0.0, to: 1.0 }] });323
this.cancelIds(old); // after the new shader animation exists (keeps the snapshot)322
}324
}323
325
324
stopAll(window) {326
// Detach the running animations of this window without cancelling them yet. They are cancelled327
// (cancelIds) only after the new animations exist: KWin's scripted shader animations draw a328
// one-time snapshot of the window, and a snapshot taken while this effect is already active329
// comes out empty (black/invisible marble). Keeping one shader animation alive makes KWin330
// reuse the existing, valid snapshot for the new animation.331
takeAll(window) {325
window.bmwMode = null;332
window.bmwMode = null;333
const ids = [];326
for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwXAnimation", "bmwYAnimation", "bmwScaleAnimation", "bmwScale2Animation", "bmwCompAnimation",334
for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwXAnimation", "bmwYAnimation", "bmwScaleAnimation", "bmwScale2Animation", "bmwCompAnimation",327
"bmwTailAnimation", "bmwUnminAnimation", "bmwFadeInAnimation"]) {335
"bmwTailAnimation", "bmwUnminAnimation", "bmwFadeInAnimation"]) {328
if (window[k]) { cancel(window[k]); delete window[k]; }336
if (window[k]) { ids.push(window[k]); delete window[k]; }329
}337
}338
return ids;339
}340
341
cancelIds(ids) {342
for (const id of ids) cancel(id);330
this.repaintAll();343
this.repaintAll();331
}344
}332
345
346
stopAll(window) { this.cancelIds(this.takeAll(window)); }347
333
// KWin reports ids as 0 here, so we use our own state + end times.348
// KWin reports ids as 0 here, so we use our own state + end times.334
slotAnimationEnded(window, id) {349
slotAnimationEnded(window, id) {335
// marble is drawn outside the window's own damage region: repaint all on every end350
// marble is drawn outside the window's own damage region: repaint all on every end@@ -786,6 +786,9 @@ void main() {
786
786
col.a = step(0.97, col.a); // ignore the window shadow
787
787
col.a = mix(col.a, 1.0, e); // marble is solid
788
788
col.rgb = clamp(col.rgb, 0.0, 1.0);
789
// KWin gives an empty snapshot when this effect was already busy with another window:
790
// then draw a plain glass marble (no window image) instead of a black/invisible one
791
if (getInputColor(vec2(0.5)).a < 0.004) col = vec4(vec3(0.16), e);
789
792
790
793
if (uDebug > 1.5) { setOutputColor(vec4(col.rgb, col.a * clamp(-d, 0.0, 1.0))); return; }
791
794
// glossy marble shading
@@ -786,6 +786,9 @@ void main() {786
col.a = step(0.97, col.a); // ignore the window shadow786
col.a = step(0.97, col.a); // ignore the window shadow787
col.a = mix(col.a, 1.0, e); // marble is solid787
col.a = mix(col.a, 1.0, e); // marble is solid788
col.rgb = clamp(col.rgb, 0.0, 1.0);788
col.rgb = clamp(col.rgb, 0.0, 1.0);789
// KWin gives an empty snapshot when this effect was already busy with another window:790
// then draw a plain glass marble (no window image) instead of a black/invisible one791
if (getInputColor(vec2(0.5)).a < 0.004) col = vec4(vec3(0.16), e);789
792
790
if (uDebug > 1.5) { setOutputColor(vec4(col.rgb, col.a * clamp(-d, 0.0, 1.0))); return; }793
if (uDebug > 1.5) { setOutputColor(vec4(col.rgb, col.a * clamp(-d, 0.0, 1.0))); return; }791
// glossy marble shading794
// glossy marble shading@@ -787,6 +787,9 @@ void main() {
787
787
col.a = step(0.97, col.a); // ignore the window shadow
788
788
col.a = mix(col.a, 1.0, e); // marble is solid
789
789
col.rgb = clamp(col.rgb, 0.0, 1.0);
790
// KWin gives an empty snapshot when this effect was already busy with another window:
791
// then draw a plain glass marble (no window image) instead of a black/invisible one
792
if (getInputColor(vec2(0.5)).a < 0.004) col = vec4(vec3(0.16), e);
790
793
791
794
if (uDebug > 1.5) { setOutputColor(vec4(col.rgb, col.a * clamp(-d, 0.0, 1.0))); return; }
792
795
// glossy marble shading
@@ -787,6 +787,9 @@ void main() {787
col.a = step(0.97, col.a); // ignore the window shadow787
col.a = step(0.97, col.a); // ignore the window shadow788
col.a = mix(col.a, 1.0, e); // marble is solid788
col.a = mix(col.a, 1.0, e); // marble is solid789
col.rgb = clamp(col.rgb, 0.0, 1.0);789
col.rgb = clamp(col.rgb, 0.0, 1.0);790
// KWin gives an empty snapshot when this effect was already busy with another window:791
// then draw a plain glass marble (no window image) instead of a black/invisible one792
if (getInputColor(vec2(0.5)).a < 0.004) col = vec4(vec3(0.16), e);790
793
791
if (uDebug > 1.5) { setOutputColor(vec4(col.rgb, col.a * clamp(-d, 0.0, 1.0))); return; }794
if (uDebug > 1.5) { setOutputColor(vec4(col.rgb, col.a * clamp(-d, 0.0, 1.0))); return; }792
// glossy marble shading795
// glossy marble shading