From 763d9d8c6f129cb1e19861b8072d2e7d05661712 Mon Sep 17 00:00:00 2001 From: Lucas Murray Date: Sun, 14 Dec 2008 12:43:16 +0000 Subject: [PATCH] Previous shadow damage commit didn't catch 100% of the events. Lets just do it the old way but taking into account the decoration shadow sizes. svn path=/trunk/KDE/kdebase/workspace/; revision=896765 --- effects/shadow.cpp | 39 ++++++++++++++++++--------------------- effects/shadow.h | 2 +- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/effects/shadow.cpp b/effects/shadow.cpp index 8954991d77..c391abad51 100644 --- a/effects/shadow.cpp +++ b/effects/shadow.cpp @@ -192,12 +192,13 @@ void ShadowEffect::updateShadowColor() shadowColor = conf.readEntry( "Color", schemeShadowColor() ); } -QRect ShadowEffect::shadowRectangle( EffectWindow* w ) const +QRect ShadowEffect::shadowRectangle( EffectWindow* w, const QRect& windowRectangle ) const { QRectF shadowRect; bool shadowDefined = false; if( effects->hasDecorationShadows() ) - { + { // TODO: This function is called for EVERY damage, we need to cache this + // (But how? Decoration shadow can change shape if it wanted to) if( w->hasDecoration() && !forceDecorated ) { // Decorated windows must be normal windows foreach( const QRect &r, w->shadowQuads( ShadowBorderedActive )) @@ -225,17 +226,16 @@ QRect ShadowEffect::shadowRectangle( EffectWindow* w ) const } if( !shadowDefined ) { - int width = qMax( shadowFuzzyness * 2, w->width() + 2 * shadowSize ); - int height = qMax( shadowFuzzyness * 2, w->height() + 2 * shadowSize ); - int x1, y1, x2, y2; - // top-left - x1 = shadowXOffset - shadowSize + 0 - shadowFuzzyness; - y1 = shadowYOffset - shadowSize + 0 - shadowFuzzyness; - x2 = shadowXOffset - shadowSize + width + shadowFuzzyness; - y2 = shadowYOffset - shadowSize + height + shadowFuzzyness; - return QRect( x1 + w->x(), y1 + w->y(), x2 - x1, y2 - y1 ); + int shadowGrow = shadowFuzzyness + shadowSize; + return windowRectangle.adjusted( shadowXOffset - shadowGrow, shadowYOffset - shadowGrow, + shadowXOffset + shadowGrow, shadowYOffset + shadowGrow); } - return shadowRect.toRect().translated( w->x(), w->y() ); + return windowRectangle.adjusted( + qMin( shadowRect.x(), 0.0 ), + qMin( shadowRect.y(), 0.0 ), + qMax( shadowRect.x() + shadowRect.width() - w->width(), 0.0 ), + qMax( shadowRect.y() + shadowRect.height() - w->height(), 0.0 ) + ); } #ifdef KWIN_HAVE_XRENDER_COMPOSITING @@ -264,12 +264,8 @@ void ShadowEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data void ShadowEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) { - // Add the shadow area to the repaint if we are repainting the entire window - // This occurs when the active window is changed for example - // TODO: This only works if there are no animations in the shadows - QRect overlap = ( data.paint & w->geometry() ).boundingRect(); - if( useShadow( w ) && !overlap.isEmpty() && overlap != data.paint.boundingRect() ) - data.paint |= shadowRectangle( w ); + if( useShadow( w )) + data.paint |= shadowRectangle( w, data.paint.boundingRect() ); effects->prePaintWindow( w, data, time ); } @@ -300,7 +296,8 @@ void ShadowEffect::drawWindow( EffectWindow* w, int mask, QRegion region, Window if( !shadowDatas.isEmpty()) d.clip |= shadowDatas.last().clip; d.mask = mask; - d.region |= shadowRectangle( w ); + foreach( const QRect &r, region.rects() ) + d.region |= shadowRectangle( w, r ); d.region &= region; shadowDatas.append(d); } @@ -476,13 +473,13 @@ QRect ShadowEffect::transformWindowDamage( EffectWindow* w, const QRect& r ) { if( !useShadow( w )) return effects->transformWindowDamage( w, r ); - QRect r2 = r | shadowRectangle( w ); + QRect r2 = r | shadowRectangle( w, r ); return effects->transformWindowDamage( w, r2 ); } void ShadowEffect::windowClosed( EffectWindow* c ) { - effects->addRepaint( shadowRectangle( c )); + effects->addRepaint( shadowRectangle( c, c->geometry() )); } bool ShadowEffect::useShadow( EffectWindow* w ) const diff --git a/effects/shadow.h b/effects/shadow.h index ef2fc2ac3e..eafa1cdb45 100644 --- a/effects/shadow.h +++ b/effects/shadow.h @@ -61,7 +61,7 @@ class ShadowEffect void drawShadow( EffectWindow* w, int mask, QRegion region, const WindowPaintData& data ); void addQuadVertices(QVector& verts, float x1, float y1, float x2, float y2) const; // transforms window rect -> shadow rect - QRect shadowRectangle( EffectWindow* w ) const; + QRect shadowRectangle( EffectWindow* w, const QRect& windowRectangle ) const; bool useShadow( EffectWindow* w ) const; void drawQueuedShadows( EffectWindow* behindWindow );