From 2ff0fc26a42ea3d0016e948372858d0515648e20 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 21 Nov 2023 13:39:23 +0200 Subject: [PATCH] Merge EffectWindow::{windowMinimized,windowUnminimized} The main motivation is to match the Window API. --- .../integration/effects/scripts/animationTest.js | 9 +++++++-- .../effects/scripts/animationTestMulti.js | 9 +++++++-- .../integration/effects/scripts/completeTest.js | 5 ++++- .../integration/effects/scripts/effectsHandler.js | 11 ++++++----- .../scripts/redirectAnimateDontTerminateTest.js | 5 ++++- .../effects/scripts/redirectAnimateTerminateTest.js | 5 ++++- .../effects/scripts/redirectSetDontTerminateTest.js | 5 ++++- .../effects/scripts/redirectSetTerminateTest.js | 5 ++++- autotests/integration/effects/scripts/ungrabTest.js | 5 ++++- src/effect/effectwindow.cpp | 6 +----- src/effect/effectwindow.h | 11 +++-------- .../dialogparent/package/contents/code/main.js | 9 +++++++-- src/plugins/dimscreen/package/contents/code/main.js | 9 +++++++-- src/plugins/frozenapp/package/contents/code/main.js | 9 +++++++-- src/plugins/magiclamp/magiclamp.cpp | 9 +++++++-- src/plugins/slideback/slideback.cpp | 6 +++++- src/plugins/squash/package/contents/code/main.js | 9 +++++++-- .../translucency/package/contents/code/main.js | 12 +++++++++--- 18 files changed, 97 insertions(+), 42 deletions(-) diff --git a/autotests/integration/effects/scripts/animationTest.js b/autotests/integration/effects/scripts/animationTest.js index 0e325076b9..83e4beb5b3 100644 --- a/autotests/integration/effects/scripts/animationTest.js +++ b/autotests/integration/effects/scripts/animationTest.js @@ -2,6 +2,11 @@ effects.windowAdded.connect(function(w) { w.anim1 = effect.animate(w, Effect.Scale, 100, 1.4, 0.2, 0, QEasingCurve.OutCubic); sendTestResponse(typeof(w.anim1) == "number"); - w.windowUnminimized.connect(() => cancel(w.anim1)); - w.windowMinimized.connect(() => retarget(w.anim1, 1.5, 200)); + w.minimizedChanged.connect(() => { + if (w.minimized) { + retarget(w.anim1, 1.5, 200); + } else { + cancel(w.anim1); + } + }); }); diff --git a/autotests/integration/effects/scripts/animationTestMulti.js b/autotests/integration/effects/scripts/animationTestMulti.js index 1e5beb4c50..6f1038bcbc 100644 --- a/autotests/integration/effects/scripts/animationTestMulti.js +++ b/autotests/integration/effects/scripts/animationTestMulti.js @@ -14,6 +14,11 @@ effects.windowAdded.connect(function(w) { }); sendTestResponse(typeof(w.anim1) == "object" && Array.isArray(w.anim1)); - w.windowUnminimized.connect(() => cancel(w.anim1)); - w.windowMinimized.connect(() => retarget(w.anim1, 1.5, 200)); + w.minimizedChanged.connect(() => { + if (w.minimized) { + retarget(w.anim1, 1.5, 200); + } else { + cancel(w.anim1); + } + }); }); diff --git a/autotests/integration/effects/scripts/completeTest.js b/autotests/integration/effects/scripts/completeTest.js index 041aba5ef7..055fa48cc8 100644 --- a/autotests/integration/effects/scripts/completeTest.js +++ b/autotests/integration/effects/scripts/completeTest.js @@ -9,7 +9,10 @@ effects.windowAdded.connect(function (window) { keepAlive: false }); - window.windowMinimized.connect(() => { + window.minimizedChanged.connect(() => { + if (!window.minimized) { + return; + } if (complete(window.animation)) { sendTestResponse('ok'); } else { diff --git a/autotests/integration/effects/scripts/effectsHandler.js b/autotests/integration/effects/scripts/effectsHandler.js index a2e47461e5..ee98578341 100644 --- a/autotests/integration/effects/scripts/effectsHandler.js +++ b/autotests/integration/effects/scripts/effectsHandler.js @@ -2,11 +2,12 @@ effects.windowAdded.connect(function(window) { sendTestResponse("windowAdded - " + window.caption); sendTestResponse("stackingOrder - " + effects.stackingOrder.length + " " + effects.stackingOrder[0].caption); - window.windowMinimized.connect(() => { - sendTestResponse("windowMinimized - " + window.caption); - }); - window.windowUnminimized.connect(() => { - sendTestResponse("windowUnminimized - " + window.caption); + window.minimizedChanged.connect(() => { + if (window.minimized) { + sendTestResponse("windowMinimized - " + window.caption); + } else { + sendTestResponse("windowUnminimized - " + window.caption); + } }); }); effects.windowClosed.connect(function(window) { diff --git a/autotests/integration/effects/scripts/redirectAnimateDontTerminateTest.js b/autotests/integration/effects/scripts/redirectAnimateDontTerminateTest.js index d54d7c21d0..d3cd3e3953 100644 --- a/autotests/integration/effects/scripts/redirectAnimateDontTerminateTest.js +++ b/autotests/integration/effects/scripts/redirectAnimateDontTerminateTest.js @@ -8,7 +8,10 @@ effects.windowAdded.connect(function (window) { to: 1.0 }) - window.windowMinimized.connect(() => { + window.minimizedChanged.connect(() => { + if (!window.minimized) { + return; + } if (redirect(window.animation, Effect.Backward, Effect.DontTerminate)) { sendTestResponse('ok'); } else { diff --git a/autotests/integration/effects/scripts/redirectAnimateTerminateTest.js b/autotests/integration/effects/scripts/redirectAnimateTerminateTest.js index b3cfe4b0b1..22422e8571 100644 --- a/autotests/integration/effects/scripts/redirectAnimateTerminateTest.js +++ b/autotests/integration/effects/scripts/redirectAnimateTerminateTest.js @@ -8,7 +8,10 @@ effects.windowAdded.connect(function (window) { to: 1.0 }); - window.windowMinimized.connect(() => { + window.minimizedChanged.connect(() => { + if (!window.minimized) { + return; + } if (redirect(window.animation, Effect.Backward, Effect.TerminateAtSource)) { sendTestResponse('ok'); } else { diff --git a/autotests/integration/effects/scripts/redirectSetDontTerminateTest.js b/autotests/integration/effects/scripts/redirectSetDontTerminateTest.js index d8230f35b3..8f24b51509 100644 --- a/autotests/integration/effects/scripts/redirectSetDontTerminateTest.js +++ b/autotests/integration/effects/scripts/redirectSetDontTerminateTest.js @@ -9,7 +9,10 @@ effects.windowAdded.connect(function (window) { keepAlive: false }); - window.windowMinimized.connect(() => { + window.minimizedChanged.connect(() => { + if (!window.minimized) { + return; + } if (redirect(window.animation, Effect.Backward, Effect.DontTerminate)) { sendTestResponse('ok'); } else { diff --git a/autotests/integration/effects/scripts/redirectSetTerminateTest.js b/autotests/integration/effects/scripts/redirectSetTerminateTest.js index 85a6a9dcec..bf7bbbb23f 100644 --- a/autotests/integration/effects/scripts/redirectSetTerminateTest.js +++ b/autotests/integration/effects/scripts/redirectSetTerminateTest.js @@ -9,7 +9,10 @@ effects.windowAdded.connect(function (window) { keepAlive: false }); - window.windowMinimized.connect(() => { + window.minimizedChanged.connect(() => { + if (!window.minimized) { + return; + } if (redirect(window.animation, Effect.Backward, Effect.TerminateAtSource)) { sendTestResponse('ok'); } else { diff --git a/autotests/integration/effects/scripts/ungrabTest.js b/autotests/integration/effects/scripts/ungrabTest.js index 771b84ac42..ed96729079 100644 --- a/autotests/integration/effects/scripts/ungrabTest.js +++ b/autotests/integration/effects/scripts/ungrabTest.js @@ -5,7 +5,10 @@ effects.windowAdded.connect(function (window) { sendTestResponse('fail'); } - window.windowMinimized.connect(() => { + window.minimizedChanged.connect(() => { + if (!window.minimized) { + return; + } if (effect.ungrab(window, Effect.WindowAddedGrabRole)) { sendTestResponse('ok'); } else { diff --git a/src/effect/effectwindow.cpp b/src/effect/effectwindow.cpp index a7e83e428c..5e31cb9950 100644 --- a/src/effect/effectwindow.cpp +++ b/src/effect/effectwindow.cpp @@ -85,11 +85,7 @@ EffectWindow::EffectWindow(WindowItem *windowItem) Q_EMIT windowOpacityChanged(this, oldOpacity, window->opacity()); }); connect(d->m_window, &Window::minimizedChanged, this, [this]() { - if (d->m_window->isMinimized()) { - Q_EMIT windowMinimized(this); - } else { - Q_EMIT windowUnminimized(this); - } + Q_EMIT minimizedChanged(this); }); connect(d->m_window, &Window::modalChanged, this, [this]() { Q_EMIT windowModalityChanged(this); diff --git a/src/effect/effectwindow.h b/src/effect/effectwindow.h index 6ef32b7448..12878f1388 100644 --- a/src/effect/effectwindow.h +++ b/src/effect/effectwindow.h @@ -759,15 +759,10 @@ Q_SIGNALS: */ void windowOpacityChanged(KWin::EffectWindow *w, qreal oldOpacity, qreal newOpacity); /** - * Signal emitted when a window got minimized. - * @param w The window which was minimized + * Signal emitted when a window is minimized or unminimized. + * @param w The window whose minimized state has changed */ - void windowMinimized(KWin::EffectWindow *w); - /** - * Signal emitted when a window got unminimized. - * @param w The window which was unminimized - */ - void windowUnminimized(KWin::EffectWindow *w); + void minimizedChanged(KWin::EffectWindow *w); /** * Signal emitted when a window either becomes modal (ie. blocking for its main client) or looses that state. * @param w The window which was unminimized diff --git a/src/plugins/dialogparent/package/contents/code/main.js b/src/plugins/dialogparent/package/contents/code/main.js index 83847c75e0..6402815f24 100644 --- a/src/plugins/dialogparent/package/contents/code/main.js +++ b/src/plugins/dialogparent/package/contents/code/main.js @@ -13,8 +13,13 @@ var dialogParentEffect = { duration: animationTime(300), windowAdded: function (window) { "use strict"; - window.windowMinimized.connect(dialogParentEffect.cancelAnimationInstant); - window.windowUnminimized.connect(dialogParentEffect.restartAnimation); + window.minimizedChanged.connect(() => { + if (window.minimized) { + dialogParentEffect.cancelAnimationInstant(window); + } else { + dialogParentEffect.restartAnimation(window); + } + }); window.windowModalityChanged.connect(dialogParentEffect.modalDialogChanged); window.windowDesktopsChanged.connect(dialogParentEffect.cancelAnimationInstant); window.windowDesktopsChanged.connect(dialogParentEffect.restartAnimation); diff --git a/src/plugins/dimscreen/package/contents/code/main.js b/src/plugins/dimscreen/package/contents/code/main.js index 2ad5c00d13..7dd20e96de 100644 --- a/src/plugins/dimscreen/package/contents/code/main.js +++ b/src/plugins/dimscreen/package/contents/code/main.js @@ -160,8 +160,13 @@ var dimScreenEffect = { } }, slotWindowAdded: function (window) { - window.windowMinimized.connect(dimScreenEffect.cancelAnimationInstant); - window.windowUnminimized.connect(dimScreenEffect.restartAnimation); + window.minimizedChanged.connect(() => { + if (window.minimized) { + dimScreenEffect.cancelAnimationInstant(window); + } else { + dimScreenEffect.restartAnimation(window); + } + }); // Don't dim authentication agents that just opened. var agent = activeAuthenticationAgent(); diff --git a/src/plugins/frozenapp/package/contents/code/main.js b/src/plugins/frozenapp/package/contents/code/main.js index 05cd630be6..7ca4ac62dd 100644 --- a/src/plugins/frozenapp/package/contents/code/main.js +++ b/src/plugins/frozenapp/package/contents/code/main.js @@ -17,8 +17,13 @@ var frozenAppEffect = { frozenAppEffect.outDuration = animationTime(250); }, windowAdded: function (window) { - window.windowMinimized.connect(frozenAppEffect.cancelAnimation); - window.windowUnminimized.connect(frozenAppEffect.restartAnimation); + window.minimizedChanged.connect(() => { + if (window.minimized) { + frozenAppEffect.cancelAnimation(window); + } else { + frozenAppEffect.restartAnimation(window); + } + }); window.windowUnresponsiveChanged.connect(frozenAppEffect.unresponsiveChanged); window.windowDesktopsChanged.connect(frozenAppEffect.cancelAnimation); window.windowDesktopsChanged.connect(frozenAppEffect.restartAnimation); diff --git a/src/plugins/magiclamp/magiclamp.cpp b/src/plugins/magiclamp/magiclamp.cpp index f704ba2f8b..782201d27c 100644 --- a/src/plugins/magiclamp/magiclamp.cpp +++ b/src/plugins/magiclamp/magiclamp.cpp @@ -372,8 +372,13 @@ void MagicLampEffect::postPaintScreen() void MagicLampEffect::slotWindowAdded(EffectWindow *w) { - connect(w, &EffectWindow::windowMinimized, this, &MagicLampEffect::slotWindowMinimized); - connect(w, &EffectWindow::windowUnminimized, this, &MagicLampEffect::slotWindowUnminimized); + connect(w, &EffectWindow::minimizedChanged, this, [this, w]() { + if (w->isMinimized()) { + slotWindowMinimized(w); + } else { + slotWindowUnminimized(w); + } + }); } void MagicLampEffect::slotWindowDeleted(EffectWindow *w) diff --git a/src/plugins/slideback/slideback.cpp b/src/plugins/slideback/slideback.cpp index f60a04f6aa..21e5e295a1 100644 --- a/src/plugins/slideback/slideback.cpp +++ b/src/plugins/slideback/slideback.cpp @@ -278,7 +278,11 @@ void SlideBackEffect::slotWindowAdded(EffectWindow *w) { m_justMapped = w; - connect(w, &EffectWindow::windowUnminimized, this, &SlideBackEffect::slotWindowUnminimized); + connect(w, &EffectWindow::minimizedChanged, this, [this, w]() { + if (!w->isMinimized()) { + slotWindowUnminimized(w); + } + }); } void SlideBackEffect::slotWindowUnminimized(EffectWindow *w) diff --git a/src/plugins/squash/package/contents/code/main.js b/src/plugins/squash/package/contents/code/main.js index e8e37ad81a..3a8e07b437 100644 --- a/src/plugins/squash/package/contents/code/main.js +++ b/src/plugins/squash/package/contents/code/main.js @@ -146,8 +146,13 @@ var squashEffect = { }); }, slotWindowAdded: function (window) { - window.windowMinimized.connect(squashEffect.slotWindowMinimized); - window.windowUnminimized.connect(squashEffect.slotWindowUnminimized); + window.minimizedChanged.connect(() => { + if (window.minimized) { + squashEffect.slotWindowMinimized(window); + } else { + squashEffect.slotWindowUnminimized(window); + } + }); }, init: function () { effect.configChanged.connect(squashEffect.loadConfig); diff --git a/src/plugins/translucency/package/contents/code/main.js b/src/plugins/translucency/package/contents/code/main.js index d8ef136285..2dc50b0cce 100644 --- a/src/plugins/translucency/package/contents/code/main.js +++ b/src/plugins/translucency/package/contents/code/main.js @@ -207,11 +207,17 @@ var translucencyEffect = { manage: function (window) { window.windowDesktopsChanged.connect(translucencyEffect.cancelAnimations); window.windowDesktopsChanged.connect(translucencyEffect.startAnimation); - window.windowUnminimized.connect(translucencyEffect.startAnimation); - window.windowMinimized.connect(translucencyEffect.cancelAnimations); - window.windowUnminimized.connect(translucencyEffect.inactive.animate); window.windowStartUserMovedResized.connect(translucencyEffect.moveResize.start); window.windowFinishUserMovedResized.connect(translucencyEffect.moveResize.finish); + + window.minimizedChanged.connect(() => { + if (window.minimized) { + translucencyEffect.cancelAnimations(); + } else { + translucencyEffect.startAnimation(window); + translucencyEffect.inactive.animate(window); + } + }); }, init: function () { effect.configChanged.connect(translucencyEffect.loadConfig);