Prefer composited logout effect if possible.

I'm just having problems with changing the saturation, I cannot
get it to simply go to gray by reducing data.saturation :-/.

CCMAIL: rivolaks@hot.ee


svn path=/trunk/KDE/kdebase/workspace/; revision=736342
This commit is contained in:
Luboš Luňák 2007-11-14 00:09:14 +00:00
parent e13c612922
commit d2c3d1a832
4 changed files with 138 additions and 0 deletions

View file

@ -41,6 +41,7 @@ SET(kwin4_effect_builtins_sources
diminactive.cpp
fade.cpp
fallapart.cpp
logout.cpp
maketransparent.cpp
minimizeanimation.cpp
presentwindows.cpp
@ -57,6 +58,7 @@ install( FILES
diminactive.desktop
fade.desktop
fallapart.desktop
logout.desktop
maketransparent.desktop
minimizeanimation.desktop
presentwindows.desktop

80
effects/logout.cpp Normal file
View file

@ -0,0 +1,80 @@
/*****************************************************************
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 "logout.h"
#include <kdebug.h>
namespace KWin
{
KWIN_EFFECT( logout, LogoutEffect )
LogoutEffect::LogoutEffect()
: progress( 0 )
, logout_window( NULL )
{
}
void LogoutEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
if( logout_window != NULL )
{
progress = qBound( 0., progress + time / 1000., 1. );
data.mask &= ~Effect::PAINT_SCREEN_REGION;
}
effects->prePaintScreen( data, time );
}
void LogoutEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
{
if( w != logout_window && progress != 0 )
{
data.saturation *= ( 1 - progress * 0.6 );
data.brightness *= ( 1 - progress * 0.6 ); // otherwise saturation doesn't work ???
}
effects->paintWindow( w, mask, region, data );
}
void LogoutEffect::postPaintWindow( EffectWindow* w )
{
if( logout_window != NULL && w != logout_window && progress != 1 )
w->addRepaintFull();
effects->postPaintWindow( w );
}
void LogoutEffect::windowAdded( EffectWindow* w )
{
if( isLogoutDialog( w ))
{
logout_window = w;
progress = 0;
effects->addRepaintFull();
}
}
void LogoutEffect::windowClosed( EffectWindow* w )
{
if( w == logout_window )
{
logout_window = NULL;
progress = 0;
effects->addRepaintFull();
}
}
bool LogoutEffect::isLogoutDialog( EffectWindow* w )
{ // TODO there should be probably a better way (window type?)
if( w->windowClass() == "ksmserver ksmserver" && w->windowRole() == "logoutdialog" )
return true;
return false;
}
} // namespace

18
effects/logout.desktop Normal file
View file

@ -0,0 +1,18 @@
[Desktop Entry]
Encoding=UTF-8
Name=Logout
Icon=preferences-system-windows-effect-logout
Comment=Logout 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_logout
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

38
effects/logout.h Normal file
View file

@ -0,0 +1,38 @@
/*****************************************************************
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_LOGOUT_H
#define KWIN_LOGOUT_H
#include <kwineffects.h>
namespace KWin
{
class LogoutEffect
: public Effect
{
public:
LogoutEffect();
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
virtual void postPaintWindow( EffectWindow* w );
virtual void windowAdded( EffectWindow* w );
virtual void windowClosed( EffectWindow* w );
private:
bool isLogoutDialog( EffectWindow* w );
double progress; // 0-1
EffectWindow* logout_window;
};
} // namespace
#endif