add more spacing
[personal-kdebase.git] / workspace / kwin / effects / login.cpp
blob84a0c3550a5492bea852081ad559a6342235d078
1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
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 "login.h"
23 #include <kdebug.h>
25 namespace KWin
28 KWIN_EFFECT( login, LoginEffect )
30 LoginEffect::LoginEffect()
31 : progress( 1.0 )
32 , login_window( NULL )
36 void LoginEffect::prePaintScreen( ScreenPrePaintData& data, int time )
38 if( login_window != NULL )
40 if( progress != 1.0 )
42 progress = qBound( 0.0, progress + time / animationTime( 2000 ), 1.0 );
43 if( progress == 1.0 )
45 login_window->unrefWindow();
46 login_window = NULL;
47 effects->prePaintScreen( data, time );
48 return;
52 effects->prePaintScreen( data, time );
55 void LoginEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
57 if( progress != 1.0 && w == login_window )
59 w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE );
60 data.setTranslucent();
62 effects->prePaintWindow( w, data, time );
65 void LoginEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
67 if( w == login_window && progress != 1.0 )
68 data.opacity *= ( 1.0 - progress );
69 effects->paintWindow( w, mask, region, data );
72 void LoginEffect::postPaintScreen()
74 if( login_window != NULL && progress != 1.0 )
75 effects->addRepaintFull();
76 effects->postPaintScreen();
79 void LoginEffect::windowAdded( EffectWindow* w )
81 if( isLoginSplash( w ))
83 login_window = w;
84 progress = 1.0;
85 effects->addRepaintFull();
89 void LoginEffect::windowClosed( EffectWindow* w )
91 if( w == login_window )
93 login_window->refWindow();
94 progress = 0.0;
95 effects->addRepaintFull();
99 bool LoginEffect::isLoginSplash( EffectWindow* w )
100 { // TODO there should be probably a better way (window type?)
101 // see also fade effect and composite.cpp
102 if( w->windowClass() == "ksplashx ksplashx"
103 || w->windowClass() == "ksplashsimple ksplashsimple" )
105 return true;
107 return false;
110 } // namespace