1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2008, 2009 Martin Gräßlin <kde@martin-graesslin.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
*********************************************************************/
20
#include "dimscreen.h"
22
#include <kwinglutils.h>
27
KWIN_EFFECT(dimscreen, DimScreenEffect)
29
DimScreenEffect::DimScreenEffect()
31
, activateAnimation(false)
32
, deactivateAnimation(false)
34
reconfigure(ReconfigureAll);
35
connect(effects, SIGNAL(windowActivated(EffectWindow*)), this, SLOT(slotWindowActivated(EffectWindow*)));
38
DimScreenEffect::~DimScreenEffect()
42
void DimScreenEffect::reconfigure(ReconfigureFlags)
44
timeline.setDuration(animationTime(250));
47
void DimScreenEffect::prePaintScreen(ScreenPrePaintData& data, int time)
49
if (mActivated && activateAnimation && !effects->activeFullScreenEffect())
50
timeline.setCurrentTime(timeline.currentTime() + time);
51
if (mActivated && deactivateAnimation)
52
timeline.setCurrentTime(timeline.currentTime() - time);
53
if (mActivated && effects->activeFullScreenEffect())
54
timeline.setCurrentTime(timeline.currentTime() - time);
55
if (mActivated && !activateAnimation && !deactivateAnimation && !effects->activeFullScreenEffect() && timeline.currentValue() != 1.0)
56
timeline.setCurrentTime(timeline.currentTime() + time);
57
effects->prePaintScreen(data, time);
60
void DimScreenEffect::postPaintScreen()
63
if (activateAnimation && timeline.currentValue() == 1.0) {
64
activateAnimation = false;
65
effects->addRepaintFull();
67
if (deactivateAnimation && timeline.currentValue() == 0.0) {
68
deactivateAnimation = false;
70
effects->addRepaintFull();
73
if (timeline.currentValue() > 0.0 && timeline.currentValue() < 1.0)
74
effects->addRepaintFull();
76
effects->postPaintScreen();
79
void DimScreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
81
if (mActivated && (w != window) && w->isManaged()) {
82
data.brightness *= (1.0 - 0.33 * timeline.currentValue());
83
data.saturation *= (1.0 - 0.33 * timeline.currentValue());
85
effects->paintWindow(w, mask, region, data);
88
void DimScreenEffect::slotWindowActivated(EffectWindow *w)
92
check << "kdesu kdesu";
93
check << "kdesudo kdesudo";
94
check << "polkit-kde-manager polkit-kde-manager";
95
check << "polkit-kde-authentication-agent-1 polkit-kde-authentication-agent-1";
96
check << "pinentry pinentry";
97
if (check.contains(w->windowClass())) {
99
activateAnimation = true;
100
deactivateAnimation = false;
102
effects->addRepaintFull();
105
activateAnimation = false;
106
deactivateAnimation = true;
107
effects->addRepaintFull();