From bb9ff25ec464bdfad918c15e649420ab88f544d7 Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Thu, 1 Nov 2007 17:47:41 +0000 Subject: [PATCH] Prevent multiple fullscreen effects from becoming active at the same time as discussed on kwin ml svn path=/trunk/KDE/kdebase/workspace/; revision=731717 --- effects.cpp | 15 +++++++++++++++ effects.h | 4 ++++ effects/desktopgrid.cpp | 6 ++++++ effects/presentwindows.cpp | 6 ++++++ lib/kwineffects.h | 3 +++ 5 files changed, 34 insertions(+) diff --git a/effects.cpp b/effects.cpp index 7ec7c56c33..14608bb571 100644 --- a/effects.cpp +++ b/effects.cpp @@ -39,6 +39,7 @@ namespace KWin EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type) : EffectsHandler(type) , keyboard_grab_effect( NULL ) + , fullscreen_effect( 0 ) { reconfigure(); } @@ -258,6 +259,16 @@ void EffectsHandlerImpl::tabBoxUpdated() ep.second->tabBoxUpdated(); } +void EffectsHandlerImpl::setActiveFullScreenEffect( Effect* e ) + { + fullscreen_effect = e; + } + +Effect* EffectsHandlerImpl::activeFullScreenEffect() const + { + return fullscreen_effect; + } + bool EffectsHandlerImpl::borderActivated( ElectricBorder border ) { bool ret = false; @@ -723,6 +734,10 @@ void EffectsHandlerImpl::unloadEffect( const QString& name ) if ( it.value().first == name ) { kDebug( 1212 ) << "EffectsHandler::unloadEffect : Unloading Effect : " << name; + if( activeFullScreenEffect() == it.value().second ) + { + setActiveFullScreenEffect( 0 ); + } delete it.value().second; effect_order.erase(it); effectsChanged(); diff --git a/effects.h b/effects.h index bd1e51e247..713d68bb19 100644 --- a/effects.h +++ b/effects.h @@ -66,6 +66,9 @@ class EffectsHandlerImpl : public EffectsHandler virtual int currentTabBoxDesktop() const; virtual EffectWindow* currentTabBoxWindow() const; + virtual void setActiveFullScreenEffect( Effect* e ); + virtual Effect* activeFullScreenEffect() const; + virtual void pushRenderTarget(GLRenderTarget* target); virtual GLRenderTarget* popRenderTarget(); @@ -125,6 +128,7 @@ class EffectsHandlerImpl : public EffectsHandler Effect* keyboard_grab_effect; QStack render_targets; + Effect* fullscreen_effect; ToplevelList elevated_windows; QMultiMap< int, EffectPair > effect_order; }; diff --git a/effects/desktopgrid.cpp b/effects/desktopgrid.cpp index a161b20ca3..aab3049991 100644 --- a/effects/desktopgrid.cpp +++ b/effects/desktopgrid.cpp @@ -350,6 +350,8 @@ EffectWindow* DesktopGridEffect::windowAt( const QPoint& pos, QRect* rect ) cons void DesktopGridEffect::desktopChanged( int old ) { + if( effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this ) + return; if( activated ) setActive( false ); else @@ -430,6 +432,8 @@ void DesktopGridEffect::toggle() void DesktopGridEffect::setActive( bool active ) { + if( effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this ) + return; if( activated == active ) return; activated = active; @@ -443,6 +447,7 @@ void DesktopGridEffect::setup() keyboard_grab = effects->grabKeyboard( this ); input = effects->createInputWindow( this, 0, 0, displayWidth(), displayHeight(), Qt::PointingHandCursor ); + effects->setActiveFullScreenEffect( this ); hover_desktop = effects->currentDesktop(); } @@ -455,6 +460,7 @@ void DesktopGridEffect::finish() effects->setElevatedWindow( window_move, false ); window_move = NULL; effects->destroyInputWindow( input ); + effects->setActiveFullScreenEffect( 0 ); effects->addRepaintFull(); // to get rid of hover } diff --git a/effects/presentwindows.cpp b/effects/presentwindows.cpp index 9cb3b9228c..1d608182b3 100644 --- a/effects/presentwindows.cpp +++ b/effects/presentwindows.cpp @@ -286,6 +286,8 @@ void PresentWindowsEffect::windowClosed( EffectWindow* w ) void PresentWindowsEffect::setActive(bool active) { + if( effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this ) + return; if( mActivated == active ) return; mActivated = active; @@ -326,6 +328,7 @@ void PresentWindowsEffect::effectActivated() // Create temporary input window to catch mouse events mInput = effects->createFullScreenInputWindow( this, Qt::PointingHandCursor ); hasKeyboardGrab = effects->grabKeyboard( this ); + effects->setActiveFullScreenEffect( this ); } void PresentWindowsEffect::effectTerminated() @@ -335,6 +338,7 @@ void PresentWindowsEffect::effectTerminated() if( hasKeyboardGrab ) effects->ungrabKeyboard(); hasKeyboardGrab = false; + effects->setActiveFullScreenEffect( 0 ); } void PresentWindowsEffect::rearrangeWindows() @@ -731,6 +735,8 @@ bool PresentWindowsEffect::canRearrangeClosest(EffectWindowList windowlist) bool PresentWindowsEffect::borderActivated( ElectricBorder border ) { + if( effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this ) + return false; if( border == borderActivate && !mActivated ) { toggleActive(); diff --git a/lib/kwineffects.h b/lib/kwineffects.h index 949ef10101..41c5a89a92 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -229,6 +229,9 @@ class KWIN_EXPORT EffectsHandler virtual int currentTabBoxDesktop() const = 0; virtual EffectWindow* currentTabBoxWindow() const = 0; + virtual void setActiveFullScreenEffect( Effect* e ) = 0; + virtual Effect* activeFullScreenEffect() const = 0; + virtual void pushRenderTarget(GLRenderTarget* target) = 0; virtual GLRenderTarget* popRenderTarget() = 0;