Login effect.
svn path=/trunk/KDE/kdebase/workspace/; revision=736359
This commit is contained in:
parent
30745b9c5d
commit
9e0a19aa2e
4 changed files with 171 additions and 0 deletions
|
@ -41,6 +41,7 @@ SET(kwin4_effect_builtins_sources
|
|||
diminactive.cpp
|
||||
fade.cpp
|
||||
fallapart.cpp
|
||||
login.cpp
|
||||
logout.cpp
|
||||
maketransparent.cpp
|
||||
minimizeanimation.cpp
|
||||
|
@ -58,6 +59,7 @@ install( FILES
|
|||
diminactive.desktop
|
||||
fade.desktop
|
||||
fallapart.desktop
|
||||
login.desktop
|
||||
logout.desktop
|
||||
maketransparent.desktop
|
||||
minimizeanimation.desktop
|
||||
|
|
112
effects/login.cpp
Normal file
112
effects/login.cpp
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*****************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
|
||||
|
||||
You can Freely distribute this program under the GNU General Public
|
||||
License. See the file "COPYING" for the exact licensing terms.
|
||||
******************************************************************/
|
||||
|
||||
#include "login.h"
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( login, LoginEffect )
|
||||
|
||||
LoginEffect::LoginEffect()
|
||||
: progress( 1 )
|
||||
, login_window( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
void LoginEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
if( login_window != NULL )
|
||||
{
|
||||
if( progress != 1 )
|
||||
{
|
||||
progress = qBound( 0., progress + time / 2000., 1. );
|
||||
if( progress == 1 )
|
||||
{
|
||||
login_window->unrefWindow();
|
||||
login_window = NULL;
|
||||
effects->prePaintScreen( data, time );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
effects->prePaintScreen( data, time );
|
||||
}
|
||||
|
||||
void LoginEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
|
||||
{
|
||||
if( progress != 1 && w == login_window )
|
||||
{
|
||||
w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE );
|
||||
data.setTranslucent();
|
||||
}
|
||||
effects->prePaintWindow( w, data, time );
|
||||
}
|
||||
|
||||
void LoginEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
||||
{
|
||||
if( login_window != NULL )
|
||||
{
|
||||
if( progress == 1 )
|
||||
{
|
||||
if( w != login_window )
|
||||
data.brightness = 0; // not visible
|
||||
}
|
||||
else
|
||||
{
|
||||
if( w == login_window )
|
||||
data.opacity *= ( 1 - progress );
|
||||
else
|
||||
data.brightness *= progress;
|
||||
}
|
||||
}
|
||||
effects->paintWindow( w, mask, region, data );
|
||||
}
|
||||
|
||||
void LoginEffect::postPaintScreen()
|
||||
{
|
||||
if( login_window != NULL && progress != 1 )
|
||||
effects->addRepaintFull();
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
|
||||
void LoginEffect::windowAdded( EffectWindow* w )
|
||||
{
|
||||
if( isLoginSplash( w ))
|
||||
{
|
||||
login_window = w;
|
||||
progress = 1;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
void LoginEffect::windowClosed( EffectWindow* w )
|
||||
{
|
||||
if( w == login_window )
|
||||
{
|
||||
login_window->refWindow();
|
||||
progress = 0;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
bool LoginEffect::isLoginSplash( EffectWindow* w )
|
||||
{ // TODO there should be probably a better way (window type?)
|
||||
if( w->windowClass() == "ksplashx ksplashx"
|
||||
|| w->windowClass() == "ksplashsimple ksplashsimple" )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
18
effects/login.desktop
Normal file
18
effects/login.desktop
Normal file
|
@ -0,0 +1,18 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Login
|
||||
Icon=preferences-system-windows-effect-login
|
||||
Comment=Login visual effect
|
||||
|
||||
Type=Service
|
||||
ServiceTypes=KWin/Effect
|
||||
X-KDE-PluginInfo-Author=Lubos Lunak
|
||||
X-KDE-PluginInfo-Email=l.lunak@kde.org
|
||||
X-KDE-PluginInfo-Name=kwin4_effect_login
|
||||
X-KDE-PluginInfo-Version=0.1.0
|
||||
X-KDE-PluginInfo-Category=Appearance
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
||||
X-KDE-Library=kwin4_effect_builtins
|
||||
X-Ordering=40
|
39
effects/login.h
Normal file
39
effects/login.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*****************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
|
||||
|
||||
You can Freely distribute this program under the GNU General Public
|
||||
License. See the file "COPYING" for the exact licensing terms.
|
||||
******************************************************************/
|
||||
|
||||
#ifndef KWIN_LOGIN_H
|
||||
#define KWIN_LOGIN_H
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class LoginEffect
|
||||
: public Effect
|
||||
{
|
||||
public:
|
||||
LoginEffect();
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
virtual void windowAdded( EffectWindow* w );
|
||||
virtual void windowClosed( EffectWindow* w );
|
||||
private:
|
||||
bool isLoginSplash( EffectWindow* w );
|
||||
double progress; // 0-1
|
||||
EffectWindow* login_window;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue