From d2c3d1a8322877fc3a719e4f6168c0a95bc06933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Wed, 14 Nov 2007 00:09:14 +0000 Subject: [PATCH] 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 --- effects/CMakeLists.txt | 2 ++ effects/logout.cpp | 80 ++++++++++++++++++++++++++++++++++++++++++ effects/logout.desktop | 18 ++++++++++ effects/logout.h | 38 ++++++++++++++++++++ 4 files changed, 138 insertions(+) create mode 100644 effects/logout.cpp create mode 100644 effects/logout.desktop create mode 100644 effects/logout.h diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index e990f68d8e..aaf843ba2c 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -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 diff --git a/effects/logout.cpp b/effects/logout.cpp new file mode 100644 index 0000000000..02687ba5a9 --- /dev/null +++ b/effects/logout.cpp @@ -0,0 +1,80 @@ +/***************************************************************** + 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 "logout.h" + +#include + +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 diff --git a/effects/logout.desktop b/effects/logout.desktop new file mode 100644 index 0000000000..df3f7528f5 --- /dev/null +++ b/effects/logout.desktop @@ -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 diff --git a/effects/logout.h b/effects/logout.h new file mode 100644 index 0000000000..96ec129daa --- /dev/null +++ b/effects/logout.h @@ -0,0 +1,38 @@ +/***************************************************************** + 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_LOGOUT_H +#define KWIN_LOGOUT_H + +#include + + +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