diff --git a/effects.cpp b/effects.cpp index c6873b27fa..753c7f87d3 100644 --- a/effects.cpp +++ b/effects.cpp @@ -560,8 +560,28 @@ KLibrary* EffectsHandlerImpl::findEffectLibrary( const QString& effectname ) return library; } +void EffectsHandlerImpl::toggleEffect( const QString& name ) + { + assert( current_paint_screen == 0 ); + assert( current_paint_window == 0 ); + assert( current_draw_window == 0 ); + assert( current_transform == 0 ); + + // Make sure a single effect won't be loaded multiple times + for(QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); it++) + { + if( (*it).first == name ) + { + unloadEffect( name ); + return; + } + } + loadEffect( name ); + } + void EffectsHandlerImpl::loadEffect( const QString& name ) { + Workspace::self()->addRepaintFull(); assert( current_paint_screen == 0 ); assert( current_paint_window == 0 ); assert( current_draw_window == 0 ); @@ -617,6 +637,7 @@ void EffectsHandlerImpl::loadEffect( const QString& name ) void EffectsHandlerImpl::unloadEffect( const QString& name ) { + Workspace::self()->addRepaintFull(); assert( current_paint_screen == 0 ); assert( current_paint_window == 0 ); assert( current_draw_window == 0 ); diff --git a/effects.h b/effects.h index 51aec7659c..b5ecdedf72 100644 --- a/effects.h +++ b/effects.h @@ -101,6 +101,7 @@ class EffectsHandlerImpl : public EffectsHandler bool hasKeyboardGrab() const; void loadEffect( const QString& name ); + void toggleEffect( const QString& name ); void unloadEffect( const QString& name ); protected: diff --git a/org.kde.KWin.xml b/org.kde.KWin.xml index dc4d4a6029..c86ce6fbee 100644 --- a/org.kde.KWin.xml +++ b/org.kde.KWin.xml @@ -1,7 +1,7 @@ - + @@ -23,6 +23,11 @@ + + + + + @@ -33,6 +38,14 @@ - + + + + + + + + + diff --git a/useractions.cpp b/useractions.cpp index 4b98b4c4fb..de50bc27f4 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -700,6 +700,12 @@ void Workspace::loadEffect( const QString& name ) static_cast(effects)->loadEffect( name ); } +void Workspace::toggleEffect( const QString& name ) + { + if( effects ) + static_cast(effects)->toggleEffect( name ); + } + void Workspace::unloadEffect( const QString& name ) { if( effects ) diff --git a/workspace.h b/workspace.h index 9047ce7a8c..5f5d3c46f3 100644 --- a/workspace.h +++ b/workspace.h @@ -210,6 +210,7 @@ class Workspace : public QObject, public KDecorationDefines void showWindowMenuAt( unsigned long id, int x, int y ); void loadEffect( const QString& name ); + void toggleEffect( const QString& name ); void unloadEffect( const QString& name );