2007-04-29 17:35:43 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
|
2007-11-13 16:20:52 +00:00
|
|
|
Copyright (C) 2007 Christian Nitschkowski <christian.nitschkowski@kdemail.net>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
2007-11-13 16:20:52 +00:00
|
|
|
#include <kconfiggroup.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include "diminactive.h"
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2007-05-28 11:16:18 +00:00
|
|
|
KWIN_EFFECT( diminactive, DimInactiveEffect )
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
DimInactiveEffect::DimInactiveEffect()
|
|
|
|
{
|
2007-11-13 16:20:52 +00:00
|
|
|
KConfigGroup conf = EffectsHandler::effectConfig("DimInactive");
|
|
|
|
|
|
|
|
dim_panels = conf.readEntry("DimPanels", false);
|
|
|
|
dim_by_group = conf.readEntry("DimByGroup", true);
|
|
|
|
dim_strength = conf.readEntry("Strength", 25);
|
2007-04-29 17:35:43 +00:00
|
|
|
active = effects->activeWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DimInactiveEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
|
|
|
{
|
|
|
|
bool dim = false;
|
2007-11-24 12:10:27 +00:00
|
|
|
if( active && dim_by_group && active->group() == w->group())
|
2007-04-29 17:35:43 +00:00
|
|
|
dim = false;
|
2007-11-24 12:10:27 +00:00
|
|
|
else if( active && !dim_by_group && active == w )
|
2007-04-29 17:35:43 +00:00
|
|
|
dim = false;
|
|
|
|
else if( w->isDock())
|
|
|
|
dim = dim_panels;
|
2007-11-24 12:10:27 +00:00
|
|
|
else if( !w->isNormalWindow() && !w->isDialog())
|
|
|
|
dim = false;
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
|
|
|
dim = true;
|
|
|
|
if( dim )
|
|
|
|
{
|
2007-11-13 16:20:52 +00:00
|
|
|
data.brightness *= (1.0 - (dim_strength / 100.0));
|
|
|
|
data.saturation *= (1.0 - (dim_strength / 100.0));
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
effects->paintWindow( w, mask, region, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
void DimInactiveEffect::windowActivated( EffectWindow* w )
|
|
|
|
{
|
|
|
|
if( active != NULL )
|
|
|
|
{
|
|
|
|
if( dim_by_group )
|
|
|
|
{
|
|
|
|
if(( w == NULL || w->group() != active->group()) && active->group() != NULL )
|
|
|
|
{ // repaint windows that are not longer in active group
|
|
|
|
foreach( EffectWindow* tmp, active->group()->members())
|
|
|
|
tmp->addRepaintFull();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
active->addRepaintFull();
|
|
|
|
}
|
|
|
|
active = w;
|
|
|
|
if( active != NULL )
|
|
|
|
if( dim_by_group )
|
|
|
|
{
|
|
|
|
if( active->group() != NULL )
|
|
|
|
{ // repaint newly active windows
|
|
|
|
foreach( EffectWindow* tmp, active->group()->members())
|
|
|
|
tmp->addRepaintFull();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
active->addRepaintFull();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|