Option for transparent inactive windows. Patch by "Mark Eaton" <eaton.mark@gmail.com>.

svn path=/trunk/KDE/kdebase/workspace/; revision=761341
icc-effect-5.14.5
Luboš Luňák 2008-01-14 15:34:39 +00:00
parent 21dc4fa63d
commit be6520907a
4 changed files with 84 additions and 14 deletions

View File

@ -33,6 +33,8 @@ MakeTransparentEffect::MakeTransparentEffect()
decoration = conf.readEntry( "Decoration", 0.7 );
moveresize = conf.readEntry( "MoveResize", 0.8 );
dialogs = conf.readEntry( "Dialogs", 1.0 );
inactive = conf.readEntry( "Inactive", 1.0 );
active = effects->activeWindow();
}
void MakeTransparentEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
@ -53,19 +55,71 @@ void MakeTransparentEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData&
void MakeTransparentEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
{
if( decoration != 1.0 && w->hasDecoration())
data.decoration_opacity *= decoration;
if( dialogs != 1.0 && w->isDialog())
data.opacity *= dialogs;
if( moveresize != 1.0 && ( w->isUserMove() || w->isUserResize()))
data.opacity *= moveresize;
if( inactive != 1.0 && isInactive(w) )
{
data.opacity *= inactive;
}
else
{
if( decoration != 1.0 && w->hasDecoration())
data.decoration_opacity *= decoration;
if( dialogs != 1.0 && w->isDialog())
data.opacity *= dialogs;
if( moveresize != 1.0 && ( w->isUserMove() || w->isUserResize()))
data.opacity *= moveresize;
}
effects->paintWindow( w, mask, region, data );
}
bool MakeTransparentEffect::isInactive( const EffectWindow* w ) const
{
if( active == w || w->isDock() || !w->isManaged() )
return false;
if( NULL != active && NULL != active->group() )
if (active->group() == w->group() )
return false;
if( !w->isNormalWindow() && !w->isDialog() && !w->isDock() )
return false;
return true;
}
void MakeTransparentEffect::windowUserMovedResized( EffectWindow* w, bool first, bool last )
{
if( moveresize != 1.0 && ( first || last ))
w->addRepaintFull();
}
void MakeTransparentEffect::windowActivated( EffectWindow* w )
{
if( inactive != 1.0 )
{
if( NULL != active && active != w )
{
if( ( NULL == w || w->group() != active->group() ) &&
NULL != active->group() )
{
// Active group has changed. so repaint old group
foreach( EffectWindow *tmp, active->group()->members() )
tmp->addRepaintFull();
}
else
active->addRepaintFull();
}
if( NULL != w )
{
if (NULL != w->group() )
{
// Repaint windows in new group
foreach( EffectWindow *tmp, w->group()->members() )
tmp->addRepaintFull();
}
else
w->addRepaintFull();
}
}
active = w;
}
} // namespace

View File

@ -34,10 +34,15 @@ class MakeTransparentEffect
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 );
virtual void windowActivated( EffectWindow* w );
private:
bool isInactive( const EffectWindow *w ) const;
double decoration;
double moveresize;
double dialogs;
double inactive;
EffectWindow* active;
};
} // namespace

View File

@ -48,24 +48,31 @@ MakeTransparentEffectConfig::MakeTransparentEffectConfig(QWidget* parent, const
layout->addWidget(new QLabel(i18n("Decorations:"), this), 1, 0);
mDecoration = new QSpinBox(this);
mDecoration->setRange(0, 100);
mDecoration->setRange(10, 100);
mDecoration->setSuffix("%");
connect(mDecoration, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mDecoration, 1, 1);
layout->addWidget(new QLabel(i18n("Moved/resized windows:"), this), 2, 0);
layout->addWidget(new QLabel(i18n("Inactive windows:"), this), 2, 0);
mInactive = new QSpinBox(this);
mInactive->setRange(10, 100);
mInactive->setSuffix("%");
connect(mInactive, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mInactive, 2, 1);
layout->addWidget(new QLabel(i18n("Moved/resized windows:"), this), 3, 0);
mMoveResize = new QSpinBox(this);
mMoveResize->setRange(0, 100);
mMoveResize->setRange(10, 100);
mMoveResize->setSuffix("%");
connect(mMoveResize, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mMoveResize, 2, 1);
layout->addWidget(mMoveResize, 3, 1);
layout->addWidget(new QLabel(i18n("Dialogs:"), this), 3, 0);
layout->addWidget(new QLabel(i18n("Dialogs:"), this), 4, 0);
mDialogs = new QSpinBox(this);
mDialogs->setRange(0, 100);
mDialogs->setRange(10, 100);
mDialogs->setSuffix("%");
connect(mDialogs, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mDialogs, 3, 1);
layout->addWidget(mDialogs, 4, 1);
layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 4, 0, 1, 2);
@ -78,9 +85,10 @@ void MakeTransparentEffectConfig::load()
KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig("MakeTransparent");
mDecoration->setValue( (int)( conf.readEntry( "Decoration", 0.7 ) * 100 ) );
mDecoration->setValue( (int)( conf.readEntry( "Decoration", 1.0 ) * 100 ) );
mMoveResize->setValue( (int)( conf.readEntry( "MoveResize", 0.8 ) * 100 ) );
mDialogs->setValue( (int)( conf.readEntry( "Dialogs", 1.0 ) * 100 ) );
mInactive->setValue( (int)( conf.readEntry( "Inactive", 0.6 ) * 100 ) );
emit changed(false);
}
@ -94,6 +102,7 @@ void MakeTransparentEffectConfig::save()
conf.writeEntry( "Decoration", mDecoration->value() / 100.0 );
conf.writeEntry( "MoveResize", mMoveResize->value() / 100.0 );
conf.writeEntry( "Dialogs", mDialogs->value() / 100.0 );
conf.writeEntry( "Inactive", mInactive->value() / 100.0 );
conf.sync();
emit changed(false);
@ -106,6 +115,7 @@ void MakeTransparentEffectConfig::defaults()
mDecoration->setValue( 70 );
mMoveResize->setValue( 80 );
mDialogs->setValue( 100 );
mInactive->setValue( 100 );
emit changed(true);
}

View File

@ -44,6 +44,7 @@ class MakeTransparentEffectConfig : public KCModule
QSpinBox* mDecoration;
QSpinBox* mMoveResize;
QSpinBox* mDialogs;
QSpinBox* mInactive;
};
} // namespace