From 9e0a19aa2e85042ced47b05b8474942db3091a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Wed, 14 Nov 2007 01:01:02 +0000 Subject: [PATCH] Login effect. svn path=/trunk/KDE/kdebase/workspace/; revision=736359 --- effects/CMakeLists.txt | 2 + effects/login.cpp | 112 +++++++++++++++++++++++++++++++++++++++++ effects/login.desktop | 18 +++++++ effects/login.h | 39 ++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 effects/login.cpp create mode 100644 effects/login.desktop create mode 100644 effects/login.h diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index aaf843ba2c..0cbd3c6192 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -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 diff --git a/effects/login.cpp b/effects/login.cpp new file mode 100644 index 0000000000..889da2fcc5 --- /dev/null +++ b/effects/login.cpp @@ -0,0 +1,112 @@ +/***************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2007 Lubos Lunak + +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 + +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 diff --git a/effects/login.desktop b/effects/login.desktop new file mode 100644 index 0000000000..a55df3b17e --- /dev/null +++ b/effects/login.desktop @@ -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 diff --git a/effects/login.h b/effects/login.h new file mode 100644 index 0000000000..deb2f351b5 --- /dev/null +++ b/effects/login.h @@ -0,0 +1,39 @@ +/***************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2007 Lubos Lunak + +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 + + +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