Merge EffectWindow::{windowMinimized,windowUnminimized}

The main motivation is to match the Window API.
This commit is contained in:
Vlad Zahorodnii 2023-11-21 13:39:23 +02:00
parent 017b4019b6
commit 2ff0fc26a4
18 changed files with 97 additions and 42 deletions

View file

@ -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);
}
});
});

View file

@ -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);
}
});
});

View file

@ -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 {

View file

@ -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) {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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);

View file

@ -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

View file

@ -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);

View file

@ -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();

View file

@ -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);

View file

@ -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)

View file

@ -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)

View file

@ -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);

View file

@ -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);