Support for proper effect reconfiguration instead of reloading them.

Fixes e.g. the global animation combo not taking effect.


svn path=/trunk/KDE/kdebase/workspace/; revision=866903
This commit is contained in:
Luboš Luňák 2008-10-02 09:27:32 +00:00
parent a0798dbe6c
commit 1d2c54edcc
48 changed files with 263 additions and 120 deletions

View file

@ -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 )

View file

@ -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;

View file

@ -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 )

View file

@ -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 );

View file

@ -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 )

View file

@ -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();

View file

@ -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 )
{

View file

@ -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();

View file

@ -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() &&

View file

@ -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 );

View file

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kaction.h>
#include <kactioncollection.h>
#include <kdebug.h>
#include <klocale.h>
#include <kconfiggroup.h>
#include <netwm_def.h>
@ -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

View file

@ -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();

View file

@ -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 )

View file

@ -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:

View file

@ -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 );

View file

@ -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();

View file

@ -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 );

View file

@ -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 );

View file

@ -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 )

View file

@ -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();

View file

@ -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 )

View file

@ -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 );

View file

@ -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);

View file

@ -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();

View file

@ -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 );

View file

@ -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 );

View file

@ -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 )

View file

@ -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,

View file

@ -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

View file

@ -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 );

View file

@ -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()

View file

@ -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 );

View file

@ -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 );

View file

@ -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 );

View file

@ -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 )

View file

@ -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();

View file

@ -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() &&

View file

@ -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 );

View file

@ -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 )

View file

@ -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 );

View file

@ -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)
{

View file

@ -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 );

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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:

View file

@ -44,7 +44,7 @@
<method name="toggleEffect">
<arg name="name" type="s" direction="in"/>
</method>
<method name="reloadEffect">
<method name="reconfigureEffect">
<arg name="name" type="s" direction="in"/>
</method>
<method name="loadedEffects">

View file

@ -740,10 +740,10 @@ void Workspace::unloadEffect( const QString& name )
static_cast<EffectsHandlerImpl*>(effects)->unloadEffect( name );
}
void Workspace::reloadEffect( const QString& name )
void Workspace::reconfigureEffect( const QString& name )
{
if( effects )
static_cast<EffectsHandlerImpl*>(effects)->reloadEffect( name );
static_cast<EffectsHandlerImpl*>(effects)->reconfigureEffect( name );
}
QStringList Workspace::loadedEffects() const

View file

@ -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;