451bbb54dd
Summary: For Wayland windows we can have a sequence of window unmapped (windowHidden signal) followed by a windowClosed way later when the application quits. This is for example the case with menus. The result of this was that the fade out animation triggered when the application quit showing all the already closed menus again. This change implements a windowShown and windowHidden handler and triggers the fadeIn/Out animation on it. If the window gets shown again the existing fadeOut animation gets cancelled, so that it can run again. If a window gets closed for which a fade out animation has been run already, it's not triggered again, thus ensuring that we don't see zombie windows. CCBUG: 372622 Reviewers: #kwin, #plasma_on_wayland, hein Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D3419
90 lines
3.5 KiB
JavaScript
90 lines
3.5 KiB
JavaScript
/********************************************************************
|
|
KWin - the KDE window manager
|
|
This file is part of the KDE project.
|
|
|
|
Copyright (C) 2007 Philip Falkner <philip.falkner@gmail.com>
|
|
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*********************************************************************/
|
|
function isFadeWindow(w) {
|
|
if (w.deleted && effect.isGrabbed(w, Effect.WindowClosedGrabRole)) {
|
|
return false;
|
|
} else if (!w.deleted && effect.isGrabbed(w, Effect.WindowAddedGrabRole)) {
|
|
return false;
|
|
}
|
|
return w.onCurrentDesktop && !isLoginWindow(w) && !w.desktopWindow && !w.utility && !w.minimized;
|
|
}
|
|
|
|
function isLoginWindow(w) {
|
|
return w.windowClass == "ksplashx ksplashx" || w.windowClass == "ksplashsimple ksplashsimple" || w.windowClass == "ksplashqml ksplashqml";
|
|
}
|
|
|
|
var fadeInTime, fadeOutTime, fadeWindows;
|
|
function loadConfig() {
|
|
fadeInTime = animationTime(effect.readConfig("FadeInTime", 150));
|
|
fadeOutTime = animationTime(effect.readConfig("FadeOutTime", 150)) * 4;
|
|
fadeWindows = effect.readConfig("FadeWindows", true);
|
|
}
|
|
loadConfig();
|
|
effect.configChanged.connect(function() {
|
|
loadConfig();
|
|
});
|
|
function fadeInHandler(w) {
|
|
if (fadeWindows && isFadeWindow(w)) {
|
|
if (w.fadeOutWindowTypeAnimation !== undefined) {
|
|
cancel(w.fadeOutWindowTypeAnimation);
|
|
w.fadeOutWindowTypeAnimation = undefined;
|
|
}
|
|
w.fadeInWindowTypeAnimation = effect.animate(w, Effect.Opacity, fadeInTime, 1.0, 0.0);
|
|
}
|
|
}
|
|
function fadeOutHandler(w) {
|
|
if (fadeWindows && isFadeWindow(w)) {
|
|
if (w.fadeOutWindowTypeAnimation !== undefined) {
|
|
// don't animate again as it was already animated through window hidden
|
|
return;
|
|
}
|
|
w.fadeOutWindowTypeAnimation = animate({
|
|
window: w,
|
|
duration: fadeOutTime,
|
|
animations: [{
|
|
type: Effect.Opacity,
|
|
curve: QEasingCurve.OutQuart,
|
|
to: 0.0
|
|
}]
|
|
});
|
|
}
|
|
}
|
|
effects.windowAdded.connect(fadeInHandler);
|
|
effects.windowShown.connect(fadeInHandler);
|
|
effects.windowClosed.connect(fadeOutHandler);
|
|
effects.windowHidden.connect(fadeOutHandler);
|
|
effects.windowDataChanged.connect(function (window, role) {
|
|
if (role == Effect.WindowAddedGrabRole) {
|
|
if (effect.isGrabbed(window, Effect.WindowAddedGrabRole)) {
|
|
if (window.fadeInWindowTypeAnimation !== undefined) {
|
|
cancel(window.fadeInWindowTypeAnimation);
|
|
window.fadeInWindowTypeAnimation = undefined;
|
|
}
|
|
}
|
|
} else if (role == Effect.WindowClosedGrabRole) {
|
|
if (effect.isGrabbed(window, Effect.WindowClosedGrabRole)) {
|
|
if (window.fadeOutWindowTypeAnimation !== undefined) {
|
|
cancel(window.fadeOutWindowTypeAnimation);
|
|
window.fadeOutWindowTypeAnimation = undefined;
|
|
}
|
|
}
|
|
}
|
|
});
|