From 0e1cb2a603a1aa53c90bf60b954e84ab6fa2c8c8 Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Fri, 28 Sep 2007 12:43:51 +0000 Subject: [PATCH] Add option to make active window's shadow stronger (on by default). svn path=/trunk/KDE/kdebase/workspace/; revision=718304 --- effects/shadow.cpp | 8 +++++++- effects/shadow.h | 1 + effects/shadow_config.cpp | 30 +++++++++++++++++++----------- effects/shadow_config.h | 2 ++ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/effects/shadow.cpp b/effects/shadow.cpp index 1b2c37c62a..c948e19861 100644 --- a/effects/shadow.cpp +++ b/effects/shadow.cpp @@ -28,6 +28,7 @@ ShadowEffect::ShadowEffect() shadowOpacity = conf.readEntry( "Opacity", 0.2 ); shadowFuzzyness = conf.readEntry( "Fuzzyness", 10 ); shadowSize = conf.readEntry( "Size", 5 ); + intensifyActiveShadow = conf.readEntry( "IntensifyActiveShadow", true ); QString shadowtexture = KGlobal::dirs()->findResource("data", "kwin/shadow-texture.png"); mShadowTexture = new GLTexture(shadowtexture); @@ -127,7 +128,12 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, W mShadowTexture->bind(); // Take the transparency settings and window's transparency into account. // Also make the shadow more transparent if we've made it bigger - glColor4f(0, 0, 0, shadowOpacity * data.opacity * (window->width() / (double)w) * (window->height() / (double)h)); + float opacity = shadowOpacity; + if( intensifyActiveShadow && window == effects->activeWindow() ) + { + opacity = 1 - (1 - shadowOpacity)*(1 - shadowOpacity); + } + glColor4f(0, 0, 0, opacity * data.opacity * (window->width() / (double)w) * (window->height() / (double)h)); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // We have two elements per vertex in the verts array int verticesCount = verts.count() / 2; diff --git a/effects/shadow.h b/effects/shadow.h index ba5c108fd2..be5f4ac8f4 100644 --- a/effects/shadow.h +++ b/effects/shadow.h @@ -38,6 +38,7 @@ class ShadowEffect double shadowOpacity; int shadowFuzzyness; int shadowSize; + bool intensifyActiveShadow; GLTexture* mShadowTexture; }; diff --git a/effects/shadow_config.cpp b/effects/shadow_config.cpp index 4706d914cb..32a1b870b0 100644 --- a/effects/shadow_config.cpp +++ b/effects/shadow_config.cpp @@ -19,6 +19,7 @@ License. See the file "COPYING" for the exact licensing terms. #include #include #include +#include KWIN_EFFECT_CONFIG_FACTORY @@ -32,38 +33,42 @@ ShadowEffectConfig::ShadowEffectConfig(QWidget* parent, const QVariantList& args QGridLayout* layout = new QGridLayout(this); - layout->addWidget(new QLabel(i18n("X offset:")), 0, 0); - mShadowXOffset = new QSpinBox; + layout->addWidget(new QLabel(i18n("X offset:"), this), 0, 0); + mShadowXOffset = new QSpinBox(this); mShadowXOffset->setRange(-20, 20); connect(mShadowXOffset, SIGNAL(valueChanged(int)), this, SLOT(changed())); layout->addWidget(mShadowXOffset, 0, 1); - layout->addWidget(new QLabel(i18n("Y offset:")), 1, 0); - mShadowYOffset = new QSpinBox; + layout->addWidget(new QLabel(i18n("Y offset:"), this), 1, 0); + mShadowYOffset = new QSpinBox(this); mShadowYOffset->setRange(-20, 20); connect(mShadowYOffset, SIGNAL(valueChanged(int)), this, SLOT(changed())); layout->addWidget(mShadowYOffset, 1, 1); - layout->addWidget(new QLabel(i18n("Shadow opacity:")), 2, 0); - mShadowOpacity = new QSpinBox; + layout->addWidget(new QLabel(i18n("Shadow opacity:"), this), 2, 0); + mShadowOpacity = new QSpinBox(this); mShadowOpacity->setRange(0, 100); mShadowOpacity->setSuffix("%"); connect(mShadowOpacity, SIGNAL(valueChanged(int)), this, SLOT(changed())); layout->addWidget(mShadowOpacity, 2, 1); - layout->addWidget(new QLabel(i18n("Shadow fuzzyness:")), 3, 0); - mShadowFuzzyness = new QSpinBox; + layout->addWidget(new QLabel(i18n("Shadow fuzzyness:"), this), 3, 0); + mShadowFuzzyness = new QSpinBox(this); mShadowFuzzyness->setRange(0, 20); connect(mShadowFuzzyness, SIGNAL(valueChanged(int)), this, SLOT(changed())); layout->addWidget(mShadowFuzzyness, 3, 1); - layout->addWidget(new QLabel(i18n("Shadow size (relative to window):")), 4, 0); - mShadowSize = new QSpinBox; + layout->addWidget(new QLabel(i18n("Shadow size (relative to window):"), this), 4, 0); + mShadowSize = new QSpinBox(this); mShadowSize->setRange(0, 20); connect(mShadowSize, SIGNAL(valueChanged(int)), this, SLOT(changed())); layout->addWidget(mShadowSize, 4, 1); - layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 5, 0, 1, 2); + mIntensifyActiveShadow = new QCheckBox(i18n("Active window has stronger shadow"), this); + connect(mIntensifyActiveShadow, SIGNAL(toggled(bool)), this, SLOT(changed())); + layout->addWidget(mIntensifyActiveShadow, 5, 0, 1, 2); + + layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 6, 0, 1, 2); load(); } @@ -84,6 +89,7 @@ void ShadowEffectConfig::load() mShadowOpacity->setValue( (int)( conf.readEntry( "Opacity", 0.2 ) * 100 ) ); mShadowFuzzyness->setValue( conf.readEntry( "Fuzzyness", 10 ) ); mShadowSize->setValue( conf.readEntry( "Size", 5 ) ); + mIntensifyActiveShadow->setChecked( conf.readEntry( "IntensifyActiveShadow", true ) ); emit changed(false); } @@ -99,6 +105,7 @@ void ShadowEffectConfig::save() conf.writeEntry( "Opacity", mShadowOpacity->value() / 100.0 ); conf.writeEntry( "Fuzzyness", mShadowFuzzyness->value() ); conf.writeEntry( "Size", mShadowSize->value() ); + conf.writeEntry( "IntensifyActiveShadow", mIntensifyActiveShadow->isChecked() ); conf.sync(); emit changed(false); @@ -113,6 +120,7 @@ void ShadowEffectConfig::defaults() mShadowOpacity->setValue( 20 ); mShadowFuzzyness->setValue( 10 ); mShadowSize->setValue( 5 ); + mIntensifyActiveShadow->setChecked( true ); emit changed(true); } diff --git a/effects/shadow_config.h b/effects/shadow_config.h index 7d59f60fae..47cb6d4cc5 100644 --- a/effects/shadow_config.h +++ b/effects/shadow_config.h @@ -16,6 +16,7 @@ License. See the file "COPYING" for the exact licensing terms. #undef KDE3_SUPPORT class QSpinBox; +class QCheckBox; namespace KWin { @@ -37,6 +38,7 @@ class ShadowEffectConfig : public KCModule QSpinBox* mShadowOpacity; QSpinBox* mShadowFuzzyness; QSpinBox* mShadowSize; + QCheckBox* mIntensifyActiveShadow; }; } // namespace