1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*********************************************************************/
21
#include "fadedesktop.h"
28
KWIN_EFFECT(fadedesktop, FadeDesktopEffect)
30
FadeDesktopEffect::FadeDesktopEffect()
33
connect(effects, SIGNAL(desktopChanged(int,int)), this, SLOT(slotDesktopChanged(int)));
34
m_timeline.setCurveShape(QTimeLine::LinearCurve);
35
reconfigure(ReconfigureAll);
38
void FadeDesktopEffect::reconfigure(ReconfigureFlags)
40
m_timeline.setDuration(animationTime(250));
43
void FadeDesktopEffect::prePaintScreen(ScreenPrePaintData &data, int time)
46
m_timeline.setCurrentTime(m_timeline.currentTime() + time);
48
// PAINT_SCREEN_BACKGROUND_FIRST is needed because screen will be actually painted more than once,
49
// so with normal screen painting second screen paint would erase parts of the first paint
50
if (m_timeline.currentValue() != 1.0)
51
data.mask |= PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_BACKGROUND_FIRST;
54
m_timeline.setCurrentTime(0);
55
foreach (EffectWindow * w, effects->stackingOrder()) {
56
w->setData(WindowForceBlurRole, QVariant(false));
58
effects->setActiveFullScreenEffect(NULL);
61
effects->prePaintScreen(data, time);
64
void FadeDesktopEffect::postPaintScreen()
67
effects->addRepaintFull();
68
effects->postPaintScreen();
71
void FadeDesktopEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
74
if (w->isOnDesktop(m_oldDesktop))
75
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
76
data.setTranslucent();
78
effects->prePaintWindow(w, data, time);
81
void FadeDesktopEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
83
if (m_fading && !(w->isOnCurrentDesktop() && w->isOnDesktop(m_oldDesktop))) {
84
if (w->isOnDesktop(m_oldDesktop))
85
data.opacity *= 1 - m_timeline.currentValue();
87
data.opacity *= m_timeline.currentValue();
89
effects->paintWindow(w, mask, region, data);
92
void FadeDesktopEffect::slotDesktopChanged(int old)
94
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
97
// TODO: Fix glitches when fading while a previous fade is still happening
99
effects->setActiveFullScreenEffect(this);
101
m_timeline.setCurrentTime(0);
103
foreach (EffectWindow * w, effects->stackingOrder()) {
104
w->setData(WindowForceBlurRole, QVariant(true));
107
effects->addRepaintFull();
112
#include "fadedesktop.moc"