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 *********************************************************************/
28 KWIN_EFFECT( login
, LoginEffect
)
30 LoginEffect::LoginEffect()
32 , login_window( NULL
)
36 void LoginEffect::prePaintScreen( ScreenPrePaintData
& data
, int time
)
38 if( login_window
!= NULL
)
42 progress
= qBound( 0.0, progress
+ time
/ animationTime( 2000 ), 1.0 );
45 login_window
->unrefWindow();
47 effects
->prePaintScreen( data
, time
);
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
))
85 effects
->addRepaintFull();
89 void LoginEffect::windowClosed( EffectWindow
* w
)
91 if( w
== login_window
)
93 login_window
->refWindow();
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" )