From 8d09ed341ae93dbac3037d1f9df17794ecd89895 Mon Sep 17 00:00:00 2001 From: Lucas Murray Date: Thu, 11 Jun 2009 08:11:13 +0000 Subject: [PATCH] Remove old decoration shadow API, rename AbilityProvidesShadow and add support for the new decoration shadow API in the shadow effect. svn path=/trunk/KDE/kdebase/workspace/; revision=980130 --- bridge.cpp | 23 -- bridge.h | 3 - client.h | 33 -- clients/oxygen/oxygen.cpp | 2 +- clients/ozone/oxygen.cpp | 2 +- effects.cpp | 54 --- effects.h | 7 - effects/shadow/shadow.cpp | 525 ++++++++---------------------- effects/shadow/shadow.h | 6 - effects/shadow/shadow_config.cpp | 16 - effects/shadow/shadow_config.ui | 541 +++++++++++++------------------ lib/kcommondecoration.cpp | 36 -- lib/kcommondecoration.h | 6 - lib/kcommondecoration_p.cpp | 28 -- lib/kcommondecoration_p.h | 5 - lib/kdecoration.cpp | 42 --- lib/kdecoration.h | 39 +-- lib/kdecorationbridge.h | 3 - lib/kdecorationfactory.cpp | 36 -- lib/kdecorationfactory.h | 34 +- lib/kwineffects.h | 30 +- workspace.h | 51 +-- 22 files changed, 371 insertions(+), 1151 deletions(-) diff --git a/bridge.cpp b/bridge.cpp index 412c398e43..6c4769723e 100644 --- a/bridge.cpp +++ b/bridge.cpp @@ -203,32 +203,9 @@ void Bridge::grabXServer( bool grab ) KWin::ungrabXServer(); } -void Bridge::repaintShadow() - { - // TODO - } - bool Bridge::compositingActive() const { return c->workspace()->compositingActive(); } -bool Bridge::shadowsActive() const - { - if( !c->workspace()->compositingActive() ) - return false; - if( effects && static_cast( effects )->isEffectLoaded( "kwin4_effect_shadow" )) - { // The shadow effect has a setting to disable decoration shadows, take it into account. - KConfigGroup conf = static_cast( effects )->effectConfig( "Shadow" ); - return !conf.readEntry( "forceDecoratedToDefault", false ); - } - return false; - } - -double Bridge::opacity() const - { - return c->opacity(); - } - - } // namespace diff --git a/bridge.h b/bridge.h index 5332d6aa5d..581b27a08d 100644 --- a/bridge.h +++ b/bridge.h @@ -75,10 +75,7 @@ class Bridge : public KDecorationBridgeUnstable virtual Qt::WFlags initialWFlags() const; virtual void grabXServer( bool grab ); - virtual void repaintShadow(); virtual bool compositingActive() const; - virtual bool shadowsActive() const; - virtual double opacity() const; private: Client* c; }; diff --git a/client.h b/client.h index 743cf6647f..6be895ea18 100644 --- a/client.h +++ b/client.h @@ -300,11 +300,6 @@ class Client } // Decorations <-> Effects - QList shadowQuads( ShadowType type ) const; - double shadowOpacity( ShadowType type ) const; - double shadowBrightness( ShadowType type ) const; - double shadowSaturation( ShadowType type ) const; - const QPixmap *topDecoPixmap() const { return &decorationPixmapTop; } const QPixmap *leftDecoPixmap() const { return &decorationPixmapLeft; } const QPixmap *bottomDecoPixmap() const { return &decorationPixmapBottom; } @@ -847,34 +842,6 @@ inline bool Client::hiddenPreview() const return mapping_state == Kept; } -inline QList Client::shadowQuads( ShadowType type ) const - { - if( KDecorationUnstable* decoration2 = dynamic_cast< KDecorationUnstable* >( decoration )) - return decoration2->shadowQuads( type ); - return QList(); - } - -inline double Client::shadowOpacity( ShadowType type ) const - { - if( KDecorationUnstable* decoration2 = dynamic_cast< KDecorationUnstable* >( decoration )) - return decoration2->shadowOpacity( type ); - return 1.0; - } - -inline double Client::shadowBrightness( ShadowType type ) const - { - if( KDecorationUnstable* decoration2 = dynamic_cast< KDecorationUnstable* >( decoration )) - return decoration2->shadowBrightness( type ); - return 1.0; - } - -inline double Client::shadowSaturation( ShadowType type ) const - { - if( KDecorationUnstable* decoration2 = dynamic_cast< KDecorationUnstable* >( decoration )) - return decoration2->shadowSaturation( type ); - return 1.0; - } - KWIN_COMPARE_PREDICATE( WrapperIdMatchPredicate, Client, Window, cl->wrapperId() == value ); } // namespace diff --git a/clients/oxygen/oxygen.cpp b/clients/oxygen/oxygen.cpp index 4b8d2fab12..b219d97909 100644 --- a/clients/oxygen/oxygen.cpp +++ b/clients/oxygen/oxygen.cpp @@ -202,7 +202,7 @@ bool OxygenFactory::supports( Ability ability ) const case AbilityButtonSpacer: case AbilityButtonShade: // compositing - case AbilityCompositingShadow: // TODO: UI option to use default shadows instead + case AbilityProvidesShadow: // TODO: UI option to use default shadows instead case AbilityUsesAlphaChannel: return true; // no colors supported at this time diff --git a/clients/ozone/oxygen.cpp b/clients/ozone/oxygen.cpp index 673b1f6878..95765d8335 100644 --- a/clients/ozone/oxygen.cpp +++ b/clients/ozone/oxygen.cpp @@ -208,7 +208,7 @@ bool OxygenFactory::supports( Ability ability ) const case AbilityButtonSpacer: case AbilityButtonShade: // compositing - case AbilityCompositingShadow: // TODO: UI option to use default shadows instead + case AbilityProvidesShadow: // TODO: UI option to use default shadows instead case AbilityUsesAlphaChannel: return true; // no colors supported at this time diff --git a/effects.cpp b/effects.cpp index 2ee35ee07a..2dd801f061 100644 --- a/effects.cpp +++ b/effects.cpp @@ -192,16 +192,6 @@ bool EffectsHandlerImpl::hasDecorationShadows() const return Workspace::self()->hasDecorationShadows(); } -QList< QList > EffectsHandlerImpl::shadowTextures() - { - return Workspace::self()->decorationShadowTextures(); - } - -int EffectsHandlerImpl::shadowTextureList( ShadowType type ) const - { - return Workspace::self()->decorationShadowTextureList( type ); - } - // start another painting pass void EffectsHandlerImpl::startPaint() { @@ -1445,50 +1435,6 @@ EffectWindowList EffectWindowImpl::mainWindows() const return EffectWindowList(); } -QList EffectWindowImpl::shadowQuads( ShadowType type ) const - { - if( type == ShadowBorderedActive || type == ShadowBorderedInactive ) - { - if( Client* c = dynamic_cast< Client* >( toplevel )) - return c->shadowQuads( type ); - return QList(); - } - return toplevel->workspace()->decorationShadowQuads( type, toplevel->size() ); - } - -double EffectWindowImpl::shadowOpacity( ShadowType type ) const - { - if( type == ShadowBorderedActive || type == ShadowBorderedInactive ) - { - if( Client* c = dynamic_cast< Client* >( toplevel )) - return c->shadowOpacity( type ); - return 1.0; - } - return toplevel->workspace()->decorationShadowOpacity( type ); - } - -double EffectWindowImpl::shadowBrightness( ShadowType type ) const - { - if( type == ShadowBorderedActive || type == ShadowBorderedInactive ) - { - if( Client* c = dynamic_cast< Client* >( toplevel )) - return c->shadowBrightness( type ); - return 1.0; - } - return toplevel->workspace()->decorationShadowBrightness( type ); - } - -double EffectWindowImpl::shadowSaturation( ShadowType type ) const - { - if( type == ShadowBorderedActive || type == ShadowBorderedInactive ) - { - if( Client* c = dynamic_cast< Client* >( toplevel )) - return c->shadowSaturation( type ); - return 1.0; - } - return toplevel->workspace()->decorationShadowSaturation( type ); - } - WindowQuadList EffectWindowImpl::buildQuads( bool force ) const { return sceneWindow()->buildQuads( force ); diff --git a/effects.h b/effects.h index 0bf69461fd..4023ef7548 100644 --- a/effects.h +++ b/effects.h @@ -134,8 +134,6 @@ class EffectsHandlerImpl : public EffectsHandler virtual void registerPropertyType( long atom, bool reg ); virtual bool hasDecorationShadows() const; - virtual QList< QList > shadowTextures(); - virtual int shadowTextureList( ShadowType type ) const; // internal (used by kwin core or compositing code) void startPaint(); @@ -256,11 +254,6 @@ class EffectWindowImpl : public EffectWindow virtual EffectWindow* findModal(); virtual EffectWindowList mainWindows() const; - virtual QList shadowQuads( ShadowType type ) const; - virtual double shadowOpacity( ShadowType type ) const; - virtual double shadowBrightness( ShadowType type ) const; - virtual double shadowSaturation( ShadowType type ) const; - virtual WindowQuadList buildQuads( bool force = false ) const; const Toplevel* window() const; diff --git a/effects/shadow/shadow.cpp b/effects/shadow/shadow.cpp index 3040b1a77e..41978418c4 100644 --- a/effects/shadow/shadow.cpp +++ b/effects/shadow/shadow.cpp @@ -50,16 +50,10 @@ ShadowEffect::ShadowEffect() ShadowEffect::~ShadowEffect() { #ifdef KWIN_HAVE_OPENGL_COMPOSITING - for( int i = 0; i < mShadowTextures.size(); i++ ) - for( int j = 0; j < mShadowTextures.at( i ).size(); j++ ) - delete mShadowTextures.at( i ).at( j ); for( int i = 0; i < mDefaultShadowTextures.size(); i++ ) delete mDefaultShadowTextures.at( i ); #endif #ifdef KWIN_HAVE_XRENDER_COMPOSITING - for( int i = 0; i < mShadowPics.size(); i++ ) - for( int j = 0; j < mShadowPics.at( i ).size(); j++ ) - delete mShadowPics.at( i ).at( j ); for( int i = 0; i < mDefaultShadowPics.size(); i++ ) delete mDefaultShadowPics.at( i ); #endif @@ -75,41 +69,16 @@ void ShadowEffect::reconfigure( ReconfigureFlags ) shadowSize = conf.readEntry( "Size", 5 ); intensifyActiveShadow = conf.readEntry( "IntensifyActiveShadow", true ); updateShadowColor(); - forceDecorated = conf.readEntry( "forceDecoratedToDefault", false ); - forceUndecorated = conf.readEntry( "forceUndecoratedToDefault", false ); - forceOther = conf.readEntry( "forceOtherToDefault", false ); // Load decoration shadow related things - bool reconfiguring = false; - if( mShadowQuadTypes.count() ) - reconfiguring = true; - mShadowQuadTypes.clear(); // Changed decoration? TODO: Unregister? #ifdef KWIN_HAVE_OPENGL_COMPOSITING if( effects->compositingType() == OpenGLCompositing ) { // Delete any other textures in memory - for( int i = 0; i < mShadowTextures.size(); i++ ) - for( int j = 0; j < mShadowTextures.at( i ).size(); j++ ) - delete mShadowTextures.at( i ).at( j ); - mShadowTextures.clear(); for( int i = 0; i < mDefaultShadowTextures.size(); i++ ) delete mDefaultShadowTextures.at( i ); mDefaultShadowTextures.clear(); - // Create decoration shadows - if( effects->hasDecorationShadows() ) - { - QList< QList > shadowImages = effects->shadowTextures(); - for( int i = 0; i < shadowImages.size(); i++ ) - { - mShadowQuadTypes.append( effects->newWindowQuadType() ); - QList textures; - for( int j = 0; j < shadowImages.at( i ).size(); j++ ) - textures.append( new GLTexture( shadowImages.at( i ).at( j ))); - mShadowTextures.append( textures ); - } - } - //------------------------- // Create default textures @@ -143,28 +112,10 @@ void ShadowEffect::reconfigure( ReconfigureFlags ) if( effects->compositingType() == XRenderCompositing ) { // Delete any other pictures in memory - for( int i = 0; i < mShadowPics.size(); i++ ) - for( int j = 0; j < mShadowPics.at( i ).size(); j++ ) - delete mShadowPics.at( i ).at( j ); - mShadowPics.clear(); for( int i = 0; i < mDefaultShadowPics.size(); i++ ) delete mDefaultShadowPics.at( i ); mDefaultShadowPics.clear(); - // Create decoration pictures - if( effects->hasDecorationShadows() ) - { - QList< QList > shadowImages = effects->shadowTextures(); - for( int i = 0; i < shadowImages.size(); i++ ) - { - mShadowQuadTypes.append( effects->newWindowQuadType() ); - QList pictures; - for( int j = 0; j < shadowImages.at( i ).size(); j++ ) - pictures.append( new XRenderPicture( QPixmap::fromImage( shadowImages.at( i ).at( j )))); - mShadowPics.append( pictures ); - } - } - // Create default pictures mDefaultShadowQuadType = effects->newWindowQuadType(); // TODO: Unregister? QPixmap shadowPixmap( KGlobal::dirs()->findResource( "data", "kwin/shadow-texture.png" )); @@ -185,19 +136,15 @@ void ShadowEffect::reconfigure( ReconfigureFlags ) // Apply repeat attribute to all pictures XRenderPictureAttributes pa; pa.repeat = true; - for( int i = 0; i < mShadowPics.size(); i++ ) - for( int j = 0; j < mShadowPics.at( i ).size(); j++ ) - XRenderChangePicture( display(), *mShadowPics.at( i ).at( j ), CPRepeat, &pa ); for( int i = 0; i < mDefaultShadowPics.size(); i++ ) XRenderChangePicture( display(), *mDefaultShadowPics.at( i ), CPRepeat, &pa ); } #endif - if( reconfiguring ) - { // Force rebuild of all quads to clear their caches - foreach( EffectWindow *w, effects->stackingOrder() ) + // Force rebuild of all quads to clear their caches + foreach( EffectWindow *w, effects->stackingOrder() ) + if( w ) // TODO/HACK: stackingOrder() should NOT return NULL w->buildQuads( true ); - } } void ShadowEffect::updateShadowColor() @@ -208,48 +155,9 @@ void ShadowEffect::updateShadowColor() 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 )) - { - shadowDefined = true; - shadowRect |= r; - } - } - else if( w->isNormalWindow() && !forceUndecorated ) - { // No decoration on a normal window - foreach( const QRect &r, w->shadowQuads( ShadowBorderlessActive )) - { - shadowDefined = true; - shadowRect |= r; - } - } - else if( !forceOther ) - { // All other undecorated windows - foreach( const QRect &r, w->shadowQuads( ShadowOther )) - { - shadowDefined = true; - shadowRect |= r; - } - } - } - if( !shadowDefined ) - { - int shadowGrow = shadowFuzzyness + shadowSize; - return windowRectangle.adjusted( shadowXOffset - shadowGrow, shadowYOffset - shadowGrow, - shadowXOffset + shadowGrow, shadowYOffset + shadowGrow); - } - return windowRectangle.adjusted( - qMin( shadowRect.x(), qreal(0.0) ), - qMin( shadowRect.y(), qreal(0.0) ), - qMax( shadowRect.x() + shadowRect.width() - w->width(), qreal(0.0) ), - qMax( shadowRect.y() + shadowRect.height() - w->height(), qreal(0.0) ) - ); + int shadowGrow = shadowFuzzyness + shadowSize; + return windowRectangle.adjusted( shadowXOffset - shadowGrow, shadowYOffset - shadowGrow, + shadowXOffset + shadowGrow, shadowYOffset + shadowGrow); } #ifdef KWIN_HAVE_XRENDER_COMPOSITING @@ -322,163 +230,113 @@ void ShadowEffect::drawWindow( EffectWindow* w, int mask, QRegion region, Window void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList ) { - bool shadowDefined = false; - if( effects->hasDecorationShadows() ) - { - // TODO: shadowQuads() is allowed to return different quads for - // active and inactive shadows. Is implementing it worth - // the performance drop? - int id = 0; - if( w->hasDecoration() && !forceDecorated ) - { // Decorated windows must be normal windows - foreach( const QRect &r, w->shadowQuads( ShadowBorderedActive )) - { - shadowDefined = true; - WindowQuad quad( mShadowQuadTypes.at( effects->shadowTextureList( ShadowBorderedActive )), id++ ); - quad[ 0 ] = WindowVertex( r.x(), r.y(), 0, 1 ); - quad[ 1 ] = WindowVertex( r.x() + r.width(), r.y(), 1, 1 ); - quad[ 2 ] = WindowVertex( r.x() + r.width(), r.y() + r.height(), 1, 0 ); - quad[ 3 ] = WindowVertex( r.x(), r.y() + r.height(), 0, 0 ); - quadList.append( quad ); - } - } - else if( w->isNormalWindow() && !forceUndecorated ) - { // No decoration on a normal window - foreach( const QRect &r, w->shadowQuads( ShadowBorderlessActive )) - { - shadowDefined = true; - WindowQuad quad( mShadowQuadTypes.at( effects->shadowTextureList( ShadowBorderlessActive )), id++ ); - quad[ 0 ] = WindowVertex( r.x(), r.y(), 0, 1 ); - quad[ 1 ] = WindowVertex( r.x() + r.width(), r.y(), 1, 1 ); - quad[ 2 ] = WindowVertex( r.x() + r.width(), r.y() + r.height(), 1, 0 ); - quad[ 3 ] = WindowVertex( r.x(), r.y() + r.height(), 0, 0 ); - quadList.append( quad ); - } - } - else if( !forceOther ) - { // All other undecorated windows - foreach( const QRect &r, w->shadowQuads( ShadowOther )) - { - shadowDefined = true; - WindowQuad quad( mShadowQuadTypes.at( effects->shadowTextureList( ShadowOther )), id++ ); - quad[ 0 ] = WindowVertex( r.x(), r.y(), 0, 1 ); - quad[ 1 ] = WindowVertex( r.x() + r.width(), r.y(), 1, 1 ); - quad[ 2 ] = WindowVertex( r.x() + r.width(), r.y() + r.height(), 1, 0 ); - quad[ 3 ] = WindowVertex( r.x(), r.y() + r.height(), 0, 0 ); - quadList.append( quad ); - } - } - } - if( !shadowDefined ) - { - //TODO: add config option to not have shadows for menus, etc. - // Make our own shadow as the decoration doesn't support it - int fuzzy = shadowFuzzyness; - // Shadow's size must be a least 2*fuzzy in both directions (or the corners will be broken) - int width = qMax( fuzzy * 2, w->width() + 2 * shadowSize ); - int height = qMax( fuzzy * 2, w->height() + 2 * shadowSize ); - double x1, y1, x2, y2; - int id = 0; - // top-left - x1 = shadowXOffset - shadowSize + 0 - fuzzy; - y1 = shadowYOffset - shadowSize + 0 - fuzzy; - x2 = shadowXOffset - shadowSize + 0 + fuzzy; - y2 = shadowYOffset - shadowSize + 0 + fuzzy; - WindowQuad topLeftQuad( mDefaultShadowQuadType, id++ ); - topLeftQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); - topLeftQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); - topLeftQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); - topLeftQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); - quadList.append( topLeftQuad ); - // top - x1 = shadowXOffset - shadowSize + 0 + fuzzy; - y1 = shadowYOffset - shadowSize + 0 - fuzzy; - x2 = shadowXOffset - shadowSize + width - fuzzy; - y2 = shadowYOffset - shadowSize + 0 + fuzzy; - WindowQuad topQuad( mDefaultShadowQuadType, id++ ); - topQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); - topQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); - topQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); - topQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); - quadList.append( topQuad ); - // top-right - x1 = shadowXOffset - shadowSize + width - fuzzy; - y1 = shadowYOffset - shadowSize + 0 - fuzzy; - x2 = shadowXOffset - shadowSize + width + fuzzy; - y2 = shadowYOffset - shadowSize + 0 + fuzzy; - WindowQuad topRightQuad( mDefaultShadowQuadType, id++ ); - topRightQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); - topRightQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); - topRightQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); - topRightQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); - quadList.append( topRightQuad ); - // left - x1 = shadowXOffset - shadowSize + 0 - fuzzy; - y1 = shadowYOffset - shadowSize + 0 + fuzzy; - x2 = shadowXOffset - shadowSize + 0 + fuzzy; - y2 = shadowYOffset - shadowSize + height - fuzzy; - WindowQuad leftQuad( mDefaultShadowQuadType, id++ ); - leftQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); - leftQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); - leftQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); - leftQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); - quadList.append( leftQuad ); - // center - x1 = shadowXOffset - shadowSize + 0 + fuzzy; - y1 = shadowYOffset - shadowSize + 0 + fuzzy; - x2 = shadowXOffset - shadowSize + width - fuzzy; - y2 = shadowYOffset - shadowSize + height - fuzzy; - WindowQuad contentsQuad( mDefaultShadowQuadType, id++ ); - contentsQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); - contentsQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); - contentsQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); - contentsQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); - quadList.append( contentsQuad ); - // right - x1 = shadowXOffset - shadowSize + width - fuzzy; - y1 = shadowYOffset - shadowSize + 0 + fuzzy; - x2 = shadowXOffset - shadowSize + width + fuzzy; - y2 = shadowYOffset - shadowSize + height - fuzzy; - WindowQuad rightQuad( mDefaultShadowQuadType, id++ ); - rightQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); - rightQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); - rightQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); - rightQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); - quadList.append( rightQuad ); - // bottom-left - x1 = shadowXOffset - shadowSize + 0 - fuzzy; - y1 = shadowYOffset - shadowSize + height - fuzzy; - x2 = shadowXOffset - shadowSize + 0 + fuzzy; - y2 = shadowYOffset - shadowSize + height + fuzzy; - WindowQuad bottomLeftQuad( mDefaultShadowQuadType, id++ ); - bottomLeftQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); - bottomLeftQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); - bottomLeftQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); - bottomLeftQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); - quadList.append( bottomLeftQuad ); - // bottom - x1 = shadowXOffset - shadowSize + 0 + fuzzy; - y1 = shadowYOffset - shadowSize + height - fuzzy; - x2 = shadowXOffset - shadowSize + width - fuzzy; - y2 = shadowYOffset - shadowSize + height + fuzzy; - WindowQuad bottomQuad( mDefaultShadowQuadType, id++ ); - bottomQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); - bottomQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); - bottomQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); - bottomQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); - quadList.append( bottomQuad ); - // bottom-right - x1 = shadowXOffset - shadowSize + width - fuzzy; - y1 = shadowYOffset - shadowSize + height - fuzzy; - x2 = shadowXOffset - shadowSize + width + fuzzy; - y2 = shadowYOffset - shadowSize + height + fuzzy; - WindowQuad bottomRightQuad( mDefaultShadowQuadType, id++ ); - bottomRightQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); - bottomRightQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); - bottomRightQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); - bottomRightQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); - quadList.append( bottomRightQuad ); - } // This is called for menus, tooltips, windows where the user has disabled borders and shaped windows + // TODO: add config option to not have shadows for menus, etc. + // Make our own shadow as the decoration doesn't support it + int fuzzy = shadowFuzzyness; + // Shadow's size must be a least 2*fuzzy in both directions (or the corners will be broken) + int width = qMax( fuzzy * 2, w->width() + 2 * shadowSize ); + int height = qMax( fuzzy * 2, w->height() + 2 * shadowSize ); + double x1, y1, x2, y2; + int id = 0; + // top-left + x1 = shadowXOffset - shadowSize + 0 - fuzzy; + y1 = shadowYOffset - shadowSize + 0 - fuzzy; + x2 = shadowXOffset - shadowSize + 0 + fuzzy; + y2 = shadowYOffset - shadowSize + 0 + fuzzy; + WindowQuad topLeftQuad( mDefaultShadowQuadType, id++ ); + topLeftQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); + topLeftQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); + topLeftQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); + topLeftQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); + quadList.append( topLeftQuad ); + // top + x1 = shadowXOffset - shadowSize + 0 + fuzzy; + y1 = shadowYOffset - shadowSize + 0 - fuzzy; + x2 = shadowXOffset - shadowSize + width - fuzzy; + y2 = shadowYOffset - shadowSize + 0 + fuzzy; + WindowQuad topQuad( mDefaultShadowQuadType, id++ ); + topQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); + topQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); + topQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); + topQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); + quadList.append( topQuad ); + // top-right + x1 = shadowXOffset - shadowSize + width - fuzzy; + y1 = shadowYOffset - shadowSize + 0 - fuzzy; + x2 = shadowXOffset - shadowSize + width + fuzzy; + y2 = shadowYOffset - shadowSize + 0 + fuzzy; + WindowQuad topRightQuad( mDefaultShadowQuadType, id++ ); + topRightQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); + topRightQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); + topRightQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); + topRightQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); + quadList.append( topRightQuad ); + // left + x1 = shadowXOffset - shadowSize + 0 - fuzzy; + y1 = shadowYOffset - shadowSize + 0 + fuzzy; + x2 = shadowXOffset - shadowSize + 0 + fuzzy; + y2 = shadowYOffset - shadowSize + height - fuzzy; + WindowQuad leftQuad( mDefaultShadowQuadType, id++ ); + leftQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); + leftQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); + leftQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); + leftQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); + quadList.append( leftQuad ); + // center + x1 = shadowXOffset - shadowSize + 0 + fuzzy; + y1 = shadowYOffset - shadowSize + 0 + fuzzy; + x2 = shadowXOffset - shadowSize + width - fuzzy; + y2 = shadowYOffset - shadowSize + height - fuzzy; + WindowQuad contentsQuad( mDefaultShadowQuadType, id++ ); + contentsQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); + contentsQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); + contentsQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); + contentsQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); + quadList.append( contentsQuad ); + // right + x1 = shadowXOffset - shadowSize + width - fuzzy; + y1 = shadowYOffset - shadowSize + 0 + fuzzy; + x2 = shadowXOffset - shadowSize + width + fuzzy; + y2 = shadowYOffset - shadowSize + height - fuzzy; + WindowQuad rightQuad( mDefaultShadowQuadType, id++ ); + rightQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); + rightQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); + rightQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); + rightQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); + quadList.append( rightQuad ); + // bottom-left + x1 = shadowXOffset - shadowSize + 0 - fuzzy; + y1 = shadowYOffset - shadowSize + height - fuzzy; + x2 = shadowXOffset - shadowSize + 0 + fuzzy; + y2 = shadowYOffset - shadowSize + height + fuzzy; + WindowQuad bottomLeftQuad( mDefaultShadowQuadType, id++ ); + bottomLeftQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); + bottomLeftQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); + bottomLeftQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); + bottomLeftQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); + quadList.append( bottomLeftQuad ); + // bottom + x1 = shadowXOffset - shadowSize + 0 + fuzzy; + y1 = shadowYOffset - shadowSize + height - fuzzy; + x2 = shadowXOffset - shadowSize + width - fuzzy; + y2 = shadowYOffset - shadowSize + height + fuzzy; + WindowQuad bottomQuad( mDefaultShadowQuadType, id++ ); + bottomQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); + bottomQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); + bottomQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); + bottomQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); + quadList.append( bottomQuad ); + // bottom-right + x1 = shadowXOffset - shadowSize + width - fuzzy; + y1 = shadowYOffset - shadowSize + height - fuzzy; + x2 = shadowXOffset - shadowSize + width + fuzzy; + y2 = shadowYOffset - shadowSize + height + fuzzy; + WindowQuad bottomRightQuad( mDefaultShadowQuadType, id++ ); + bottomRightQuad[ 0 ] = WindowVertex( x1, y1, 0, 1 ); + bottomRightQuad[ 1 ] = WindowVertex( x2, y1, 1, 1 ); + bottomRightQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); + bottomRightQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); + quadList.append( bottomRightQuad ); effects->buildQuads( w, quadList ); } @@ -500,7 +358,9 @@ bool ShadowEffect::useShadow( EffectWindow* w ) const { return !w->isDeleted() && !w->isDesktop() && !w->isDock() // popups may have shadow even if shaped, their shape is almost rectangular - && ( !w->hasOwnShape() || w->isDropdownMenu() || w->isPopupMenu() || w->isComboBox()); + && ( !w->hasOwnShape() || w->isDropdownMenu() || w->isPopupMenu() || w->isComboBox()) + // If decoration has it's own shadow leave it alone + && !( w->hasDecoration() && effects->hasDecorationShadows() ); } void ShadowEffect::addQuadVertices(QVector& verts, float x1, float y1, float x2, float y2) const @@ -761,7 +621,7 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c foreach( const WindowQuad &quad, data.quads ) { - if( !mShadowQuadTypes.contains( quad.type() ) && quad.type() != mDefaultShadowQuadType ) + if( quad.type() != mDefaultShadowQuadType ) continue; // Not a shadow quad glPushMatrix(); @@ -812,79 +672,16 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c texcoords << quad[3].textureX() << quad[3].textureY(); // Work out which texture to use - int texture = mShadowQuadTypes.indexOf( quad.type() ); - if( texture != -1 && texture < mShadowTextures.size() ) // TODO: Needed? - { - // Render it! - // Cheat a little, assume the active and inactive shadows have identical quads - if( effects->hasDecorationShadows() ) - { - if( window->hasDecoration() && - effects->shadowTextureList( ShadowBorderedActive ) == texture ) - { // Decorated windows - // Active shadow - drawShadowQuadOpenGL( mShadowTextures.at( texture ).at( quad.id() ), - verts, texcoords, region, - data.opacity * window->shadowOpacity( ShadowBorderedActive ), - data.brightness * window->shadowBrightness( ShadowBorderedActive ), - data.saturation * window->shadowSaturation( ShadowBorderedActive ), - data.shader); + float opacity = shadowOpacity; + if( intensifyActiveShadow && window == effects->activeWindow() ) + opacity = 1 - ( 1 - shadowOpacity ) * ( 1 - shadowOpacity ); - // Inactive shadow - texture = effects->shadowTextureList( ShadowBorderedInactive ); - drawShadowQuadOpenGL( mShadowTextures.at( texture ).at( quad.id() ), - verts, texcoords, region, - data.opacity * window->shadowOpacity( ShadowBorderedInactive ), - data.brightness * window->shadowBrightness( ShadowBorderedInactive ), - data.saturation * window->shadowSaturation( ShadowBorderedInactive ), - data.shader); - } - else if( effects->shadowTextureList( ShadowBorderlessActive ) == texture ) - { // Decoration-less normal windows - if( effects->activeWindow() == window ) - { - drawShadowQuadOpenGL( mShadowTextures.at( texture ).at( quad.id() ), - verts, texcoords, region, - data.opacity * window->shadowOpacity( ShadowBorderlessActive ), - data.brightness * window->shadowBrightness( ShadowBorderlessActive ), - data.saturation * window->shadowSaturation( ShadowBorderlessActive ), - data.shader); - } - else - { - texture = effects->shadowTextureList( ShadowBorderlessInactive ); - drawShadowQuadOpenGL( mShadowTextures.at( texture ).at( quad.id() ), - verts, texcoords, region, - data.opacity * window->shadowOpacity( ShadowBorderlessInactive ), - data.brightness * window->shadowBrightness( ShadowBorderlessInactive ), - data.saturation * window->shadowSaturation( ShadowBorderlessInactive ), - data.shader); - } - } - else - { // Other windows - drawShadowQuadOpenGL( mShadowTextures.at( texture ).at( quad.id() ), - verts, texcoords, region, - data.opacity * window->shadowOpacity( ShadowOther ), - data.brightness * window->shadowBrightness( ShadowOther ), - data.saturation * window->shadowSaturation( ShadowOther ), - data.shader); - } - } - } - if( quad.type() == mDefaultShadowQuadType ) - { // Default shadow - float opacity = shadowOpacity; - if( intensifyActiveShadow && window == effects->activeWindow() ) - opacity = 1 - ( 1 - shadowOpacity ) * ( 1 - shadowOpacity ); - - drawShadowQuadOpenGL( mDefaultShadowTextures.at( quad.id() ), - verts, texcoords, region, - data.opacity * opacity, - data.brightness, - data.saturation, - data.shader); - } + drawShadowQuadOpenGL( mDefaultShadowTextures.at( quad.id() ), + verts, texcoords, region, + data.opacity * opacity, + data.brightness, + data.saturation, + data.shader); glPopMatrix(); } @@ -899,7 +696,7 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c foreach( const WindowQuad &quad, data.quads ) { - if( !mShadowQuadTypes.contains( quad.type() ) && quad.type() != mDefaultShadowQuadType ) + if( quad.type() != mDefaultShadowQuadType ) continue; // Not a shadow quad // Determine transformed quad position @@ -929,70 +726,12 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c ( quad[2].y() - quad[0].y() ) * yScale ); // Work out which texture to use - int texture = mShadowQuadTypes.indexOf( quad.type() ); - if( texture != -1 ) - { - // Render it! - // Cheat a little, assume the active and inactive shadows have identical quads - if( effects->hasDecorationShadows() ) - { - if( window->hasDecoration() && - effects->shadowTextureList( ShadowBorderedActive ) == texture ) - { // Decorated windows - // Active shadow - drawShadowQuadXRender( mShadowPics.at( texture ).at( quad.id() ), quadRect, - xScale, yScale, QColor(), - data.opacity * window->shadowOpacity( ShadowBorderedActive ), - data.brightness * window->shadowBrightness( ShadowBorderedActive ), - data.saturation * window->shadowSaturation( ShadowBorderedActive )); + float opacity = shadowOpacity; + if( intensifyActiveShadow && window == effects->activeWindow() ) + opacity = 1 - ( 1 - shadowOpacity ) * ( 1 - shadowOpacity ); - // Inactive shadow - texture = effects->shadowTextureList( ShadowBorderedInactive ); - drawShadowQuadXRender( mShadowPics.at( texture ).at( quad.id() ), quadRect, - xScale, yScale, QColor(), - data.opacity * window->shadowOpacity( ShadowBorderedInactive ), - data.brightness * window->shadowBrightness( ShadowBorderedInactive ), - data.saturation * window->shadowSaturation( ShadowBorderedInactive )); - } - else if( effects->shadowTextureList( ShadowBorderlessActive ) == texture ) - { // Decoration-less normal windows - if( effects->activeWindow() == window ) - { // Active shadow - drawShadowQuadXRender( mShadowPics.at( texture ).at( quad.id() ), quadRect, - xScale, yScale, QColor(), - data.opacity * window->shadowOpacity( ShadowBorderlessActive ), - data.brightness * window->shadowBrightness( ShadowBorderlessActive ), - data.saturation * window->shadowSaturation( ShadowBorderlessActive )); - } - else - { // Inactive shadow - texture = effects->shadowTextureList( ShadowBorderedInactive ); - drawShadowQuadXRender( mShadowPics.at( texture ).at( quad.id() ), quadRect, - xScale, yScale, QColor(), - data.opacity * window->shadowOpacity( ShadowBorderlessInactive ), - data.brightness * window->shadowBrightness( ShadowBorderlessInactive ), - data.saturation * window->shadowSaturation( ShadowBorderlessInactive )); - } - } - else - { // Other windows - drawShadowQuadXRender( mShadowPics.at( texture ).at( quad.id() ), quadRect, - xScale, yScale, QColor(), - data.opacity * window->shadowOpacity( ShadowOther ), - data.brightness * window->shadowBrightness( ShadowOther ), - data.saturation * window->shadowSaturation( ShadowOther )); - } - } - } - if( quad.type() == mDefaultShadowQuadType ) - { // Default shadow - float opacity = shadowOpacity; - if( intensifyActiveShadow && window == effects->activeWindow() ) - opacity = 1 - ( 1 - shadowOpacity ) * ( 1 - shadowOpacity ); - - drawShadowQuadXRender( mDefaultShadowPics.at( quad.id() ), quadRect, xScale, yScale, - shadowColor, opacity * data.opacity, data.brightness, data.saturation ); - } + drawShadowQuadXRender( mDefaultShadowPics.at( quad.id() ), quadRect, xScale, yScale, + shadowColor, opacity * data.opacity, data.brightness, data.saturation ); } } #endif diff --git a/effects/shadow/shadow.h b/effects/shadow/shadow.h index 205c720f04..bf7a7d7c2d 100644 --- a/effects/shadow/shadow.h +++ b/effects/shadow/shadow.h @@ -71,20 +71,14 @@ class ShadowEffect int shadowSize; bool intensifyActiveShadow; QColor shadowColor, cachedColor; - bool forceDecorated; - bool forceUndecorated; - bool forceOther; #ifdef KWIN_HAVE_OPENGL_COMPOSITING - QList< QList > mShadowTextures; QList mDefaultShadowTextures; #endif #ifdef KWIN_HAVE_XRENDER_COMPOSITING - QList< QList > mShadowPics; QList mDefaultShadowPics; XRenderPicture cachedBlendPicture; #endif - QList mShadowQuadTypes; WindowQuadType mDefaultShadowQuadType; struct ShadowData diff --git a/effects/shadow/shadow_config.cpp b/effects/shadow/shadow_config.cpp index b75d2d05e7..5d4f834a07 100644 --- a/effects/shadow/shadow_config.cpp +++ b/effects/shadow/shadow_config.cpp @@ -56,10 +56,6 @@ ShadowEffectConfig::ShadowEffectConfig(QWidget* parent, const QVariantList& args connect( m_ui->colorButton, SIGNAL( changed( QColor )), this, SLOT( changed() )); connect( m_ui->strongerActiveBox, SIGNAL( stateChanged( int )), this, SLOT( changed() )); - connect( m_ui->forceDecoratedBox, SIGNAL( stateChanged( int )), this, SLOT( changed() )); - connect( m_ui->forceUndecoratedBox, SIGNAL( stateChanged( int )), this, SLOT( changed() )); - connect( m_ui->forceOtherBox, SIGNAL( stateChanged( int )), this, SLOT( changed() )); - load(); } @@ -81,10 +77,6 @@ void ShadowEffectConfig::load() m_ui->colorButton->setColor( conf.readEntry( "Color", schemeShadowColor() )); m_ui->strongerActiveBox->setChecked( conf.readEntry( "IntensifyActiveShadow", true )); - m_ui->forceDecoratedBox->setChecked( conf.readEntry( "forceDecoratedToDefault", false )); - m_ui->forceUndecoratedBox->setChecked( conf.readEntry( "forceUndecoratedToDefault", false )); - m_ui->forceOtherBox->setChecked( conf.readEntry( "forceOtherToDefault", false )); - emit changed(false); } @@ -108,10 +100,6 @@ void ShadowEffectConfig::save() conf.writeEntry( "Color", userColor ); conf.writeEntry( "IntensifyActiveShadow", m_ui->strongerActiveBox->isChecked() ); - conf.writeEntry( "forceDecoratedToDefault", m_ui->forceDecoratedBox->isChecked() ); - conf.writeEntry( "forceUndecoratedToDefault", m_ui->forceUndecoratedBox->isChecked() ); - conf.writeEntry( "forceOtherToDefault", m_ui->forceOtherBox->isChecked() ); - conf.sync(); emit changed(false); @@ -132,10 +120,6 @@ void ShadowEffectConfig::defaults() m_ui->colorButton->setColor( schemeShadowColor() ); m_ui->strongerActiveBox->setChecked( true ); - m_ui->forceDecoratedBox->setChecked( false ); - m_ui->forceUndecoratedBox->setChecked( false ); - m_ui->forceOtherBox->setChecked( false ); - emit changed(true); } diff --git a/effects/shadow/shadow_config.ui b/effects/shadow/shadow_config.ui index 459a24dded..6e1f74ab1e 100644 --- a/effects/shadow/shadow_config.ui +++ b/effects/shadow/shadow_config.ui @@ -1,313 +1,242 @@ - + + KWin::ShadowEffectConfigForm - - + + 0 0 - 521 - 267 + 292 + 219 - - - - - Default Shadow + + + + + &X offset: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + xOffsetSpin - - - - - &X offset: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - xOffsetSpin - - - - - - - &Active windows have stronger shadows - - - - - - - &Y offset: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - yOffsetSpin - - - - - - - - 0 - 0 - - - - - - - - - - -100 - - - 100 - - - 1 - - - 0 - - - - - - - &Opacity: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - opacitySpin - - - - - - - - 0 - 0 - - - - - - - % - - - 0 - - - 100 - - - 1 - - - 0 - - - - - - - &Fuzziness: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - fuzzinessSpin - - - - - - - &Size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - sizeSpin - - - - - - - - 0 - 0 - - - - - - - - - - 0 - - - 100 - - - 1 - - - 0 - - - - - - - - 0 - 0 - - - - - - - - - - 0 - - - 100 - - - 1 - - - 0 - - - - - - - - 0 - 0 - - - - - - - - - - -100 - - - 100 - - - 1 - - - 0 - - - - - - - - - - &Color: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - colorButton - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - Decoration Shadows + + + + + 0 + 0 + + + + + + + + + + -100 + + + 100 + + + 1 + + + 0 + + + + + + + &Y offset: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + yOffsetSpin + + + + + + + + 0 + 0 + + + + + + + + + + -100 + + + 100 + + + 1 + + + 0 + + + + + + + &Opacity: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + opacitySpin + + + + + + + + 0 + 0 + + + + + + + % + + + 0 + + + 100 + + + 1 + + + 0 + + + + + + + &Fuzziness: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + fuzzinessSpin + + + + + + + + 0 + 0 + + + + + + + + + + 0 + + + 100 + + + 1 + + + 0 + + + + + + + &Size: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + sizeSpin + + + + + + + + 0 + 0 + + + + + + + + + + 0 + + + 100 + + + 1 + + + 0 + + + + + + + &Color: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + colorButton + + + + + + + + + + &Active windows have stronger shadows - - - - - &Decorated windows - - - - - - - Force default shadows for: - - - - - - - &Undecorated normal windows - - - - - - - All &other windows - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - @@ -319,18 +248,6 @@
kcolorbutton.h
- - xOffsetSpin - yOffsetSpin - opacitySpin - fuzzinessSpin - sizeSpin - colorButton - strongerActiveBox - forceDecoratedBox - forceUndecoratedBox - forceOtherBox -
diff --git a/lib/kcommondecoration.cpp b/lib/kcommondecoration.cpp index b275686b2d..fa4a7cc54d 100644 --- a/lib/kcommondecoration.cpp +++ b/lib/kcommondecoration.cpp @@ -1249,46 +1249,10 @@ KCommonDecorationUnstable::~KCommonDecorationUnstable() } // All copied from kdecoration.cpp -QList KCommonDecorationUnstable::shadowQuads( ShadowType type ) const - { - Q_UNUSED( type ); - return QList(); - } -double KCommonDecorationUnstable::shadowOpacity( ShadowType type ) const - { - if( isActive() && type == ShadowBorderedActive ) - return 1.0; - else if( !isActive() && type == ShadowBorderedInactive ) - return 1.0; - return 0.0; - } -double KCommonDecorationUnstable::shadowBrightness( ShadowType type ) const - { - Q_UNUSED( type ); - return 1.0; - } -double KCommonDecorationUnstable::shadowSaturation( ShadowType type ) const - { - Q_UNUSED( type ); - return 1.0; - } - -void KCommonDecorationUnstable::repaintShadow() - { - return static_cast( decoration() )->repaintShadow(); - } bool KCommonDecorationUnstable::compositingActive() const { return static_cast( decoration() )->compositingActive(); } -bool KCommonDecorationUnstable::shadowsActive() const - { - return static_cast( decoration() )->shadowsActive(); - } -double KCommonDecorationUnstable::opacity() const - { - return static_cast( decoration() )->opacity(); - } // kate: space-indent on; indent-width 4; mixedindent off; indent-mode cstyle; diff --git a/lib/kcommondecoration.h b/lib/kcommondecoration.h index e41a19c797..509dffa2a9 100644 --- a/lib/kcommondecoration.h +++ b/lib/kcommondecoration.h @@ -373,14 +373,8 @@ class KWIN_EXPORT KCommonDecorationUnstable public: KCommonDecorationUnstable(KDecorationBridge* bridge, KDecorationFactory* factory); virtual ~KCommonDecorationUnstable(); - virtual QList shadowQuads( ShadowType type ) const; - virtual double shadowOpacity( ShadowType type ) const; - virtual double shadowBrightness( ShadowType type ) const; - virtual double shadowSaturation( ShadowType type ) const; - void repaintShadow(); bool compositingActive() const; bool shadowsActive() const; - double opacity() const; }; /** diff --git a/lib/kcommondecoration_p.cpp b/lib/kcommondecoration_p.cpp index cc55040d1d..27902aa4eb 100644 --- a/lib/kcommondecoration_p.cpp +++ b/lib/kcommondecoration_p.cpp @@ -113,34 +113,6 @@ void KCommonDecorationWrapper::reset( unsigned long changed ) return decoration->reset( changed ); } -QList KCommonDecorationWrapper::shadowQuads( ShadowType type ) const - { - if( KCommonDecorationUnstable *decoration2 = dynamic_cast( decoration )) - return decoration2->shadowQuads( type ); - return QList(); - } - -double KCommonDecorationWrapper::shadowOpacity( ShadowType type ) const - { - if( KCommonDecorationUnstable *decoration2 = dynamic_cast( decoration )) - return decoration2->shadowOpacity( type ); - return 1.0; - } - -double KCommonDecorationWrapper::shadowBrightness( ShadowType type ) const - { - if( KCommonDecorationUnstable *decoration2 = dynamic_cast( decoration )) - return decoration2->shadowBrightness( type ); - return 1.0; - } - -double KCommonDecorationWrapper::shadowSaturation( ShadowType type ) const - { - if( KCommonDecorationUnstable *decoration2 = dynamic_cast( decoration )) - return decoration2->shadowSaturation( type ); - return 1.0; - } - void KCommonDecorationWrapper::padding(int &left, int &right, int &top, int &bottom) const { left = decoration->layoutMetric(KCommonDecoration::LM_OuterPaddingLeft); diff --git a/lib/kcommondecoration_p.h b/lib/kcommondecoration_p.h index 5bd1954759..ffcf1a83da 100644 --- a/lib/kcommondecoration_p.h +++ b/lib/kcommondecoration_p.h @@ -59,11 +59,6 @@ class KCommonDecorationWrapper virtual bool windowDocked( Position side ); virtual void reset( unsigned long changed ); - virtual QList shadowQuads( ShadowType type ) const; - virtual double shadowOpacity( ShadowType type ) const; - virtual double shadowBrightness( ShadowType type ) const; - virtual double shadowSaturation( ShadowType type ) const; - virtual void padding( int &left, int &right, int &top, int &bottom ) const; private: KCommonDecoration* decoration; diff --git a/lib/kdecoration.cpp b/lib/kdecoration.cpp index 610dd4b748..40ddfa4219 100644 --- a/lib/kdecoration.cpp +++ b/lib/kdecoration.cpp @@ -393,53 +393,11 @@ KDecorationUnstable::~KDecorationUnstable() { } -QList KDecorationUnstable::shadowQuads( ShadowType type ) const - { - Q_UNUSED( type ); - return QList(); - } - -double KDecorationUnstable::shadowOpacity( ShadowType type ) const - { - if( isActive() && type == ShadowBorderedActive ) - return 1.0; - else if( !isActive() && type == ShadowBorderedInactive ) - return 1.0; - return 0.0; - } - -double KDecorationUnstable::shadowBrightness( ShadowType type ) const - { - Q_UNUSED( type ); - return 1.0; - } - -double KDecorationUnstable::shadowSaturation( ShadowType type ) const - { - Q_UNUSED( type ); - return 1.0; - } - -void KDecorationUnstable::repaintShadow() - { - static_cast< KDecorationBridgeUnstable* >( bridge_ )->repaintShadow(); - } - bool KDecorationUnstable::compositingActive() const { return static_cast< KDecorationBridgeUnstable* >( bridge_ )->compositingActive(); } -bool KDecorationUnstable::shadowsActive() const - { - return static_cast< KDecorationBridgeUnstable* >( bridge_ )->shadowsActive(); - } - -double KDecorationUnstable::opacity() const - { - return static_cast< KDecorationBridgeUnstable* >( bridge_ )->opacity(); - } - void KDecorationUnstable::padding(int &left, int &right, int &top, int &bottom) const { left = right = top = bottom = 0; diff --git a/lib/kdecoration.h b/lib/kdecoration.h index 7812154111..21e556dd1d 100644 --- a/lib/kdecoration.h +++ b/lib/kdecoration.h @@ -185,7 +185,8 @@ public: AbilityColorButtonFore = 2021, ///< decoration supports button foreground color ABILITYCOLOR_END, ///< @internal // compositing - AbilityCompositingShadow = 3000, ///< decoration supports window shadows + AbilityProvidesShadow = 3000, ///< The decoration draws its own shadows. + /// @since 4.3 AbilityUsesAlphaChannel = 3001, ///< The decoration isn't clipped to the mask when compositing is enabled. /// The mask is still used to define the input region and the blurred /// region, when the blur plugin is enabled. @@ -869,7 +870,7 @@ class KWIN_EXPORT KDecoration }; /** - * @warning THIS CLASS IS UNSTABLE AND WILL ONLY BE SUPPORTED IN KDE 4.2! + * @warning THIS CLASS IS UNSTABLE! */ class KWIN_EXPORT KDecorationUnstable : public KDecoration @@ -879,24 +880,6 @@ class KWIN_EXPORT KDecorationUnstable public: KDecorationUnstable( KDecorationBridge* bridge, KDecorationFactory* factory ); virtual ~KDecorationUnstable(); - /** - * This function should return the positions of the shadow quads to be rendered. - * All positions are relative to the window's top-left corner. Only "bordered" - * windows will call this method. - */ - virtual QList shadowQuads( ShadowType type ) const; - /** - * This function should return the desired opacity of the shadow. - */ - virtual double shadowOpacity( ShadowType type ) const; - /** - * This function should return the desired brightness of the shadow. - */ - virtual double shadowBrightness( ShadowType type ) const; - /** - * This function should return the desired saturation of the shadow. - */ - virtual double shadowSaturation( ShadowType type ) const; /** * This function can return additional padding values that are added outside the * borders of the window, and can be used by the decoration if it wants to paint @@ -909,23 +892,9 @@ class KWIN_EXPORT KDecorationUnstable */ virtual void padding(int &left, int &right, int &top, int &bottom) const; /** - * Force a repaint of the shadow. Automatically called when the window changes states. - */ - void repaintShadow(); - /** - * Returns @a true if compositing is enabled (Currently useless to decorations, - * use \a shadowsActive() instead). + * Returns @a true if compositing--and therefore ARGB--is enabled. */ bool compositingActive() const; - /** - * Returns @a true if compositing is enabled and the shadow effect is activated - * by the current user. - */ - bool shadowsActive() const; - /** - * Returns the opacity that the decoration will be rendered at. - */ - double opacity() const; }; inline diff --git a/lib/kdecorationbridge.h b/lib/kdecorationbridge.h index 24a9477995..89bda6e5d5 100644 --- a/lib/kdecorationbridge.h +++ b/lib/kdecorationbridge.h @@ -93,10 +93,7 @@ class KWIN_EXPORT KDecorationBridgeUnstable : public KDecorationBridge { public: - virtual void repaintShadow() = 0; virtual bool compositingActive() const = 0; - virtual bool shadowsActive() const = 0; - virtual double opacity() const = 0; }; /** @} */ diff --git a/lib/kdecorationfactory.cpp b/lib/kdecorationfactory.cpp index 90de5b233e..36ff5e7d36 100644 --- a/lib/kdecorationfactory.cpp +++ b/lib/kdecorationfactory.cpp @@ -78,39 +78,3 @@ NET::WindowType KDecorationFactory::windowType( unsigned long supported_types, K { return bridge->windowType( supported_types ); } - -QList< QList > KDecorationFactoryUnstable::shadowTextures() - { - return QList< QList >(); - } - -int KDecorationFactoryUnstable::shadowTextureList( ShadowType type ) const - { - Q_UNUSED( type ); - return -1; - } - -QList KDecorationFactoryUnstable::shadowQuads( ShadowType type, QSize size ) const - { - Q_UNUSED( type ); - Q_UNUSED( size ); - return QList(); - } - -double KDecorationFactoryUnstable::shadowOpacity( ShadowType type ) const - { - Q_UNUSED( type ); - return 1.0; - } - -double KDecorationFactoryUnstable::shadowBrightness( ShadowType type ) const - { - Q_UNUSED( type ); - return 1.0; - } - -double KDecorationFactoryUnstable::shadowSaturation( ShadowType type ) const - { - Q_UNUSED( type ); - return 1.0; - } diff --git a/lib/kdecorationfactory.h b/lib/kdecorationfactory.h index f61a0da6a8..42f502320e 100644 --- a/lib/kdecorationfactory.h +++ b/lib/kdecorationfactory.h @@ -116,42 +116,12 @@ class KWIN_EXPORT KDecorationFactory }; /** - * @warning THIS CLASS IS UNSTABLE AND WILL ONLY BE SUPPORTED IN KDE 4.2! + * @warning THIS CLASS IS UNSTABLE! + * Keep all decoration class names in sync. E.g. KDecorationFactory2 and KDecoration2. */ class KWIN_EXPORT KDecorationFactoryUnstable : public KDecorationFactory { - public: - /** - * This function should return the texture lists that contain the textures of the - * shadow quads. Textures are mapped to the quad that has the same list offset. - * E.g. texture[0][2] is rendered where the third QRect that shadowQuads() - * returns is if using the first texture list. - */ - virtual QList< QList > shadowTextures(); - /** - * This function should return the texture list offset for the requested type. - */ - virtual int shadowTextureList( ShadowType type ) const; - /** - * This function should return the positions of the shadow quads to be rendered. - * All positions are relative to the window's top-left corner. Only "borderless" - * and "other" types will call this method. - * @param size The size of the window. - */ - virtual QList shadowQuads( ShadowType type, QSize size ) const; - /** - * This function should return the desired opacity of the shadow. - */ - virtual double shadowOpacity( ShadowType type ) const; - /** - * This function should return the desired brightness of the shadow. - */ - virtual double shadowBrightness( ShadowType type ) const; - /** - * This function should return the desired saturation of the shadow. - */ - virtual double shadowSaturation( ShadowType type ) const; }; inline const KDecorationOptions* KDecorationFactory::options() diff --git a/lib/kwineffects.h b/lib/kwineffects.h index f836123492..0b45e0b06e 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -170,7 +170,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 82 +#define KWIN_EFFECT_API_VERSION_MINOR 83 #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) @@ -701,17 +701,6 @@ class KWIN_EXPORT EffectsHandler * Returns @a true if the active window decoration has shadow API hooks. */ virtual bool hasDecorationShadows() const = 0; - /** - * Returns the textures to be used in the shadow. Textures are mapped - * to the quad that has the same list offset. E.g. texture[2] is - * rendered where the third QRect that EffectWindow::shadowQuads() - * returns is. - */ - virtual QList< QList > shadowTextures() = 0; - /** - * Returns the texture list offset for the requested type. - */ - virtual int shadowTextureList( ShadowType type ) const = 0; /** * @deprecated @@ -950,23 +939,6 @@ class KWIN_EXPORT EffectWindow virtual EffectWindow* findModal() = 0; virtual EffectWindowList mainWindows() const = 0; - /** - * Returns the positions of the shadow quads to be rendered. All positions - * are relative to the window's top-left corner. - */ - virtual QList shadowQuads( ShadowType type ) const = 0; - /** - * Returns the desired opacity of the shadow. - */ - virtual double shadowOpacity( ShadowType type ) const = 0; - /** - * Returns the desired brightness of the shadow. - */ - virtual double shadowBrightness( ShadowType type ) const = 0; - /** - * Returns the desired saturation of the shadow. - */ - virtual double shadowSaturation( ShadowType type ) const = 0; /** * Returns the unmodified window quad list. Can also be used to force rebuilding. */ diff --git a/workspace.h b/workspace.h index b39b933a04..483847c809 100644 --- a/workspace.h +++ b/workspace.h @@ -367,13 +367,6 @@ class Workspace : public QObject, public KDecorationDefines bool hasDecorationShadows() const; bool decorationHasAlpha() const; - QList< QList > decorationShadowTextures(); - int decorationShadowTextureList( ShadowType type ) const; - QList decorationShadowQuads( ShadowType type, QSize size ) const; - double decorationShadowOpacity( ShadowType type ) const; - double decorationShadowBrightness( ShadowType type ) const; - double decorationShadowSaturation( ShadowType type ) const; - // D-Bus interface void cascadeDesktop(); void unclutterDesktop(); @@ -1187,7 +1180,7 @@ inline void Workspace::checkCompositeTimer() inline bool Workspace::hasDecorationShadows() const { - return mgr->factory()->supports( AbilityCompositingShadow ); + return mgr->factory()->supports( AbilityProvidesShadow ); } inline bool Workspace::decorationHasAlpha() const @@ -1195,48 +1188,6 @@ inline bool Workspace::decorationHasAlpha() const return mgr->factory()->supports( AbilityUsesAlphaChannel ); } -inline QList< QList > Workspace::decorationShadowTextures() - { - if( KDecorationFactoryUnstable* factory = dynamic_cast( mgr->factory() )) - return factory->shadowTextures(); - return QList< QList >(); - } - -inline int Workspace::decorationShadowTextureList( ShadowType type ) const - { - if( KDecorationFactoryUnstable* factory = dynamic_cast( mgr->factory() )) - return factory->shadowTextureList( type ); - return -1; - } - -inline QList Workspace::decorationShadowQuads( ShadowType type, QSize size ) const - { - if( KDecorationFactoryUnstable* factory = dynamic_cast( mgr->factory() )) - return factory->shadowQuads( type, size ); - return QList(); - } - -inline double Workspace::decorationShadowOpacity( ShadowType type ) const - { - if( KDecorationFactoryUnstable* factory = dynamic_cast( mgr->factory() )) - return factory->shadowOpacity( type ); - return 1.0; - } - -inline double Workspace::decorationShadowBrightness( ShadowType type ) const - { - if( KDecorationFactoryUnstable* factory = dynamic_cast( mgr->factory() )) - return factory->shadowBrightness( type ); - return 1.0; - } - -inline double Workspace::decorationShadowSaturation( ShadowType type ) const - { - if( KDecorationFactoryUnstable* factory = dynamic_cast< KDecorationFactoryUnstable*>( mgr->factory() )) - return factory->shadowSaturation( type ); - return 1.0; - } - } // namespace #endif