diff --git a/effects/logout/logout.cpp b/effects/logout/logout.cpp index 6fe089b9d..5fc474a7c 100644 --- a/effects/logout/logout.cpp +++ b/effects/logout/logout.cpp @@ -1,192 +1,195 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Lubos Lunak +Copyright (C) 2009 Martin Gräßlin Copyright (C) 2009 Lucas Murray This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "logout.h" #include "kwinglutils.h" #include namespace KWin { KWIN_EFFECT( logout, LogoutEffect ) LogoutEffect::LogoutEffect() - : progress( 0 ) - , logout_window( NULL ) + : progress( 0.0 ) + , logoutWindow( NULL ) + , logoutWindowClosed( true ) { char net_wm_cm_name[ 100 ]; sprintf( net_wm_cm_name, "_NET_WM_CM_S%d", DefaultScreen( display())); Atom net_wm_cm = XInternAtom( display(), net_wm_cm_name, False ); Window sel = XGetSelectionOwner( display(), net_wm_cm ); Atom hack = XInternAtom( display(), "_KWIN_LOGOUT_EFFECT", False ); XChangeProperty( display(), sel, hack, hack, 8, PropModeReplace, (unsigned char*)&hack, 1 ); // the atom is not removed when effect is destroyed, this is temporary anyway #ifdef KWIN_HAVE_OPENGL_COMPOSITING blurSupported = false; - - // If NPOT textures are not supported use the nearest power-of-two sized - // texture. It wastes memory, but it's possible to support systems without - // NPOT textures this way. - int texw = displayWidth(); - int texh = displayHeight(); - if( !GLTexture::NPOTTextureSupported() ) - { - kWarning( 1212 ) << "NPOT textures not supported, wasting some memory"; - texw = nearestPowerOfTwo( texw ); - texh = nearestPowerOfTwo( texh ); + if( effects->compositingType() == OpenGLCompositing && GLTexture::NPOTTextureSupported() ) + { // TODO: It seems that it is not possible to create a GLRenderTarget that has + // a different size than the display right now. Most likely a KWin core bug. + // Create texture and render target + blurTexture = new GLTexture( displayWidth(), displayHeight() ); + blurTexture->setFilter( GL_LINEAR_MIPMAP_LINEAR ); + blurTexture->setWrapMode( GL_CLAMP_TO_EDGE ); + + blurTarget = new GLRenderTarget( blurTexture ); + if( blurTarget->valid() ) + blurSupported = true; } - // Create texture and render target - blurTexture = new GLTexture( texw, texh ); - blurTexture->setFilter( GL_LINEAR_MIPMAP_LINEAR ); - blurTexture->setWrapMode( GL_CLAMP_TO_EDGE ); - - blurTarget = new GLRenderTarget( blurTexture ); - if( blurTarget->valid() ) - blurSupported = true; #endif } LogoutEffect::~LogoutEffect() { #ifdef KWIN_HAVE_OPENGL_COMPOSITING delete blurTexture; delete blurTarget; #endif } void LogoutEffect::prePaintScreen( ScreenPrePaintData& data, int time ) { - if( logout_window != NULL ) - progress = qBound( 0., progress + time / animationTime( 2000. ), 1. ); - else if( progress != 0 ) - progress = qBound( 0., progress - time / animationTime( 500. ), 1. ); + if( logoutWindow != NULL && !logoutWindowClosed ) + progress = qMin( 1.0, progress + time / animationTime( 2000.0 )); + else if( progress > 0.0 ) + progress = qMax( 0.0, progress - time / animationTime( 500.0 )); #ifdef KWIN_HAVE_OPENGL_COMPOSITING if( blurSupported && progress > 0.0 ) { data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; effects->pushRenderTarget( blurTarget ); } #endif effects->prePaintScreen( data, time ); } -void LogoutEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) - { -#ifdef KWIN_HAVE_OPENGL_COMPOSITING - if( blurSupported && progress > 0.0 && w == logout_window ) - w->disablePainting( EffectWindow::PAINT_DISABLED ); -#endif - effects->prePaintWindow( w, data, time ); - } - void LogoutEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) { - if( w != logout_window && progress != 0 ) + if( progress > 0.0 ) { - if( effects->saturationSupported() ) + if( w == logoutWindow ) { - data.saturation *= ( 1 - progress * 0.8 ); - data.brightness *= ( 1 - progress * 0.3 ); + windowOpacity = data.opacity; + data.opacity = 0.0; // Cheat, we need the opacity for later but don't want to blur it } - else // When saturation isn't supported then reduce brightness a bit more - { - data.brightness *= ( 1 - progress * 0.6 ); + else + { + if( effects->saturationSupported() ) + { + data.saturation *= ( 1.0 - progress * 0.8 ); + data.brightness *= ( 1.0 - progress * 0.3 ); + } + else // When saturation isn't supported then reduce brightness a bit more + data.brightness *= ( 1.0 - progress * 0.6 ); } } effects->paintWindow( w, mask, region, data ); } -void LogoutEffect::postPaintScreen() +void LogoutEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data ) { - if( progress != 0 && progress != 1 ) - effects->addRepaintFull(); - effects->postPaintScreen(); + effects->paintScreen( mask, region, data ); #ifdef KWIN_HAVE_OPENGL_COMPOSITING if( blurSupported && progress > 0.0 ) { assert( effects->popRenderTarget() == blurTarget ); // Render the blurred scene blurTexture->bind(); GLfloat bias[1]; glGetTexEnvfv( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, bias ); glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, progress * 2.75 ); - glBegin(GL_QUADS); + glBegin( GL_QUADS ); glTexCoord2f( 0.0, 0.0 ); glVertex2f( 0.0, displayHeight() ); glTexCoord2f( 1.0, 0.0 ); glVertex2f( displayWidth(), displayHeight() ); glTexCoord2f( 1.0, 1.0 ); glVertex2f( displayWidth(), 0.0 ); glTexCoord2f( 0.0, 1.0 ); glVertex2f( 0.0, 0.0 ); glEnd(); glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, bias[0] ); blurTexture->unbind(); // Render the logout window - if( logout_window ) + if( logoutWindow ) { - int mask = PAINT_WINDOW_OPAQUE; // TODO: Can we have a translucent logout window? - QRect region = infiniteRegion(); - WindowPaintData data( logout_window ); - effects->drawWindow( logout_window, mask, region, data ); + int winMask = logoutWindow->hasAlpha() ? PAINT_WINDOW_TRANSLUCENT : PAINT_WINDOW_OPAQUE; + WindowPaintData winData( logoutWindow ); + winData.opacity = windowOpacity; + effects->drawWindow( logoutWindow, winMask, region, winData ); } } #endif } +void LogoutEffect::postPaintScreen() + { + if( progress != 0.0 && progress != 1.0 ) + effects->addRepaintFull(); + effects->postPaintScreen(); + } + void LogoutEffect::windowAdded( EffectWindow* w ) { if( isLogoutDialog( w )) { - logout_window = w; - progress = 0; + logoutWindow = w; + logoutWindowClosed = false; // So we don't blur the window on close + progress = 0.0; effects->addRepaintFull(); } } void LogoutEffect::windowClosed( EffectWindow* w ) { - if( w == logout_window ) + if( w == logoutWindow ) { - logout_window = NULL; + logoutWindowClosed = true; effects->addRepaintFull(); } } +void LogoutEffect::windowDeleted( EffectWindow* w ) + { + if( w == logoutWindow ) + logoutWindow = NULL; + } + bool LogoutEffect::isLogoutDialog( EffectWindow* w ) { // TODO there should be probably a better way (window type?) if( w->windowClass() == "ksmserver ksmserver" && ( w->windowRole() == "logoutdialog" || w->windowRole() == "logouteffect" )) { return true; } return false; } } // namespace diff --git a/effects/logout/logout.desktop b/effects/logout/logout.desktop index 7162d837e..077be0aa0 100644 --- a/effects/logout/logout.desktop +++ b/effects/logout/logout.desktop @@ -1,134 +1,134 @@ [Desktop Entry] Name=Logout Name[af]=Afteken Name[ar]=اخرج Name[be]=Выйсці Name[be@latin]=Vychad Name[bg]=Изход Name[bn]=লগ-আউট Name[bn_IN]=লগ-আউট করুন Name[ca]=Sortida Name[ca@valencia]=Eixida Name[cs]=Odhlášení Name[csb]=Wëlogòwanié Name[da]=Log ud Name[de]=Abmeldung Name[el]=Αποσύνδεση Name[eo]=Elsaluto Name[es]=Cerrar la sesión Name[et]=Väljalogimine Name[eu]=Saioa amaitu Name[fi]=Uloskirjautuminen Name[fr]=Déconnexion Name[fy]=Utlogge Name[ga]=Logáil Amach Name[gl]=Saír Name[gu]=બહાર નીકળો Name[he]=התנתקות Name[hi]=लॉगआउट Name[hr]=Odjava Name[hsb]=Wotzjewjenje Name[hu]=Elrendezés Name[is]=Útskráning Name[it]=Termina sessione Name[ja]=ログアウト Name[kk]=Шығу Name[km]=ចេញ Name[kn]=ನಿರ್ಗಮಿಸು (ಲಾಗೌಟ್) Name[ko]=로그아웃 Name[ku]=Derketin Name[lt]=Atsijungti Name[lv]=Atteikties Name[mai]=लाग आउट Name[mk]=Одјавување Name[ml]=പുറത്തിറങ്ങുക Name[mr]=बाहेर पडा Name[nb]=Logg ut Name[nds]=Afmellen Name[ne]=लगआउट Name[nl]=Afmelden Name[nn]=Utlogging Name[oc]=Desconnexion Name[or]=ଲଗଆଉଟ Name[pa]=ਲਾਗਆਉਟ Name[pl]=Wylogowanie Name[pt]=Encerramento Name[pt_BR]=Encerramento de sessão Name[ro]=Ieșire Name[ru]=Завершение сеанса Name[se]=Olggosčáliheapmi Name[sk]=Odhlásenie Name[sl]=Odjava Name[sr]=Одјава Name[sr@latin]=Odjava Name[sv]=Utloggning Name[ta]=வெளிவருக Name[te]=లాగ్అవుట్ Name[tg]=Баромадан Name[th]=ออกจากระบบ Name[tr]=Çıkış Name[uk]=Вихід Name[uz]=Chiqish Name[uz@cyrillic]=Чиқиш Name[wa]=Dislodjaedje Name[x-test]=xxLogoutxx Name[zh_CN]=注销 Name[zh_TW]=登出 Icon=preferences-system-windows-effect-logout Comment=Desaturate the desktop when displaying the logout dialog Comment[ar]=إلغاء تشبع ألوان سطح المكتب عن ظهور حور الخروج Comment[bg]=Избледняване на работния плот при показване на прозореца за изход Comment[ca]=Reducció de la saturació de l'escriptori en mostar el diàleg de sortida Comment[ca@valencia]=Reducció de la saturació de l'escriptori en mostar el diàleg d'eixida Comment[da]=Afmæt farverne på desktoppen når log ud-dialogen vises Comment[de]=Färbt die Arbeitsfläche in Grautöne, wenn der Abmelde-Dialog erscheint. Comment[el]=Αποχρωματισμός της επιφάνειας εργασίας κατά την εμφάνιση του διαλόγου αποσύνδεσης Comment[es]=Desatura el escritorio cuando se finaliza la sesión Comment[et]=Töölaua värvide tuhmistamine väljalogimisdialoogi näitamisel Comment[fr]=Dé-sature le bureau lors de l'affichage de la fenêtre de déconnexion Comment[fy]=Fertsjusterje it buroblêd ûnder it werjaan fan it ôfmeldskerm Comment[gl]=Desatura o escritorio ao mostrar o diálogo de saída Comment[gu]=બહાર નીકળવાનો સંવાદ દર્શાવતી વખતે ડેસ્કટોપ ઝાંખું બનાવો Comment[he]=הפוך את שולחן העבודה לשחור־לבן בעת הצגת חלון סיום העבודה Comment[is]=Afmetta skjáborð þegar útstimplunarglugginn birtist Comment[it]=Desatura il desktop quando viene mostrata la finestra di dialogo per terminare la sessione Comment[ja]=ログアウトダイアログを表示するときにデスクトップを減色します Comment[kk]=Шығу диалогын көрсеткенде үстелді ертіп жіберу Comment[km]=ជ្រាប​ផ្ទៃតុ​នៅពេល​បង្ហាញ​ប្រអប់​ចេញ Comment[kn]=ಹೊರನಡೆಯುವಿಕೆ (ಲಾಗೌಟ್) ಸಂವಾದವನ್ನು ತೋರಿಸುವಾಗ ಗಣಕತೆರೆಯ ಶುಧ್ಧತ್ವವನ್ನು ಕುಂದಿಸು Comment[ko]=로그아웃 대화상자를 표시할 때 데스크톱을 흑백으로 전환시킵니다 Comment[lv]=Padarīt darbvirsmu pelēktoņu , parādot atteikšanās logu Comment[ml]=പുറത്തേക്ക് കടക്കാനുള്ള ഡയലോഗ് കാണിക്കുംബോള്‍ പണിയിടം ഡീ-സാചുറേറ്റ് ചെയ്യുക Comment[nb]=Blek ut skrivebordet når utloggingsdialogen vises Comment[nds]=De Sattheit vun de Schriefdischklören bi't Wiesen vun den Afmelldialoog daalsetten Comment[nl]=Verduistert het bureaublad tijdens het weergeven van de afmelddialoog Comment[pa]=ਜਦੋਂ ਲਾਗ-ਆਉਟ ਡਾਈਲਾਗ ਵੇਖਾਉਣਾ ਹੋਵੇ ਤਾਂ ਡੈਸਕਟਾਪ ਨੂੰ ਡਿ-ਸੈਚੂਰੇਟ ਕਰੋ Comment[pl]=Zmniejszenie nasycenia kolorów podczas pokazywania okna wylogowania Comment[pt]=Reduzir a saturação do ecrã ao mostrar a janela de fim de sessão Comment[pt_BR]=Reduz a saturação da área de trabalho ao mostrar o diálogo de logout Comment[ro]=Desaturează biroul la afișarea dialogului de ieșire Comment[sk]=Odfarbi plochu pri zobrazení odhlasovacieho dialógu Comment[sl]=Ob prikazu odjavnega okna se namizje razbarva Comment[sr]=Посивљује површ при појави одјавног дијалога Comment[sr@latin]=Posivljuje površ pri pojavi odjavnog dijaloga Comment[sv]=Försvaga färger på skrivbordet när utloggningsdialogrutan visas Comment[te]=లాగ్అవుట్ డైలాగ్‌ను ప్రదర్శిస్తున్నప్పుడు రంగస్థలమును డీసాట్యురేట్ చేయుము Comment[th]=ลดความอิ่มสีของพื้นที่ทำงาน เมื่อมีการแสดงกล่องออกจากระบบ Comment[tr]=Çıkış penceresi gösterilirken ekranı soldur Comment[uk]=Зменшення насиченості кольорів стільниці під час показу вікна виходу Comment[x-test]=xxDesaturate the desktop when displaying the logout dialogxx Comment[zh_CN]=显示注销对话框时降低桌面饱和度 Comment[zh_TW]=顯示登出視窗時將桌面淡化 Type=Service X-KDE-ServiceTypes=KWin/Effect -X-KDE-PluginInfo-Author=Lubos Lunak -X-KDE-PluginInfo-Email=l.lunak@kde.org +X-KDE-PluginInfo-Author=Lubos Lunak & Lucas Murray +X-KDE-PluginInfo-Email=l.lunak@kde.org & lmurray@undefinedfire.com X-KDE-PluginInfo-Name=kwin4_effect_logout -X-KDE-PluginInfo-Version=0.1.0 +X-KDE-PluginInfo-Version=0.2.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-KDE-Ordering=40 +X-KDE-Ordering=85 diff --git a/effects/logout/logout.h b/effects/logout/logout.h index d71b52980..2c5700bc4 100644 --- a/effects/logout/logout.h +++ b/effects/logout/logout.h @@ -1,60 +1,64 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Lubos Lunak +Copyright (C) 2009 Martin Gräßlin Copyright (C) 2009 Lucas Murray This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #ifndef KWIN_LOGOUT_H #define KWIN_LOGOUT_H #include namespace KWin { class GLRenderTarget; class GLTexture; class LogoutEffect : public Effect { public: LogoutEffect(); ~LogoutEffect(); virtual void prePaintScreen( ScreenPrePaintData& data, int time ); + virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); 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 ); + virtual void windowDeleted( EffectWindow* w ); private: bool isLogoutDialog( EffectWindow* w ); double progress; // 0-1 - EffectWindow* logout_window; + EffectWindow* logoutWindow; + bool logoutWindowClosed; #ifdef KWIN_HAVE_OPENGL_COMPOSITING bool blurSupported; GLTexture* blurTexture; GLRenderTarget* blurTarget; + double windowOpacity; #endif }; } // namespace #endif