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
This commit is contained in:
Martin Gräßlin 2010-11-10 18:33:07 +00:00
parent 6270b502ba
commit 6353d6ff57
7 changed files with 27 additions and 4 deletions

View file

@ -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;
}

View file

@ -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()
{

View file

@ -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)

View file

@ -167,7 +167,7 @@ QRegion BlurEffect::blurRegion(const EffectWindow *w) const
if (value.isValid()) {
const QRegion appRegion = qvariant_cast<QRegion>(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;

View file

@ -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

View file

@ -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

View file

@ -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 );