From 437a36a2bb86222f1c3d086c15a2f60eef898c1a Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 24 Apr 2018 23:20:14 +0200 Subject: [PATCH] [KScreen Effect] Fix fade to black Summary: When you have two windows ontop of each other and you turn them transparent, evidently you'll be able to see through them. Not only does it look unpolished if the desktop window flashes through your windows, it can pose a privacy risk as you'd be able to briefly look through the lock screen. This patch fades apps to black intead of to transparent. As this looks weird for panels, so windows are also faded to opaque (if relevant) at the same rate. BUG: 388384 Reviewers: #plasma, graesslin Subscribers: luebking, plasma-devel, kwin, #kwin Tags: #plasma Differential Revision: https://phabricator.kde.org/D9608 --- effects/kscreen/kscreen.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/effects/kscreen/kscreen.cpp b/effects/kscreen/kscreen.cpp index 2d167110b5..ee21ac5c20 100644 --- a/effects/kscreen/kscreen.cpp +++ b/effects/kscreen/kscreen.cpp @@ -105,19 +105,23 @@ void KscreenEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, in void KscreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) { + //fade to black and fully opaque switch (m_state) { - case StateFadingOut: - data.multiplyOpacity(1.0 - m_timeLine.currentValue()); - break; - case StateFadedOut: - data.multiplyOpacity(0.0); - break; - case StateFadingIn: - data.multiplyOpacity(m_timeLine.currentValue()); - break; - default: - // no adjustment - break; + case StateFadingOut: + data.setOpacity(data.opacity() + (1.0 - data.opacity()) * m_timeLine.currentValue()); + data.multiplyBrightness(1.0 - m_timeLine.currentValue()); + break; + case StateFadedOut: + data.multiplyOpacity(0.0); + data.multiplyBrightness(0.0); + break; + case StateFadingIn: + data.setOpacity(data.opacity() + (1.0 - data.opacity()) * (1.0 - m_timeLine.currentValue())); + data.multiplyBrightness(m_timeLine.currentValue()); + break; + default: + // no adjustment + break; } effects->paintWindow(w, mask, region, data); }