diff --git a/effects.cpp b/effects.cpp index c4bc449ba3..369ac492f0 100644 --- a/effects.cpp +++ b/effects.cpp @@ -85,14 +85,21 @@ void EffectsHandlerImpl::reconfigure() if( shouldbeloaded ) effectsToBeLoaded.append( plugininfo.pluginName() ); } + QStringList newLoaded; // Then load those that should be loaded foreach( const QString &effectName, effectsToBeLoaded ) { if( !isEffectLoaded( effectName )) { loadEffect( effectName ); + newLoaded.append( effectName ); } } + foreach( const EffectPair &ep, loaded_effects ) + { + if( !newLoaded.contains( ep.first )) // don't reconfigure newly loaded effects + ep.second->reconfigure( Effect::ReconfigureAll ); + } } // the idea is that effects call this function again which calls the next one @@ -887,13 +894,14 @@ void EffectsHandlerImpl::unloadEffect( const QString& name ) kDebug( 1212 ) << "EffectsHandler::unloadEffect : Effect not loaded : " << name; } -void EffectsHandlerImpl::reloadEffect( const QString& name ) +void EffectsHandlerImpl::reconfigureEffect( const QString& name ) { - if( isEffectLoaded( name )) - { - unloadEffect( name ); - loadEffect( name ); - } + for( QVector< EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it) + if ( (*it).first == name ) + { + (*it).second->reconfigure( Effect::ReconfigureAll ); + return; + } } bool EffectsHandlerImpl::isEffectLoaded( const QString& name ) diff --git a/effects.h b/effects.h index bf2762725a..e6f9cd8bdc 100644 --- a/effects.h +++ b/effects.h @@ -143,7 +143,7 @@ class EffectsHandlerImpl : public EffectsHandler bool loadEffect( const QString& name ); void toggleEffect( const QString& name ); void unloadEffect( const QString& name ); - void reloadEffect( const QString& name ); + void reconfigureEffect( const QString& name ); bool isEffectLoaded( const QString& name ); QStringList loadedEffects() const; QStringList listOfEffects() const; diff --git a/effects/boxswitch.cpp b/effects/boxswitch.cpp index 559ffc12cd..7162c73e29 100644 --- a/effects/boxswitch.cpp +++ b/effects/boxswitch.cpp @@ -51,6 +51,15 @@ BoxSwitchEffect::BoxSwitchEffect() frame_margin = 10; highlight_margin = 5; + reconfigure( ReconfigureAll ); + } + +BoxSwitchEffect::~BoxSwitchEffect() + { + } + +void BoxSwitchEffect::reconfigure( ReconfigureFlags ) + { color_frame = KColorScheme( QPalette::Active, KColorScheme::Window ).background().color(); color_frame.setAlphaF( 0.9 ); color_highlight = KColorScheme( QPalette::Active, KColorScheme::Selection ).background().color(); @@ -58,10 +67,6 @@ BoxSwitchEffect::BoxSwitchEffect() color_text = KColorScheme( QPalette::Active, KColorScheme::Window ).foreground().color(); } -BoxSwitchEffect::~BoxSwitchEffect() - { - } - void BoxSwitchEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) { if( mActivated ) diff --git a/effects/boxswitch.h b/effects/boxswitch.h index bc3f7bd85a..0d2b297258 100644 --- a/effects/boxswitch.h +++ b/effects/boxswitch.h @@ -42,7 +42,8 @@ class BoxSwitchEffect public: BoxSwitchEffect(); ~BoxSwitchEffect(); - + + virtual void reconfigure( ReconfigureFlags ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); diff --git a/effects/coverswitch.cpp b/effects/coverswitch.cpp index b5344ad1aa..f585335745 100644 --- a/effects/coverswitch.cpp +++ b/effects/coverswitch.cpp @@ -50,6 +50,15 @@ CoverSwitchEffect::CoverSwitchEffect() , stopRequested( false ) , startRequested( false ) , twinview( false ) + { + reconfigure( ReconfigureAll ); + } + +CoverSwitchEffect::~CoverSwitchEffect() + { + } + +void CoverSwitchEffect::reconfigure( ReconfigureFlags ) { KConfigGroup conf = effects->effectConfig( "CoverSwitch" ); animationDuration = animationTime( conf, "Duration", 200 ); @@ -61,10 +70,6 @@ CoverSwitchEffect::CoverSwitchEffect() timeLine.setDuration( animationDuration ); } -CoverSwitchEffect::~CoverSwitchEffect() - { - } - void CoverSwitchEffect::prePaintScreen( ScreenPrePaintData& data, int time ) { if( mActivated || stop || stopRequested ) diff --git a/effects/coverswitch.h b/effects/coverswitch.h index fc650f311a..296035d98c 100644 --- a/effects/coverswitch.h +++ b/effects/coverswitch.h @@ -33,6 +33,7 @@ class CoverSwitchEffect CoverSwitchEffect(); ~CoverSwitchEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void postPaintScreen(); diff --git a/effects/cube.cpp b/effects/cube.cpp index 575999f72e..cec7443e9e 100644 --- a/effects/cube.cpp +++ b/effects/cube.cpp @@ -48,6 +48,7 @@ CubeEffect::CubeEffect() , cube_painting( false ) , keyboard_grab( false ) , schedule_close( false ) + , borderActivate( ElectricNone ) , frontDesktop( 0 ) , cubeOpacity( 1.0 ) , displayDesktopName( true ) @@ -81,7 +82,7 @@ CubeEffect::CubeEffect() , capListCreated( false ) , capList( 0 ) { - loadConfig( "Cube" ); + reconfigure( ReconfigureAll ); KActionCollection* actionCollection = new KActionCollection( this ); KAction* a = static_cast< KAction* >( actionCollection->addAction( "Cube" )); @@ -90,9 +91,15 @@ CubeEffect::CubeEffect() connect( a, SIGNAL( triggered( bool )), this, SLOT( toggle())); } +void CubeEffect::reconfigure( ReconfigureFlags ) + { + loadConfig( "Cube" ); + } + void CubeEffect::loadConfig( QString config ) { KConfigGroup conf = effects->effectConfig( config ); + effects->unreserveElectricBorder( borderActivate ); borderActivate = (ElectricBorder)conf.readEntry( "BorderActivate", (int)ElectricNone ); effects->reserveElectricBorder( borderActivate ); @@ -109,6 +116,8 @@ void CubeEffect::loadConfig( QString config ) zPosition = conf.readEntry( "ZPosition", 100.0 ); useForTabBox = conf.readEntry( "TabBox", false ); QString file = conf.readEntry( "Wallpaper", QString("") ); + delete wallpaper; + wallpaper = NULL; if( !file.isEmpty() ) { QImage img = QImage( file ); @@ -117,6 +126,8 @@ void CubeEffect::loadConfig( QString config ) wallpaper = new GLTexture( img ); } } + delete capTexture; + capTexture = NULL; texturedCaps = conf.readEntry( "TexturedCaps", true ); if( texturedCaps ) { diff --git a/effects/cube.h b/effects/cube.h index 31da59e1c7..f860fa97e2 100644 --- a/effects/cube.h +++ b/effects/cube.h @@ -36,6 +36,7 @@ class CubeEffect public: CubeEffect(); ~CubeEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void postPaintScreen(); diff --git a/effects/cylinder.cpp b/effects/cylinder.cpp index e1542bab3d..0ad5d0c324 100644 --- a/effects/cylinder.cpp +++ b/effects/cylinder.cpp @@ -41,9 +41,7 @@ CylinderEffect::CylinderEffect() { if( wallpaper ) wallpaper->discard(); - loadConfig( "Cylinder" ); - animateDesktopChange = false; - bigCube = true; + reconfigure( ReconfigureAll ); } CylinderEffect::~CylinderEffect() @@ -51,6 +49,13 @@ CylinderEffect::~CylinderEffect() delete mShader; } +void CylinderEffect::reconfigure( ReconfigureFlags ) + { + loadConfig( "Cylinder" ); + animateDesktopChange = false; + bigCube = true; + } + bool CylinderEffect::supported() { return GLRenderTarget::supported() && diff --git a/effects/cylinder.h b/effects/cylinder.h index a02b390ffa..372671fe5e 100644 --- a/effects/cylinder.h +++ b/effects/cylinder.h @@ -33,6 +33,7 @@ class CylinderEffect public: CylinderEffect(); ~CylinderEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void desktopChanged( int old ); diff --git a/effects/desktopgrid.cpp b/effects/desktopgrid.cpp index f53798f20f..478c6b68d9 100644 --- a/effects/desktopgrid.cpp +++ b/effects/desktopgrid.cpp @@ -25,6 +25,7 @@ along with this program. If not, see . #include #include +#include #include #include #include @@ -37,7 +38,8 @@ namespace KWin KWIN_EFFECT( desktopgrid, DesktopGridEffect ) DesktopGridEffect::DesktopGridEffect() - : activated( false ) + : borderActivate( ElectricNone ) + , activated( false ) , timeline() , keyboardGrab( false ) , wasWindowMove( false ) @@ -59,9 +61,19 @@ DesktopGridEffect::DesktopGridEffect() connect( a, SIGNAL( triggered( bool )), this, SLOT( toggle() )); // Load all other configuration details + reconfigure( ReconfigureAll ); + } +DesktopGridEffect::~DesktopGridEffect() + { + effects->unreserveElectricBorder( borderActivate ); + } + +void DesktopGridEffect::reconfigure( ReconfigureFlags ) + { KConfigGroup conf = effects->effectConfig( "DesktopGrid" ); + effects->unreserveElectricBorder( borderActivate ); borderActivate = ElectricBorder( conf.readEntry( "BorderActivate", int( ElectricNone ))); effects->reserveElectricBorder( borderActivate ); @@ -75,11 +87,6 @@ DesktopGridEffect::DesktopGridEffect() customLayoutRows = conf.readEntry( "CustomLayoutRows", 2 ); } -DesktopGridEffect::~DesktopGridEffect() - { - effects->unreserveElectricBorder( borderActivate ); - } - //----------------------------------------------------------------------------- // Screen painting diff --git a/effects/desktopgrid.h b/effects/desktopgrid.h index 215bf82ae1..10a6645569 100644 --- a/effects/desktopgrid.h +++ b/effects/desktopgrid.h @@ -35,6 +35,7 @@ class DesktopGridEffect public: DesktopGridEffect(); ~DesktopGridEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void postPaintScreen(); diff --git a/effects/diminactive.cpp b/effects/diminactive.cpp index 149e6a56fc..22fc3d4d10 100644 --- a/effects/diminactive.cpp +++ b/effects/diminactive.cpp @@ -30,13 +30,17 @@ KWIN_EFFECT( diminactive, DimInactiveEffect ) DimInactiveEffect::DimInactiveEffect() { - KConfigGroup conf = EffectsHandler::effectConfig("DimInactive"); + reconfigure( ReconfigureAll ); + active = effects->activeWindow(); + } +void DimInactiveEffect::reconfigure( ReconfigureFlags ) + { + KConfigGroup conf = EffectsHandler::effectConfig("DimInactive"); dim_panels = conf.readEntry("DimPanels", false); dim_desktop = conf.readEntry("DimDesktop", false); dim_by_group = conf.readEntry("DimByGroup", true); dim_strength = conf.readEntry("Strength", 25); - active = effects->activeWindow(); } void DimInactiveEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) diff --git a/effects/diminactive.h b/effects/diminactive.h index 74fecc37cd..1c58b86bd1 100644 --- a/effects/diminactive.h +++ b/effects/diminactive.h @@ -34,6 +34,7 @@ class DimInactiveEffect { public: DimInactiveEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void windowActivated( EffectWindow* c ); private: diff --git a/effects/dimscreen.cpp b/effects/dimscreen.cpp index 417f10d3ec..01ee18d921 100644 --- a/effects/dimscreen.cpp +++ b/effects/dimscreen.cpp @@ -32,10 +32,10 @@ KWIN_EFFECT( dimscreen, DimScreenEffect ) DimScreenEffect::DimScreenEffect() : mActivated( false ) - , animationDuration( Effect::animationTime( 300 )) , animation( false ) , deactivate( false ) { + reconfigure( ReconfigureAll ); #ifdef KWIN_HAVE_XRENDER_COMPOSITING alphaFormat = XRenderFindStandardFormat( display(), PictStandardARGB32 ); #endif @@ -45,6 +45,11 @@ DimScreenEffect::~DimScreenEffect() { } +void DimScreenEffect::reconfigure( ReconfigureFlags ) + { + animationDuration = Effect::animationTime( 300 ); + } + void DimScreenEffect::prePaintScreen( ScreenPrePaintData& data, int time ) { effects->prePaintScreen( data, time ); diff --git a/effects/dimscreen.h b/effects/dimscreen.h index f952e325d6..d5f7de1f43 100644 --- a/effects/dimscreen.h +++ b/effects/dimscreen.h @@ -39,6 +39,7 @@ class DimScreenEffect DimScreenEffect(); ~DimScreenEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void postPaintScreen(); diff --git a/effects/fade.cpp b/effects/fade.cpp index 0c21472728..370b3f71e0 100644 --- a/effects/fade.cpp +++ b/effects/fade.cpp @@ -28,6 +28,11 @@ namespace KWin KWIN_EFFECT( fade, FadeEffect ) FadeEffect::FadeEffect() + { + reconfigure( ReconfigureAll ); + } + +void FadeEffect::reconfigure( ReconfigureFlags ) { KConfigGroup conf = effects->effectConfig( "Fade" ); fadeInTime = animationTime( conf, "FadeInTime", 150 ); diff --git a/effects/fade.h b/effects/fade.h index adad3d0e99..48b100e638 100644 --- a/effects/fade.h +++ b/effects/fade.h @@ -31,6 +31,7 @@ class FadeEffect { public: FadeEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); diff --git a/effects/flipswitch.cpp b/effects/flipswitch.cpp index 1a7c86118b..06b41c82c6 100644 --- a/effects/flipswitch.cpp +++ b/effects/flipswitch.cpp @@ -47,6 +47,15 @@ FlipSwitchEffect::FlipSwitchEffect() , stopRequested( false ) , startRequested( false ) , twinview( false ) + { + reconfigure( ReconfigureAll ); + } + +FlipSwitchEffect::~FlipSwitchEffect() + { + } + +void FlipSwitchEffect::reconfigure( ReconfigureFlags ) { KConfigGroup conf = effects->effectConfig( "FlipSwitch" ); mFlipDuration = animationTime( conf, "FlipDuration", 200 ); @@ -55,10 +64,6 @@ FlipSwitchEffect::FlipSwitchEffect() timeLine.setDuration( mFlipDuration ); } -FlipSwitchEffect::~FlipSwitchEffect() - { - } - void FlipSwitchEffect::prePaintScreen( ScreenPrePaintData& data, int time ) { if( mActivated || stopRequested || stop ) diff --git a/effects/flipswitch.h b/effects/flipswitch.h index da24989c5d..e2b6b665e7 100644 --- a/effects/flipswitch.h +++ b/effects/flipswitch.h @@ -33,6 +33,7 @@ class FlipSwitchEffect FlipSwitchEffect(); ~FlipSwitchEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void postPaintScreen(); diff --git a/effects/lookingglass.cpp b/effects/lookingglass.cpp index 17f2b3c382..0e46dd47b7 100644 --- a/effects/lookingglass.cpp +++ b/effects/lookingglass.cpp @@ -43,7 +43,6 @@ LookingGlassEffect::LookingGlassEffect() : QObject(), ShaderEffect("lookingglass zoom = 1.0f; target_zoom = 1.0f; - KConfigGroup conf = EffectsHandler::effectConfig("LookingGlass"); actionCollection = new KActionCollection( this ); actionCollection->setConfigGlobal(true); actionCollection->setConfigGroup("LookingGlass"); @@ -55,18 +54,22 @@ LookingGlassEffect::LookingGlassEffect() : QObject(), ShaderEffect("lookingglass a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Minus)); a = static_cast< KAction* >( actionCollection->addAction( KStandardAction::ActualSize, this, SLOT( toggle()))); a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0)); - initialradius = conf.readEntry("Radius", 200); - radius = initialradius; - - kDebug(1212) << QString("Radius from config: %1").arg(radius) << endl; - - actionCollection->readSettings(); + reconfigure( ReconfigureAll ); } LookingGlassEffect::~LookingGlassEffect() { } +void LookingGlassEffect::reconfigure( ReconfigureFlags ) + { + KConfigGroup conf = EffectsHandler::effectConfig("LookingGlass"); + initialradius = conf.readEntry("Radius", 200); + radius = initialradius; + kDebug(1212) << QString("Radius from config: %1").arg(radius) << endl; + actionCollection->readSettings(); + } + void LookingGlassEffect::toggle() { if( target_zoom == 1.0f ) diff --git a/effects/lookingglass.h b/effects/lookingglass.h index 5c098ce3a2..367d59fbdc 100644 --- a/effects/lookingglass.h +++ b/effects/lookingglass.h @@ -39,6 +39,7 @@ class LookingGlassEffect : public QObject, public ShaderEffect LookingGlassEffect(); virtual ~LookingGlassEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void mouseChanged( const QPoint& pos, const QPoint& old, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers ); diff --git a/effects/magnifier.cpp b/effects/magnifier.cpp index 586966a9a6..0bc65c6694 100644 --- a/effects/magnifier.cpp +++ b/effects/magnifier.cpp @@ -43,8 +43,6 @@ MagnifierEffect::MagnifierEffect() : zoom( 1 ) , target_zoom( 1 ) { - KConfigGroup conf = EffectsHandler::effectConfig("Magnifier"); - KActionCollection* actionCollection = new KActionCollection( this ); KAction* a; a = static_cast< KAction* >( actionCollection->addAction( KStandardAction::ZoomIn, this, SLOT( zoomIn()))); @@ -53,7 +51,12 @@ MagnifierEffect::MagnifierEffect() a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Minus)); a = static_cast< KAction* >( actionCollection->addAction( KStandardAction::ActualSize, this, SLOT( toggle()))); a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0)); + reconfigure( ReconfigureAll ); + } +void MagnifierEffect::reconfigure( ReconfigureFlags ) + { + KConfigGroup conf = EffectsHandler::effectConfig("Magnifier"); int width, height; width = conf.readEntry("Width", 200); height = conf.readEntry("Height", 200); diff --git a/effects/magnifier.h b/effects/magnifier.h index c78b8cff2e..45d467a022 100644 --- a/effects/magnifier.h +++ b/effects/magnifier.h @@ -32,6 +32,7 @@ class MagnifierEffect Q_OBJECT public: MagnifierEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void postPaintScreen(); diff --git a/effects/maketransparent.cpp b/effects/maketransparent.cpp index 3d3d0506dd..68e219c6c6 100644 --- a/effects/maketransparent.cpp +++ b/effects/maketransparent.cpp @@ -31,6 +31,12 @@ MakeTransparentEffect::MakeTransparentEffect() : fadeout( NULL ) , current( NULL ) , previous( NULL ) + { + reconfigure( ReconfigureAll ); + active = effects->activeWindow(); + } + +void MakeTransparentEffect::reconfigure( ReconfigureFlags ) { KConfigGroup conf = effects->effectConfig("MakeTransparent"); decoration = conf.readEntry( "Decoration", 1.0 ); @@ -52,7 +58,6 @@ MakeTransparentEffect::MakeTransparentEffect() popupmenus = menus; tornoffmenus = menus; } - active = effects->activeWindow(); moveresize_timeline.setCurveShape( TimeLine::EaseOutCurve ); moveresize_timeline.setDuration( animationTime( conf, "Duration", 800 ) ); activeinactive_timeline.setCurveShape( TimeLine::EaseInOutCurve ); diff --git a/effects/maketransparent.h b/effects/maketransparent.h index d6ad64bb94..d57571fbeb 100644 --- a/effects/maketransparent.h +++ b/effects/maketransparent.h @@ -31,6 +31,7 @@ class MakeTransparentEffect { public: MakeTransparentEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last ); virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); diff --git a/effects/mousemark.cpp b/effects/mousemark.cpp index 39542343f9..93ba41cb06 100644 --- a/effects/mousemark.cpp +++ b/effects/mousemark.cpp @@ -56,12 +56,15 @@ MouseMarkEffect::MouseMarkEffect() a->setText( i18n( "Clear Last Mouse Mark" )); a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F12 )); connect( a, SIGNAL( triggered( bool )), this, SLOT( clearLast())); + reconfigure( ReconfigureAll ); + arrow_start = NULL_POINT; + } +void MouseMarkEffect::reconfigure( ReconfigureFlags ) + { KConfigGroup conf = EffectsHandler::effectConfig("MouseMark"); width = conf.readEntry( "LineWidth", 3 ); color = conf.readEntry( "Color", QColor( Qt::red )); - - arrow_start = NULL_POINT; } void MouseMarkEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data ) diff --git a/effects/mousemark.h b/effects/mousemark.h index 0aaa3ac195..217aa61262 100644 --- a/effects/mousemark.h +++ b/effects/mousemark.h @@ -33,6 +33,7 @@ class MouseMarkEffect Q_OBJECT public: MouseMarkEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void mouseChanged( const QPoint& pos, const QPoint& old, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, diff --git a/effects/presentwindows.cpp b/effects/presentwindows.cpp index ba6ce7c734..3360650bcf 100644 --- a/effects/presentwindows.cpp +++ b/effects/presentwindows.cpp @@ -41,7 +41,9 @@ namespace KWin KWIN_EFFECT( presentwindows, PresentWindowsEffect ) PresentWindowsEffect::PresentWindowsEffect() - : m_activated( false ) + : m_borderActivate( ElectricNone ) + , m_borderActivateAll( ElectricNone ) + , m_activated( false ) , m_allDesktops( false ) , m_decalOpacity( 0.0 ) //, m_input() @@ -58,8 +60,6 @@ PresentWindowsEffect::PresentWindowsEffect() //, m_filterFrameRect() #endif { - KConfigGroup conf = effects->effectConfig("PresentWindows"); - KActionCollection* actionCollection = new KActionCollection( this ); KAction* a = ( KAction* )actionCollection->addAction( "Expose" ); a->setText( i18n( "Toggle Present Windows (Current desktop)" )); @@ -69,20 +69,7 @@ PresentWindowsEffect::PresentWindowsEffect() b->setText( i18n( "Toggle Present Windows (All desktops)" )); b->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F10 )); connect( b, SIGNAL( triggered(bool) ), this, SLOT( toggleActiveAllDesktops() )); - - m_borderActivate = ElectricBorder( conf.readEntry( "BorderActivate", int( ElectricNone ))); - m_borderActivateAll = ElectricBorder( conf.readEntry( "BorderActivateAll", int( ElectricTopLeft ))); - m_layoutMode = conf.readEntry( "LayoutMode", int( LayoutNatural )); - m_showCaptions = conf.readEntry( "DrawWindowCaptions", true ); - m_showIcons = conf.readEntry( "DrawWindowIcons", true ); - m_tabBoxAllowed = conf.readEntry( "TabBox", false ); - m_accuracy = conf.readEntry( "Accuracy", 1 ) * 20; - m_fillGaps = conf.readEntry( "FillGaps", true ); - - m_fadeDuration = double( animationTime( 150 )); - - effects->reserveElectricBorder( m_borderActivate ); - effects->reserveElectricBorder( m_borderActivateAll ); + reconfigure( ReconfigureAll ); } PresentWindowsEffect::~PresentWindowsEffect() @@ -92,6 +79,24 @@ PresentWindowsEffect::~PresentWindowsEffect() discardFilterTexture(); } +void PresentWindowsEffect::reconfigure( ReconfigureFlags ) + { + KConfigGroup conf = effects->effectConfig("PresentWindows"); + effects->unreserveElectricBorder( m_borderActivate ); + effects->unreserveElectricBorder( m_borderActivateAll ); + m_borderActivate = ElectricBorder( conf.readEntry( "BorderActivate", int( ElectricNone ))); + m_borderActivateAll = ElectricBorder( conf.readEntry( "BorderActivateAll", int( ElectricTopLeft ))); + effects->reserveElectricBorder( m_borderActivate ); + effects->reserveElectricBorder( m_borderActivateAll ); + m_layoutMode = conf.readEntry( "LayoutMode", int( LayoutNatural )); + m_showCaptions = conf.readEntry( "DrawWindowCaptions", true ); + m_showIcons = conf.readEntry( "DrawWindowIcons", true ); + m_tabBoxAllowed = conf.readEntry( "TabBox", false ); + m_accuracy = conf.readEntry( "Accuracy", 1 ) * 20; + m_fillGaps = conf.readEntry( "FillGaps", true ); + m_fadeDuration = double( animationTime( 150 )); + } + //----------------------------------------------------------------------------- // Screen painting diff --git a/effects/presentwindows.h b/effects/presentwindows.h index ac10faad4d..831796144e 100644 --- a/effects/presentwindows.h +++ b/effects/presentwindows.h @@ -68,6 +68,7 @@ class PresentWindowsEffect PresentWindowsEffect(); virtual ~PresentWindowsEffect(); + virtual void reconfigure( ReconfigureFlags ); // Screen painting virtual void prePaintScreen( ScreenPrePaintData &data, int time ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData &data ); diff --git a/effects/shadow.cpp b/effects/shadow.cpp index aa13ebb3c9..a538e5fd06 100644 --- a/effects/shadow.cpp +++ b/effects/shadow.cpp @@ -77,6 +77,30 @@ ShadowTiles::ShadowTiles(const QPixmap& shadow) #endif ShadowEffect::ShadowEffect() + : shadowSize( 0 ) +#ifdef KWIN_HAVE_OPENGL_COMPOSITING + , mShadowTexture( NULL ) +#endif +#ifdef KWIN_HAVE_XRENDER_COMPOSITING + , mShadowPics( NULL ) +#endif + { + reconfigure( ReconfigureAll ); + connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), + this, SLOT(updateShadowColor())); + } + +ShadowEffect::~ShadowEffect() + { +#ifdef KWIN_HAVE_OPENGL_COMPOSITING + delete mShadowTexture; +#endif +#ifdef KWIN_HAVE_XRENDER_COMPOSITING + delete mShadowPics; +#endif + } + +void ShadowEffect::reconfigure( ReconfigureFlags ) { KConfigGroup conf = effects->effectConfig("Shadow"); shadowXOffset = conf.readEntry( "XOffset", 0 ); @@ -86,15 +110,17 @@ ShadowEffect::ShadowEffect() shadowSize = conf.readEntry( "Size", 5 ); intensifyActiveShadow = conf.readEntry( "IntensifyActiveShadow", true ); #ifdef KWIN_HAVE_OPENGL_COMPOSITING + delete mShadowTexture; + mShadowTexture = NULL; if ( effects->compositingType() == OpenGLCompositing) { QString shadowtexture = KGlobal::dirs()->findResource("data", "kwin/shadow-texture.png"); mShadowTexture = new GLTexture(shadowtexture); } - else - mShadowTexture = NULL; #endif #ifdef KWIN_HAVE_XRENDER_COMPOSITING + delete mShadowPics; + mShadowPics = NULL; if ( effects->compositingType() == XRenderCompositing) { qreal size = 2*(shadowFuzzyness+shadowSize)+1; @@ -116,23 +142,8 @@ ShadowEffect::ShadowEffect() mShadowPics = new ShadowTiles(*shadow); delete shadow; } - else - mShadowPics = NULL; #endif - updateShadowColor(); - connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), - this, SLOT(updateShadowColor())); - } - -ShadowEffect::~ShadowEffect() - { -#ifdef KWIN_HAVE_OPENGL_COMPOSITING - delete mShadowTexture; -#endif -#ifdef KWIN_HAVE_XRENDER_COMPOSITING - delete mShadowPics; -#endif } void ShadowEffect::updateShadowColor() diff --git a/effects/shadow.h b/effects/shadow.h index 3cdda93a12..feeee48617 100644 --- a/effects/shadow.h +++ b/effects/shadow.h @@ -48,6 +48,7 @@ class ShadowEffect public: ShadowEffect(); virtual ~ShadowEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void drawWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); diff --git a/effects/showfps.cpp b/effects/showfps.cpp index b5c92be568..79f9f38787 100644 --- a/effects/showfps.cpp +++ b/effects/showfps.cpp @@ -65,6 +65,11 @@ ShowFpsEffect::ShowFpsEffect() i < MAX_FPS; ++i ) frames[ i ] = 0; + reconfigure( ReconfigureAll ); + } + +void ShowFpsEffect::reconfigure( ReconfigureFlags ) + { KConfigGroup config( KGlobal::config(), "EffectShowFps" ); alpha = config.readEntry( "Alpha", 0.5 ); x = config.readEntry( "X", -10000 ); diff --git a/effects/showfps.h b/effects/showfps.h index 40da6449b7..e67bb32a58 100644 --- a/effects/showfps.h +++ b/effects/showfps.h @@ -34,6 +34,7 @@ class ShowFpsEffect { public: ShowFpsEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); diff --git a/effects/snow.cpp b/effects/snow.cpp index 8efe401f90..c72692b7b1 100644 --- a/effects/snow.cpp +++ b/effects/snow.cpp @@ -53,16 +53,12 @@ SnowEffect::SnowEffect() srandom( std::time( NULL ) ); lastFlakeTime = QTime::currentTime(); nextFlakeMillis = 0; - KConfigGroup conf = effects->effectConfig("Snow"); - mNumberFlakes = conf.readEntry("Number", 50); - mMinFlakeSize = conf.readEntry("MinFlakes", 10); - mMaxFlakeSize = conf.readEntry("MaxFlakes", 50); - KActionCollection* actionCollection = new KActionCollection( this ); KAction* a = static_cast< KAction* >( actionCollection->addAction( "Snow" )); a->setText( i18n("Snow" )); a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::META + Qt::Key_F12 )); connect( a, SIGNAL( triggered( bool )), this, SLOT( toggle())); + reconfigure( ReconfigureAll ); } SnowEffect::~SnowEffect() @@ -71,6 +67,14 @@ SnowEffect::~SnowEffect() delete flakes; } +void SnowEffect::reconfigure( ReconfigureFlags ) + { + KConfigGroup conf = effects->effectConfig("Snow"); + mNumberFlakes = conf.readEntry("Number", 50); + mMinFlakeSize = conf.readEntry("MinFlakes", 10); + mMaxFlakeSize = conf.readEntry("MaxFlakes", 50); + } + void SnowEffect::prePaintScreen( ScreenPrePaintData& data, int time ) { if ( active ) diff --git a/effects/snow.h b/effects/snow.h index 6913ae0c93..bff35e1b74 100644 --- a/effects/snow.h +++ b/effects/snow.h @@ -39,6 +39,7 @@ class SnowEffect public: SnowEffect(); virtual ~SnowEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void postPaintScreen(); diff --git a/effects/sphere.cpp b/effects/sphere.cpp index 725f9445f9..57bc02c144 100644 --- a/effects/sphere.cpp +++ b/effects/sphere.cpp @@ -42,6 +42,16 @@ SphereEffect::SphereEffect() { if( wallpaper ) wallpaper->discard(); + reconfigure( ReconfigureAll ); + } + +SphereEffect::~SphereEffect() + { + delete mShader; + } + +void SphereEffect::reconfigure( ReconfigureFlags ) + { loadConfig( "Sphere" ); reflection = false; animateDesktopChange = false; @@ -51,11 +61,6 @@ SphereEffect::SphereEffect() bigCube = true; } -SphereEffect::~SphereEffect() - { - delete mShader; - } - bool SphereEffect::supported() { return GLRenderTarget::supported() && diff --git a/effects/sphere.h b/effects/sphere.h index a29b540adf..a4b2d5eeb6 100644 --- a/effects/sphere.h +++ b/effects/sphere.h @@ -33,6 +33,7 @@ class SphereEffect public: SphereEffect(); ~SphereEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); diff --git a/effects/thumbnailaside.cpp b/effects/thumbnailaside.cpp index cbf8d7e3ee..dec03e6bb4 100644 --- a/effects/thumbnailaside.cpp +++ b/effects/thumbnailaside.cpp @@ -33,18 +33,22 @@ KWIN_EFFECT( thumbnailaside, ThumbnailAsideEffect ) ThumbnailAsideEffect::ThumbnailAsideEffect() { - KConfigGroup conf = EffectsHandler::effectConfig("ThumbnailAside"); - KActionCollection* actionCollection = new KActionCollection( this ); KAction* a = (KAction*)actionCollection->addAction( "ToggleCurrentThumbnail" ); a->setText( i18n("Toggle Thumbnail for Current Window" )); a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_T)); connect(a, SIGNAL(triggered(bool)), this, SLOT(toggleCurrentThumbnail())); + reconfigure( ReconfigureAll ); + } +void ThumbnailAsideEffect::reconfigure( ReconfigureFlags ) + { + KConfigGroup conf = EffectsHandler::effectConfig("ThumbnailAside"); maxwidth = conf.readEntry("MaxWidth", 200); spacing = conf.readEntry("Spacing", 10); opacity = conf.readEntry("Opacity", 50) / 100.0; screen = conf.readEntry("Screen",-1); // Xinerama screen TODO add gui option + arrange(); } void ThumbnailAsideEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data ) diff --git a/effects/thumbnailaside.h b/effects/thumbnailaside.h index d0b89f9885..d0ad1f1540 100644 --- a/effects/thumbnailaside.h +++ b/effects/thumbnailaside.h @@ -42,6 +42,7 @@ class ThumbnailAsideEffect Q_OBJECT public: ThumbnailAsideEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data ); virtual void windowDamaged( EffectWindow* w, const QRect& damage ); virtual void windowGeometryShapeChanged( EffectWindow* w, const QRect& old ); diff --git a/effects/wobblywindows.cpp b/effects/wobblywindows.cpp index 3c414dad9c..8a77a9c871 100644 --- a/effects/wobblywindows.cpp +++ b/effects/wobblywindows.cpp @@ -168,6 +168,26 @@ static const ParameterSet pset[5] = { set_0, set_1, set_2, set_3, set_4 }; KWIN_EFFECT(wobblywindows, WobblyWindowsEffect) WobblyWindowsEffect::WobblyWindowsEffect() +{ + reconfigure( ReconfigureAll ); +} + +WobblyWindowsEffect::~WobblyWindowsEffect() +{ + if (!windows.empty()) + { + // we should be empty at this point... + // emit a warning and clean the list. + kDebug() << "Windows list not empty. Left items : " << windows.count(); + QHash< const EffectWindow*, WindowWobblyInfos >::iterator i; + for (i = windows.begin(); i != windows.end(); ++i) + { + freeWobblyInfo(i.value()); + } + } +} + +void WobblyWindowsEffect::reconfigure( ReconfigureFlags ) { KConfigGroup conf = effects->effectConfig("Wobbly"); @@ -225,20 +245,6 @@ WobblyWindowsEffect::WobblyWindowsEffect() #endif } -WobblyWindowsEffect::~WobblyWindowsEffect() -{ - if (!windows.empty()) - { - // we should be empty at this point... - // emit a warning and clean the list. - kDebug() << "Windows list not empty. Left items : " << windows.count(); - QHash< const EffectWindow*, WindowWobblyInfos >::iterator i; - for (i = windows.begin(); i != windows.end(); ++i) - { - freeWobblyInfo(i.value()); - } - } -} void WobblyWindowsEffect::setParameterSet(const ParameterSet& pset) { diff --git a/effects/wobblywindows.h b/effects/wobblywindows.h index 31b8f09069..dbb1a69241 100644 --- a/effects/wobblywindows.h +++ b/effects/wobblywindows.h @@ -29,6 +29,7 @@ class WobblyWindowsEffect : public Effect WobblyWindowsEffect(); virtual ~WobblyWindowsEffect(); + virtual void reconfigure( ReconfigureFlags ); virtual void prePaintScreen( ScreenPrePaintData& data, int time ); virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp index ba2c4a0c87..eed8a1f7f6 100644 --- a/kcmkwin/kwincompositing/main.cpp +++ b/kcmkwin/kwincompositing/main.cpp @@ -482,14 +482,6 @@ void KWinCompositingConfig::configChanged() // Send signal to all kwin instances QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); QDBusConnection::sessionBus().send(message); - // present windows effect has to be reloaded - message = QDBusMessage::createMethodCall("org.kde.kwin", "/KWin", "org.kde.KWin", "reloadEffect"); - message << QString("kwin4_effect_presentwindows"); - QDBusConnection::sessionBus().send(message); - // cube effect has to be reloaded - message = QDBusMessage::createMethodCall("org.kde.kwin", "/KWin", "org.kde.KWin", "reloadEffect"); - message << QString("kwin4_effect_cube"); - QDBusConnection::sessionBus().send(message); } diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp index 34d1276631..68a15fa674 100644 --- a/lib/kwineffects.cpp +++ b/lib/kwineffects.cpp @@ -108,6 +108,10 @@ Effect::~Effect() { } +void Effect::reconfigure( ReconfigureFlags ) + { + } + void Effect::windowUserMovedResized( EffectWindow* , bool, bool ) { } @@ -333,7 +337,7 @@ bool EffectsHandler::saturationSupported() const void EffectsHandler::sendReloadMessage( const QString& effectname ) { - QDBusMessage message = QDBusMessage::createMethodCall("org.kde.kwin", "/KWin", "org.kde.KWin", "reloadEffect"); + QDBusMessage message = QDBusMessage::createMethodCall("org.kde.kwin", "/KWin", "org.kde.KWin", "reconfigureEffect"); message << QString("kwin4_effect_" + effectname); QDBusConnection::sessionBus().send(message); } diff --git a/lib/kwineffects.h b/lib/kwineffects.h index 2845f3e5d7..20369ea86c 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -163,7 +163,7 @@ X-KDE-Library=kwin4_effect_cooleffect #define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor )) #define KWIN_EFFECT_API_VERSION_MAJOR 0 -#define KWIN_EFFECT_API_VERSION_MINOR 55 +#define KWIN_EFFECT_API_VERSION_MINOR 56 #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) @@ -273,6 +273,20 @@ class KWIN_EXPORT Effect **/ virtual ~Effect(); + /** + * Flags describing which parts of configuration have changed. + */ + enum ReconfigureFlag + { + ReconfigureAll = 1 << 0 /// Everything needs to be reconfigured. + }; + Q_DECLARE_FLAGS( ReconfigureFlags, ReconfigureFlag ) + + /** + * Called when configuration changes (either the effect's or KWin's global). + */ + virtual void reconfigure( ReconfigureFlags flags ); + /** * Called before starting to paint the screen. * In this method you can: diff --git a/org.kde.KWin.xml b/org.kde.KWin.xml index fe05470ee3..ec27372a84 100644 --- a/org.kde.KWin.xml +++ b/org.kde.KWin.xml @@ -44,7 +44,7 @@ - + diff --git a/useractions.cpp b/useractions.cpp index 7e266f6dbf..25357e6613 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -740,10 +740,10 @@ void Workspace::unloadEffect( const QString& name ) static_cast(effects)->unloadEffect( name ); } -void Workspace::reloadEffect( const QString& name ) +void Workspace::reconfigureEffect( const QString& name ) { if( effects ) - static_cast(effects)->reloadEffect( name ); + static_cast(effects)->reconfigureEffect( name ); } QStringList Workspace::loadedEffects() const diff --git a/workspace.h b/workspace.h index 03b128f4af..e7c6503593 100644 --- a/workspace.h +++ b/workspace.h @@ -209,8 +209,7 @@ class Workspace : public QObject, public KDecorationDefines void loadEffect( const QString& name ); void toggleEffect( const QString& name ); - void reloadEffect( const QString& name ); - + void reconfigureEffect( const QString& name ); void unloadEffect( const QString& name ); QStringList loadedEffects() const;