Add slight animations to the dim inactive effect. Also don't dim windows

when a fullscreen effect is active, fixes dimmed windows during
coverswitch.
BUG: 165295

svn path=/trunk/KDE/kdebase/workspace/; revision=922574
icc-effect-5.14.5
Lucas Murray 2009-02-07 09:48:20 +00:00
parent 1db192a11d
commit 681cda92b5
2 changed files with 35 additions and 3 deletions

View File

@ -31,7 +31,10 @@ KWIN_EFFECT( diminactive, DimInactiveEffect )
DimInactiveEffect::DimInactiveEffect()
{
reconfigure( ReconfigureAll );
timeline.setDuration( 250 );
previousActiveTimeline.setDuration( 250 );
active = effects->activeWindow();
previousActive = NULL;
}
void DimInactiveEffect::reconfigure( ReconfigureFlags )
@ -43,12 +46,34 @@ void DimInactiveEffect::reconfigure( ReconfigureFlags )
dim_strength = conf.readEntry("Strength", 25);
}
void DimInactiveEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
double oldValue = timeline.value();
if( effects->activeFullScreenEffect() )
timeline.removeTime( time );
else
timeline.addTime( time );
if( oldValue != timeline.value() )
effects->addRepaintFull();
if( previousActive )
{ // We are fading out the previous window
previousActive->addRepaintFull();
previousActiveTimeline.addTime( time );
}
effects->prePaintScreen( data, time );
}
void DimInactiveEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
{
if( dimWindow( w ))
if( dimWindow( w ) || w == previousActive )
{
data.brightness *= (1.0 - (dim_strength / 100.0));
data.saturation *= (1.0 - (dim_strength / 100.0));
double previous = 1.0;
if( w == previousActive )
previous = previousActiveTimeline.value();
if( previousActiveTimeline.value() == 1.0 )
previousActive = NULL;
data.brightness *= (1.0 - (dim_strength / 100.0) * timeline.value() * previous );
data.saturation *= (1.0 - (dim_strength / 100.0) * timeline.value() * previous );
}
effects->paintWindow( w, mask, region, data );
}
@ -76,6 +101,9 @@ void DimInactiveEffect::windowActivated( EffectWindow* w )
{
if( active != NULL )
{
previousActive = active;
previousActiveTimeline.setProgress( 0.0 );
if( dim_by_group )
{
if(( w == NULL || w->group() != active->group()) && active->group() != NULL )

View File

@ -35,11 +35,15 @@ class DimInactiveEffect
public:
DimInactiveEffect();
virtual void reconfigure( ReconfigureFlags );
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
virtual void windowActivated( EffectWindow* c );
private:
bool dimWindow( const EffectWindow* w ) const;
TimeLine timeline;
EffectWindow* active;
EffectWindow* previousActive;
TimeLine previousActiveTimeline;
int dim_strength; // reduce saturation and brightness by this percentage
bool dim_panels; // do/don't dim also all panels
bool dim_desktop; // do/don't dim the desktop