From 6353d6ff577412f7ef9c9c7dc23a230bf4f61321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 10 Nov 2010 18:33:07 +0000 Subject: [PATCH] Don't blur behind opaque window decorations. Adding a new AbilityUsesBlurBehind which can be set by decorations with alpha channel to request that the background can be blurred. This improves the situation for our completely opaque default Oxygen decoration. This change is a behavior change in comparison to 4.5! Translucent decorations do not get blurred by default any more. CCMAIL: craig.p.drummond@googlemail.com svn path=/trunk/KDE/kdebase/workspace/; revision=1195274 --- clients/aurorae/src/aurorae.cpp | 2 ++ effects.cpp | 5 +++++ effects.h | 2 ++ effects/blur/blur.cpp | 6 +++--- lib/kdecoration.h | 2 ++ lib/kwineffects.h | 8 +++++++- workspace.h | 6 ++++++ 7 files changed, 27 insertions(+), 4 deletions(-) diff --git a/clients/aurorae/src/aurorae.cpp b/clients/aurorae/src/aurorae.cpp index 08431a3544..6d8a5c0ce2 100644 --- a/clients/aurorae/src/aurorae.cpp +++ b/clients/aurorae/src/aurorae.cpp @@ -103,6 +103,8 @@ bool AuroraeFactory::supports(Ability ability) const return true; // TODO: correct value from theme case AbilityClientGrouping: return true; + case AbilityUsesBlurBehind: + return true; default: return false; } diff --git a/effects.cpp b/effects.cpp index 14d7a6b2b8..b96a00ba99 100644 --- a/effects.cpp +++ b/effects.cpp @@ -266,6 +266,11 @@ bool EffectsHandlerImpl::decorationsHaveAlpha() const return Workspace::self()->decorationHasAlpha(); } +bool EffectsHandlerImpl::decorationSupportsBlurBehind() const + { + return Workspace::self()->decorationSupportsBlurBehind(); + } + // start another painting pass void EffectsHandlerImpl::startPaint() { diff --git a/effects.h b/effects.h index ab07abe9bd..796a47c319 100644 --- a/effects.h +++ b/effects.h @@ -146,6 +146,8 @@ class EffectsHandlerImpl : public EffectsHandler virtual bool decorationsHaveAlpha() const; + virtual bool decorationSupportsBlurBehind() const; + virtual EffectFrame* effectFrame( EffectFrameStyle style, bool staticSize, const QPoint& position, Qt::Alignment alignment ) const; // internal (used by kwin core or compositing code) diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp index c024632e33..7420b89787 100644 --- a/effects/blur/blur.cpp +++ b/effects/blur/blur.cpp @@ -167,7 +167,7 @@ QRegion BlurEffect::blurRegion(const EffectWindow *w) const if (value.isValid()) { const QRegion appRegion = qvariant_cast(value); if (!appRegion.isEmpty()) { - if (w->hasDecoration()) { + if (w->hasDecoration() && effects->decorationSupportsBlurBehind()) { region = w->shape(); region -= w->decorationInnerRect(); region |= appRegion.translated(w->contentsRect().topLeft()) & @@ -179,7 +179,7 @@ QRegion BlurEffect::blurRegion(const EffectWindow *w) const // for the whole window. region = w->shape(); } - } else if (w->hasDecoration()) { + } else if (w->hasDecoration() && effects->decorationSupportsBlurBehind()) { // If the client hasn't specified a blur region, we'll only enable // the effect behind the decoration. region = w->shape(); @@ -236,7 +236,7 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPai bool scaled = !qFuzzyCompare(data.xScale, 1.0) && !qFuzzyCompare(data.yScale, 1.0); bool translated = data.xTranslate || data.yTranslate; bool transformed = scaled || translated || mask & PAINT_WINDOW_TRANSFORMED; - bool hasAlpha = w->hasAlpha() || (w->hasDecoration() && effects->decorationsHaveAlpha()); + bool hasAlpha = w->hasAlpha() || (w->hasDecoration() && effects->decorationsHaveAlpha() && effects->decorationSupportsBlurBehind()); bool valid = target->valid() && shader->isValid(); QRegion shape; diff --git a/lib/kdecoration.h b/lib/kdecoration.h index 553ae09eec..4881beabc4 100644 --- a/lib/kdecoration.h +++ b/lib/kdecoration.h @@ -200,6 +200,8 @@ public: /// @since 4.3 AbilityExtendIntoClientArea = 3002, ///< The decoration respects transparentRect() /// @since 4.4 + AbilityUsesBlurBehind = 3003, ///< The decoration wants the background to be blurred, when the blur plugin is enabled. + /// @since 4.6 // Tabbing AbilityClientGrouping = 4000, ///< The decoration supports tabbing // TODO colors for individual button types diff --git a/lib/kwineffects.h b/lib/kwineffects.h index 40e7922a84..ec1fb316e4 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -171,7 +171,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 156 +#define KWIN_EFFECT_API_VERSION_MINOR 157 #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) @@ -795,6 +795,12 @@ class KWIN_EXPORT EffectsHandler */ virtual bool decorationsHaveAlpha() const = 0; + /** + * Returns @a true if the window decorations support blurring behind the decoration, and @a false otherwise + * @since 4.6 + */ + virtual bool decorationSupportsBlurBehind() const = 0; + /** * Checks if the driver is on given blacklist. * The format of the blacklist is driver identifier as key (e.g. Intel) with a list of diff --git a/workspace.h b/workspace.h index 8a07fe9794..12ec259200 100644 --- a/workspace.h +++ b/workspace.h @@ -435,6 +435,7 @@ class Workspace : public QObject, public KDecorationDefines bool decorationHasAlpha() const; bool decorationSupportsClientGrouping() const; // Returns true if the decoration supports tabs. bool decorationSupportsFrameOverlap() const; + bool decorationSupportsBlurBehind() const; // D-Bus interface void cascadeDesktop(); @@ -1376,6 +1377,11 @@ inline bool Workspace::decorationSupportsFrameOverlap() const return mgr->factory()->supports( AbilityExtendIntoClientArea ); } +inline bool Workspace::decorationSupportsBlurBehind() const + { + return mgr->factory()->supports( AbilityUsesBlurBehind ); + } + inline void Workspace::addClientGroup( ClientGroup* group ) { clientGroups.append( group );