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
icc-effect-5.14.5
Lucas Murray 2009-06-11 08:11:13 +00:00
parent b52b5c0ffb
commit 8d09ed341a
22 changed files with 371 additions and 1151 deletions

View File

@ -203,32 +203,9 @@ void Bridge::grabXServer( bool grab )
KWin::ungrabXServer(); KWin::ungrabXServer();
} }
void Bridge::repaintShadow()
{
// TODO
}
bool Bridge::compositingActive() const bool Bridge::compositingActive() const
{ {
return c->workspace()->compositingActive(); return c->workspace()->compositingActive();
} }
bool Bridge::shadowsActive() const
{
if( !c->workspace()->compositingActive() )
return false;
if( effects && static_cast<EffectsHandlerImpl*>( effects )->isEffectLoaded( "kwin4_effect_shadow" ))
{ // The shadow effect has a setting to disable decoration shadows, take it into account.
KConfigGroup conf = static_cast<EffectsHandlerImpl*>( effects )->effectConfig( "Shadow" );
return !conf.readEntry( "forceDecoratedToDefault", false );
}
return false;
}
double Bridge::opacity() const
{
return c->opacity();
}
} // namespace } // namespace

View File

@ -75,10 +75,7 @@ class Bridge : public KDecorationBridgeUnstable
virtual Qt::WFlags initialWFlags() const; virtual Qt::WFlags initialWFlags() const;
virtual void grabXServer( bool grab ); virtual void grabXServer( bool grab );
virtual void repaintShadow();
virtual bool compositingActive() const; virtual bool compositingActive() const;
virtual bool shadowsActive() const;
virtual double opacity() const;
private: private:
Client* c; Client* c;
}; };

View File

@ -300,11 +300,6 @@ class Client
} }
// Decorations <-> Effects // Decorations <-> Effects
QList<QRect> 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 *topDecoPixmap() const { return &decorationPixmapTop; }
const QPixmap *leftDecoPixmap() const { return &decorationPixmapLeft; } const QPixmap *leftDecoPixmap() const { return &decorationPixmapLeft; }
const QPixmap *bottomDecoPixmap() const { return &decorationPixmapBottom; } const QPixmap *bottomDecoPixmap() const { return &decorationPixmapBottom; }
@ -847,34 +842,6 @@ inline bool Client::hiddenPreview() const
return mapping_state == Kept; return mapping_state == Kept;
} }
inline QList<QRect> Client::shadowQuads( ShadowType type ) const
{
if( KDecorationUnstable* decoration2 = dynamic_cast< KDecorationUnstable* >( decoration ))
return decoration2->shadowQuads( type );
return QList<QRect>();
}
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 ); KWIN_COMPARE_PREDICATE( WrapperIdMatchPredicate, Client, Window, cl->wrapperId() == value );
} // namespace } // namespace

View File

@ -202,7 +202,7 @@ bool OxygenFactory::supports( Ability ability ) const
case AbilityButtonSpacer: case AbilityButtonSpacer:
case AbilityButtonShade: case AbilityButtonShade:
// compositing // compositing
case AbilityCompositingShadow: // TODO: UI option to use default shadows instead case AbilityProvidesShadow: // TODO: UI option to use default shadows instead
case AbilityUsesAlphaChannel: case AbilityUsesAlphaChannel:
return true; return true;
// no colors supported at this time // no colors supported at this time

View File

@ -208,7 +208,7 @@ bool OxygenFactory::supports( Ability ability ) const
case AbilityButtonSpacer: case AbilityButtonSpacer:
case AbilityButtonShade: case AbilityButtonShade:
// compositing // compositing
case AbilityCompositingShadow: // TODO: UI option to use default shadows instead case AbilityProvidesShadow: // TODO: UI option to use default shadows instead
case AbilityUsesAlphaChannel: case AbilityUsesAlphaChannel:
return true; return true;
// no colors supported at this time // no colors supported at this time

View File

@ -192,16 +192,6 @@ bool EffectsHandlerImpl::hasDecorationShadows() const
return Workspace::self()->hasDecorationShadows(); return Workspace::self()->hasDecorationShadows();
} }
QList< QList<QImage> > EffectsHandlerImpl::shadowTextures()
{
return Workspace::self()->decorationShadowTextures();
}
int EffectsHandlerImpl::shadowTextureList( ShadowType type ) const
{
return Workspace::self()->decorationShadowTextureList( type );
}
// start another painting pass // start another painting pass
void EffectsHandlerImpl::startPaint() void EffectsHandlerImpl::startPaint()
{ {
@ -1445,50 +1435,6 @@ EffectWindowList EffectWindowImpl::mainWindows() const
return EffectWindowList(); return EffectWindowList();
} }
QList<QRect> EffectWindowImpl::shadowQuads( ShadowType type ) const
{
if( type == ShadowBorderedActive || type == ShadowBorderedInactive )
{
if( Client* c = dynamic_cast< Client* >( toplevel ))
return c->shadowQuads( type );
return QList<QRect>();
}
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 WindowQuadList EffectWindowImpl::buildQuads( bool force ) const
{ {
return sceneWindow()->buildQuads( force ); return sceneWindow()->buildQuads( force );

View File

@ -134,8 +134,6 @@ class EffectsHandlerImpl : public EffectsHandler
virtual void registerPropertyType( long atom, bool reg ); virtual void registerPropertyType( long atom, bool reg );
virtual bool hasDecorationShadows() const; virtual bool hasDecorationShadows() const;
virtual QList< QList<QImage> > shadowTextures();
virtual int shadowTextureList( ShadowType type ) const;
// internal (used by kwin core or compositing code) // internal (used by kwin core or compositing code)
void startPaint(); void startPaint();
@ -256,11 +254,6 @@ class EffectWindowImpl : public EffectWindow
virtual EffectWindow* findModal(); virtual EffectWindow* findModal();
virtual EffectWindowList mainWindows() const; virtual EffectWindowList mainWindows() const;
virtual QList<QRect> 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; virtual WindowQuadList buildQuads( bool force = false ) const;
const Toplevel* window() const; const Toplevel* window() const;

View File

@ -50,16 +50,10 @@ ShadowEffect::ShadowEffect()
ShadowEffect::~ShadowEffect() ShadowEffect::~ShadowEffect()
{ {
#ifdef KWIN_HAVE_OPENGL_COMPOSITING #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++ ) for( int i = 0; i < mDefaultShadowTextures.size(); i++ )
delete mDefaultShadowTextures.at( i ); delete mDefaultShadowTextures.at( i );
#endif #endif
#ifdef KWIN_HAVE_XRENDER_COMPOSITING #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++ ) for( int i = 0; i < mDefaultShadowPics.size(); i++ )
delete mDefaultShadowPics.at( i ); delete mDefaultShadowPics.at( i );
#endif #endif
@ -75,41 +69,16 @@ void ShadowEffect::reconfigure( ReconfigureFlags )
shadowSize = conf.readEntry( "Size", 5 ); shadowSize = conf.readEntry( "Size", 5 );
intensifyActiveShadow = conf.readEntry( "IntensifyActiveShadow", true ); intensifyActiveShadow = conf.readEntry( "IntensifyActiveShadow", true );
updateShadowColor(); updateShadowColor();
forceDecorated = conf.readEntry( "forceDecoratedToDefault", false );
forceUndecorated = conf.readEntry( "forceUndecoratedToDefault", false );
forceOther = conf.readEntry( "forceOtherToDefault", false );
// Load decoration shadow related things // Load decoration shadow related things
bool reconfiguring = false;
if( mShadowQuadTypes.count() )
reconfiguring = true;
mShadowQuadTypes.clear(); // Changed decoration? TODO: Unregister?
#ifdef KWIN_HAVE_OPENGL_COMPOSITING #ifdef KWIN_HAVE_OPENGL_COMPOSITING
if( effects->compositingType() == OpenGLCompositing ) if( effects->compositingType() == OpenGLCompositing )
{ {
// Delete any other textures in memory // 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++ ) for( int i = 0; i < mDefaultShadowTextures.size(); i++ )
delete mDefaultShadowTextures.at( i ); delete mDefaultShadowTextures.at( i );
mDefaultShadowTextures.clear(); mDefaultShadowTextures.clear();
// Create decoration shadows
if( effects->hasDecorationShadows() )
{
QList< QList<QImage> > shadowImages = effects->shadowTextures();
for( int i = 0; i < shadowImages.size(); i++ )
{
mShadowQuadTypes.append( effects->newWindowQuadType() );
QList<GLTexture*> 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 // Create default textures
@ -143,28 +112,10 @@ void ShadowEffect::reconfigure( ReconfigureFlags )
if( effects->compositingType() == XRenderCompositing ) if( effects->compositingType() == XRenderCompositing )
{ {
// Delete any other pictures in memory // 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++ ) for( int i = 0; i < mDefaultShadowPics.size(); i++ )
delete mDefaultShadowPics.at( i ); delete mDefaultShadowPics.at( i );
mDefaultShadowPics.clear(); mDefaultShadowPics.clear();
// Create decoration pictures
if( effects->hasDecorationShadows() )
{
QList< QList<QImage> > shadowImages = effects->shadowTextures();
for( int i = 0; i < shadowImages.size(); i++ )
{
mShadowQuadTypes.append( effects->newWindowQuadType() );
QList<XRenderPicture*> 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 // Create default pictures
mDefaultShadowQuadType = effects->newWindowQuadType(); // TODO: Unregister? mDefaultShadowQuadType = effects->newWindowQuadType(); // TODO: Unregister?
QPixmap shadowPixmap( KGlobal::dirs()->findResource( "data", "kwin/shadow-texture.png" )); QPixmap shadowPixmap( KGlobal::dirs()->findResource( "data", "kwin/shadow-texture.png" ));
@ -185,20 +136,16 @@ void ShadowEffect::reconfigure( ReconfigureFlags )
// Apply repeat attribute to all pictures // Apply repeat attribute to all pictures
XRenderPictureAttributes pa; XRenderPictureAttributes pa;
pa.repeat = true; 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++ ) for( int i = 0; i < mDefaultShadowPics.size(); i++ )
XRenderChangePicture( display(), *mDefaultShadowPics.at( i ), CPRepeat, &pa ); XRenderChangePicture( display(), *mDefaultShadowPics.at( i ), CPRepeat, &pa );
} }
#endif #endif
if( reconfiguring ) // Force rebuild of all quads to clear their caches
{ // Force rebuild of all quads to clear their caches
foreach( EffectWindow *w, effects->stackingOrder() ) foreach( EffectWindow *w, effects->stackingOrder() )
if( w ) // TODO/HACK: stackingOrder() should NOT return NULL
w->buildQuads( true ); w->buildQuads( true );
} }
}
void ShadowEffect::updateShadowColor() void ShadowEffect::updateShadowColor()
{ {
@ -207,50 +154,11 @@ void ShadowEffect::updateShadowColor()
} }
QRect ShadowEffect::shadowRectangle( EffectWindow* w, const QRect& windowRectangle ) 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 ))
{
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; int shadowGrow = shadowFuzzyness + shadowSize;
return windowRectangle.adjusted( shadowXOffset - shadowGrow, shadowYOffset - shadowGrow, return windowRectangle.adjusted( shadowXOffset - shadowGrow, shadowYOffset - shadowGrow,
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) )
);
}
#ifdef KWIN_HAVE_XRENDER_COMPOSITING #ifdef KWIN_HAVE_XRENDER_COMPOSITING
static ScreenPaintData gScreenData; static ScreenPaintData gScreenData;
@ -322,56 +230,7 @@ void ShadowEffect::drawWindow( EffectWindow* w, int mask, QRegion region, Window
void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList ) void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList )
{ {
bool shadowDefined = false; // TODO: add config option to not have shadows for menus, etc.
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 // Make our own shadow as the decoration doesn't support it
int fuzzy = shadowFuzzyness; int fuzzy = shadowFuzzyness;
// Shadow's size must be a least 2*fuzzy in both directions (or the corners will be broken) // Shadow's size must be a least 2*fuzzy in both directions (or the corners will be broken)
@ -478,7 +337,6 @@ void ShadowEffect::buildQuads( EffectWindow* w, WindowQuadList& quadList )
bottomRightQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 ); bottomRightQuad[ 2 ] = WindowVertex( x2, y2, 1, 0 );
bottomRightQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 ); bottomRightQuad[ 3 ] = WindowVertex( x1, y2, 0, 0 );
quadList.append( bottomRightQuad ); quadList.append( bottomRightQuad );
} // This is called for menus, tooltips, windows where the user has disabled borders and shaped windows
effects->buildQuads( w, quadList ); effects->buildQuads( w, quadList );
} }
@ -500,7 +358,9 @@ bool ShadowEffect::useShadow( EffectWindow* w ) const
{ {
return !w->isDeleted() && !w->isDesktop() && !w->isDock() return !w->isDeleted() && !w->isDesktop() && !w->isDock()
// popups may have shadow even if shaped, their shape is almost rectangular // 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<float>& verts, float x1, float y1, float x2, float y2) const void ShadowEffect::addQuadVertices(QVector<float>& 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 ) foreach( const WindowQuad &quad, data.quads )
{ {
if( !mShadowQuadTypes.contains( quad.type() ) && quad.type() != mDefaultShadowQuadType ) if( quad.type() != mDefaultShadowQuadType )
continue; // Not a shadow quad continue; // Not a shadow quad
glPushMatrix(); glPushMatrix();
@ -812,68 +672,6 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c
texcoords << quad[3].textureX() << quad[3].textureY(); texcoords << quad[3].textureX() << quad[3].textureY();
// Work out which texture to use // 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);
// 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; float opacity = shadowOpacity;
if( intensifyActiveShadow && window == effects->activeWindow() ) if( intensifyActiveShadow && window == effects->activeWindow() )
opacity = 1 - ( 1 - shadowOpacity ) * ( 1 - shadowOpacity ); opacity = 1 - ( 1 - shadowOpacity ) * ( 1 - shadowOpacity );
@ -884,7 +682,6 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c
data.brightness, data.brightness,
data.saturation, data.saturation,
data.shader); data.shader);
}
glPopMatrix(); glPopMatrix();
} }
@ -899,7 +696,7 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c
foreach( const WindowQuad &quad, data.quads ) foreach( const WindowQuad &quad, data.quads )
{ {
if( !mShadowQuadTypes.contains( quad.type() ) && quad.type() != mDefaultShadowQuadType ) if( quad.type() != mDefaultShadowQuadType )
continue; // Not a shadow quad continue; // Not a shadow quad
// Determine transformed quad position // Determine transformed quad position
@ -929,63 +726,6 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c
( quad[2].y() - quad[0].y() ) * yScale ); ( quad[2].y() - quad[0].y() ) * yScale );
// Work out which texture to use // 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 ));
// 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; float opacity = shadowOpacity;
if( intensifyActiveShadow && window == effects->activeWindow() ) if( intensifyActiveShadow && window == effects->activeWindow() )
opacity = 1 - ( 1 - shadowOpacity ) * ( 1 - shadowOpacity ); opacity = 1 - ( 1 - shadowOpacity ) * ( 1 - shadowOpacity );
@ -994,7 +734,6 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, c
shadowColor, opacity * data.opacity, data.brightness, data.saturation ); shadowColor, opacity * data.opacity, data.brightness, data.saturation );
} }
} }
}
#endif #endif
} }

View File

@ -71,20 +71,14 @@ class ShadowEffect
int shadowSize; int shadowSize;
bool intensifyActiveShadow; bool intensifyActiveShadow;
QColor shadowColor, cachedColor; QColor shadowColor, cachedColor;
bool forceDecorated;
bool forceUndecorated;
bool forceOther;
#ifdef KWIN_HAVE_OPENGL_COMPOSITING #ifdef KWIN_HAVE_OPENGL_COMPOSITING
QList< QList<GLTexture*> > mShadowTextures;
QList<GLTexture*> mDefaultShadowTextures; QList<GLTexture*> mDefaultShadowTextures;
#endif #endif
#ifdef KWIN_HAVE_XRENDER_COMPOSITING #ifdef KWIN_HAVE_XRENDER_COMPOSITING
QList< QList<XRenderPicture*> > mShadowPics;
QList<XRenderPicture*> mDefaultShadowPics; QList<XRenderPicture*> mDefaultShadowPics;
XRenderPicture cachedBlendPicture; XRenderPicture cachedBlendPicture;
#endif #endif
QList<WindowQuadType> mShadowQuadTypes;
WindowQuadType mDefaultShadowQuadType; WindowQuadType mDefaultShadowQuadType;
struct ShadowData struct ShadowData

View File

@ -56,10 +56,6 @@ ShadowEffectConfig::ShadowEffectConfig(QWidget* parent, const QVariantList& args
connect( m_ui->colorButton, SIGNAL( changed( QColor )), this, SLOT( changed() )); connect( m_ui->colorButton, SIGNAL( changed( QColor )), this, SLOT( changed() ));
connect( m_ui->strongerActiveBox, SIGNAL( stateChanged( int )), 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(); load();
} }
@ -81,10 +77,6 @@ void ShadowEffectConfig::load()
m_ui->colorButton->setColor( conf.readEntry( "Color", schemeShadowColor() )); m_ui->colorButton->setColor( conf.readEntry( "Color", schemeShadowColor() ));
m_ui->strongerActiveBox->setChecked( conf.readEntry( "IntensifyActiveShadow", true )); 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); emit changed(false);
} }
@ -108,10 +100,6 @@ void ShadowEffectConfig::save()
conf.writeEntry( "Color", userColor ); conf.writeEntry( "Color", userColor );
conf.writeEntry( "IntensifyActiveShadow", m_ui->strongerActiveBox->isChecked() ); 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(); conf.sync();
emit changed(false); emit changed(false);
@ -132,10 +120,6 @@ void ShadowEffectConfig::defaults()
m_ui->colorButton->setColor( schemeShadowColor() ); m_ui->colorButton->setColor( schemeShadowColor() );
m_ui->strongerActiveBox->setChecked( true ); m_ui->strongerActiveBox->setChecked( true );
m_ui->forceDecoratedBox->setChecked( false );
m_ui->forceUndecoratedBox->setChecked( false );
m_ui->forceOtherBox->setChecked( false );
emit changed(true); emit changed(true);
} }

View File

@ -1,313 +1,242 @@
<ui version="4.0" > <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KWin::ShadowEffectConfigForm</class> <class>KWin::ShadowEffectConfigForm</class>
<widget class="QWidget" name="KWin::ShadowEffectConfigForm" > <widget class="QWidget" name="KWin::ShadowEffectConfigForm">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>521</width> <width>292</width>
<height>267</height> <height>219</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout" > <layout class="QGridLayout" name="gridLayout">
<item> <item row="0" column="0">
<widget class="QGroupBox" name="groupBox" > <widget class="QLabel" name="label">
<property name="title" > <property name="text">
<string>Default Shadow</string>
</property>
<layout class="QGridLayout" name="gridLayout_3" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>&amp;X offset:</string> <string>&amp;X offset:</string>
</property> </property>
<property name="alignment" > <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>xOffsetSpin</cstring> <cstring>xOffsetSpin</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0" colspan="2" > <item row="0" column="1">
<widget class="QCheckBox" name="strongerActiveBox" > <widget class="QSpinBox" name="xOffsetSpin">
<property name="text" > <property name="sizePolicy">
<string>&amp;Active windows have stronger shadows</string> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText">
<string/>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" > <item row="1" column="0">
<widget class="QLabel" name="label_3" > <widget class="QLabel" name="label_3">
<property name="text" > <property name="text">
<string>&amp;Y offset:</string> <string>&amp;Y offset:</string>
</property> </property>
<property name="alignment" > <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>yOffsetSpin</cstring> <cstring>yOffsetSpin</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" > <item row="1" column="1">
<widget class="QSpinBox" name="yOffsetSpin" > <widget class="QSpinBox" name="yOffsetSpin">
<property name="sizePolicy" > <property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" > <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="specialValueText" > <property name="specialValueText">
<string/> <string/>
</property> </property>
<property name="suffix" > <property name="suffix">
<string/> <string/>
</property> </property>
<property name="minimum" > <property name="minimum">
<number>-100</number> <number>-100</number>
</property> </property>
<property name="maximum" > <property name="maximum">
<number>100</number> <number>100</number>
</property> </property>
<property name="singleStep" > <property name="singleStep">
<number>1</number> <number>1</number>
</property> </property>
<property name="value" > <property name="value">
<number>0</number> <number>0</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" > <item row="2" column="0">
<widget class="QLabel" name="label_4" > <widget class="QLabel" name="label_4">
<property name="text" > <property name="text">
<string>&amp;Opacity:</string> <string>&amp;Opacity:</string>
</property> </property>
<property name="alignment" > <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>opacitySpin</cstring> <cstring>opacitySpin</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1" > <item row="2" column="1">
<widget class="QSpinBox" name="opacitySpin" > <widget class="QSpinBox" name="opacitySpin">
<property name="sizePolicy" > <property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" > <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="specialValueText" > <property name="specialValueText">
<string/> <string/>
</property> </property>
<property name="suffix" > <property name="suffix">
<string>%</string> <string>%</string>
</property> </property>
<property name="minimum" > <property name="minimum">
<number>0</number> <number>0</number>
</property> </property>
<property name="maximum" > <property name="maximum">
<number>100</number> <number>100</number>
</property> </property>
<property name="singleStep" > <property name="singleStep">
<number>1</number> <number>1</number>
</property> </property>
<property name="value" > <property name="value">
<number>0</number> <number>0</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" > <item row="3" column="0">
<widget class="QLabel" name="label_5" > <widget class="QLabel" name="label_5">
<property name="text" > <property name="text">
<string>&amp;Fuzziness:</string> <string>&amp;Fuzziness:</string>
</property> </property>
<property name="alignment" > <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>fuzzinessSpin</cstring> <cstring>fuzzinessSpin</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" > <item row="3" column="1">
<widget class="QLabel" name="label_6" > <widget class="QSpinBox" name="fuzzinessSpin">
<property name="text" > <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText">
<string/>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>&amp;Size:</string> <string>&amp;Size:</string>
</property> </property>
<property name="alignment" > <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>sizeSpin</cstring> <cstring>sizeSpin</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1" > <item row="4" column="1">
<widget class="QSpinBox" name="fuzzinessSpin" > <widget class="QSpinBox" name="sizeSpin">
<property name="sizePolicy" > <property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" > <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="specialValueText" > <property name="specialValueText">
<string/> <string/>
</property> </property>
<property name="suffix" > <property name="suffix">
<string/> <string/>
</property> </property>
<property name="minimum" > <property name="minimum">
<number>0</number> <number>0</number>
</property> </property>
<property name="maximum" > <property name="maximum">
<number>100</number> <number>100</number>
</property> </property>
<property name="singleStep" > <property name="singleStep">
<number>1</number> <number>1</number>
</property> </property>
<property name="value" > <property name="value">
<number>0</number> <number>0</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1" > <item row="5" column="0">
<widget class="QSpinBox" name="sizeSpin" > <widget class="QLabel" name="label_7">
<property name="sizePolicy" > <property name="text">
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText" >
<string/>
</property>
<property name="suffix" >
<string/>
</property>
<property name="minimum" >
<number>0</number>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="singleStep" >
<number>1</number>
</property>
<property name="value" >
<number>0</number>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QSpinBox" name="xOffsetSpin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText" >
<string/>
</property>
<property name="suffix" >
<string/>
</property>
<property name="minimum" >
<number>-100</number>
</property>
<property name="maximum" >
<number>100</number>
</property>
<property name="singleStep" >
<number>1</number>
</property>
<property name="value" >
<number>0</number>
</property>
</widget>
</item>
<item row="6" column="1" >
<widget class="KColorButton" name="colorButton" />
</item>
<item row="6" column="0" >
<widget class="QLabel" name="label_7" >
<property name="text" >
<string>&amp;Color:</string> <string>&amp;Color:</string>
</property> </property>
<property name="alignment" > <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>colorButton</cstring> <cstring>colorButton</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0" colspan="2" > <item row="5" column="1">
<spacer name="verticalSpacer_2" > <widget class="KColorButton" name="colorButton"/>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item> </item>
</layout> <item row="6" column="0" colspan="2">
</widget> <widget class="QCheckBox" name="strongerActiveBox">
</item> <property name="text">
<item> <string>&amp;Active windows have stronger shadows</string>
<widget class="QGroupBox" name="groupBox_3" >
<property name="title" >
<string>Decoration Shadows</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_4" >
<item row="1" column="0" >
<widget class="QCheckBox" name="forceDecoratedBox" >
<property name="text" >
<string>&amp;Decorated windows</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Force default shadows for:</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QCheckBox" name="forceUndecoratedBox" >
<property name="text" >
<string>&amp;Undecorated normal windows</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QCheckBox" name="forceOtherBox" >
<property name="text" >
<string>All &amp;other windows</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -319,18 +248,6 @@
<header>kcolorbutton.h</header> <header>kcolorbutton.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops>
<tabstop>xOffsetSpin</tabstop>
<tabstop>yOffsetSpin</tabstop>
<tabstop>opacitySpin</tabstop>
<tabstop>fuzzinessSpin</tabstop>
<tabstop>sizeSpin</tabstop>
<tabstop>colorButton</tabstop>
<tabstop>strongerActiveBox</tabstop>
<tabstop>forceDecoratedBox</tabstop>
<tabstop>forceUndecoratedBox</tabstop>
<tabstop>forceOtherBox</tabstop>
</tabstops>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -1249,46 +1249,10 @@ KCommonDecorationUnstable::~KCommonDecorationUnstable()
} }
// All copied from kdecoration.cpp // All copied from kdecoration.cpp
QList<QRect> KCommonDecorationUnstable::shadowQuads( ShadowType type ) const
{
Q_UNUSED( type );
return QList<QRect>();
}
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<KDecorationUnstable*>( decoration() )->repaintShadow();
}
bool KCommonDecorationUnstable::compositingActive() const bool KCommonDecorationUnstable::compositingActive() const
{ {
return static_cast<const KDecorationUnstable*>( decoration() )->compositingActive(); return static_cast<const KDecorationUnstable*>( decoration() )->compositingActive();
} }
bool KCommonDecorationUnstable::shadowsActive() const
{
return static_cast<const KDecorationUnstable*>( decoration() )->shadowsActive();
}
double KCommonDecorationUnstable::opacity() const
{
return static_cast<const KDecorationUnstable*>( decoration() )->opacity();
}
// kate: space-indent on; indent-width 4; mixedindent off; indent-mode cstyle; // kate: space-indent on; indent-width 4; mixedindent off; indent-mode cstyle;

View File

@ -373,14 +373,8 @@ class KWIN_EXPORT KCommonDecorationUnstable
public: public:
KCommonDecorationUnstable(KDecorationBridge* bridge, KDecorationFactory* factory); KCommonDecorationUnstable(KDecorationBridge* bridge, KDecorationFactory* factory);
virtual ~KCommonDecorationUnstable(); virtual ~KCommonDecorationUnstable();
virtual QList<QRect> 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 compositingActive() const;
bool shadowsActive() const; bool shadowsActive() const;
double opacity() const;
}; };
/** /**

View File

@ -113,34 +113,6 @@ void KCommonDecorationWrapper::reset( unsigned long changed )
return decoration->reset( changed ); return decoration->reset( changed );
} }
QList<QRect> KCommonDecorationWrapper::shadowQuads( ShadowType type ) const
{
if( KCommonDecorationUnstable *decoration2 = dynamic_cast<KCommonDecorationUnstable*>( decoration ))
return decoration2->shadowQuads( type );
return QList<QRect>();
}
double KCommonDecorationWrapper::shadowOpacity( ShadowType type ) const
{
if( KCommonDecorationUnstable *decoration2 = dynamic_cast<KCommonDecorationUnstable*>( decoration ))
return decoration2->shadowOpacity( type );
return 1.0;
}
double KCommonDecorationWrapper::shadowBrightness( ShadowType type ) const
{
if( KCommonDecorationUnstable *decoration2 = dynamic_cast<KCommonDecorationUnstable*>( decoration ))
return decoration2->shadowBrightness( type );
return 1.0;
}
double KCommonDecorationWrapper::shadowSaturation( ShadowType type ) const
{
if( KCommonDecorationUnstable *decoration2 = dynamic_cast<KCommonDecorationUnstable*>( decoration ))
return decoration2->shadowSaturation( type );
return 1.0;
}
void KCommonDecorationWrapper::padding(int &left, int &right, int &top, int &bottom) const void KCommonDecorationWrapper::padding(int &left, int &right, int &top, int &bottom) const
{ {
left = decoration->layoutMetric(KCommonDecoration::LM_OuterPaddingLeft); left = decoration->layoutMetric(KCommonDecoration::LM_OuterPaddingLeft);

View File

@ -59,11 +59,6 @@ class KCommonDecorationWrapper
virtual bool windowDocked( Position side ); virtual bool windowDocked( Position side );
virtual void reset( unsigned long changed ); virtual void reset( unsigned long changed );
virtual QList<QRect> 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; virtual void padding( int &left, int &right, int &top, int &bottom ) const;
private: private:
KCommonDecoration* decoration; KCommonDecoration* decoration;

View File

@ -393,53 +393,11 @@ KDecorationUnstable::~KDecorationUnstable()
{ {
} }
QList<QRect> KDecorationUnstable::shadowQuads( ShadowType type ) const
{
Q_UNUSED( type );
return QList<QRect>();
}
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 bool KDecorationUnstable::compositingActive() const
{ {
return static_cast< KDecorationBridgeUnstable* >( bridge_ )->compositingActive(); 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 void KDecorationUnstable::padding(int &left, int &right, int &top, int &bottom) const
{ {
left = right = top = bottom = 0; left = right = top = bottom = 0;

View File

@ -185,7 +185,8 @@ public:
AbilityColorButtonFore = 2021, ///< decoration supports button foreground color AbilityColorButtonFore = 2021, ///< decoration supports button foreground color
ABILITYCOLOR_END, ///< @internal ABILITYCOLOR_END, ///< @internal
// compositing // 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. 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 /// The mask is still used to define the input region and the blurred
/// region, when the blur plugin is enabled. /// 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 class KWIN_EXPORT KDecorationUnstable
: public KDecoration : public KDecoration
@ -879,24 +880,6 @@ class KWIN_EXPORT KDecorationUnstable
public: public:
KDecorationUnstable( KDecorationBridge* bridge, KDecorationFactory* factory ); KDecorationUnstable( KDecorationBridge* bridge, KDecorationFactory* factory );
virtual ~KDecorationUnstable(); 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<QRect> 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 * 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 * 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; 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. * Returns @a true if compositing--and therefore ARGB--is enabled.
*/
void repaintShadow();
/**
* Returns @a true if compositing is enabled (Currently useless to decorations,
* use \a shadowsActive() instead).
*/ */
bool compositingActive() const; 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 inline

View File

@ -93,10 +93,7 @@ class KWIN_EXPORT KDecorationBridgeUnstable
: public KDecorationBridge : public KDecorationBridge
{ {
public: public:
virtual void repaintShadow() = 0;
virtual bool compositingActive() const = 0; virtual bool compositingActive() const = 0;
virtual bool shadowsActive() const = 0;
virtual double opacity() const = 0;
}; };
/** @} */ /** @} */

View File

@ -78,39 +78,3 @@ NET::WindowType KDecorationFactory::windowType( unsigned long supported_types, K
{ {
return bridge->windowType( supported_types ); return bridge->windowType( supported_types );
} }
QList< QList<QImage> > KDecorationFactoryUnstable::shadowTextures()
{
return QList< QList<QImage> >();
}
int KDecorationFactoryUnstable::shadowTextureList( ShadowType type ) const
{
Q_UNUSED( type );
return -1;
}
QList<QRect> KDecorationFactoryUnstable::shadowQuads( ShadowType type, QSize size ) const
{
Q_UNUSED( type );
Q_UNUSED( size );
return QList<QRect>();
}
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;
}

View File

@ -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 class KWIN_EXPORT KDecorationFactoryUnstable
: public KDecorationFactory : 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<QImage> > 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<QRect> 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() inline const KDecorationOptions* KDecorationFactory::options()

View File

@ -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_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor ))
#define KWIN_EFFECT_API_VERSION_MAJOR 0 #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( \ #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \
KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) 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. * Returns @a true if the active window decoration has shadow API hooks.
*/ */
virtual bool hasDecorationShadows() const = 0; 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<QImage> > shadowTextures() = 0;
/**
* Returns the texture list offset for the requested type.
*/
virtual int shadowTextureList( ShadowType type ) const = 0;
/** /**
* @deprecated * @deprecated
@ -950,23 +939,6 @@ class KWIN_EXPORT EffectWindow
virtual EffectWindow* findModal() = 0; virtual EffectWindow* findModal() = 0;
virtual EffectWindowList mainWindows() const = 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<QRect> 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. * Returns the unmodified window quad list. Can also be used to force rebuilding.
*/ */

View File

@ -367,13 +367,6 @@ class Workspace : public QObject, public KDecorationDefines
bool hasDecorationShadows() const; bool hasDecorationShadows() const;
bool decorationHasAlpha() const; bool decorationHasAlpha() const;
QList< QList<QImage> > decorationShadowTextures();
int decorationShadowTextureList( ShadowType type ) const;
QList<QRect> decorationShadowQuads( ShadowType type, QSize size ) const;
double decorationShadowOpacity( ShadowType type ) const;
double decorationShadowBrightness( ShadowType type ) const;
double decorationShadowSaturation( ShadowType type ) const;
// D-Bus interface // D-Bus interface
void cascadeDesktop(); void cascadeDesktop();
void unclutterDesktop(); void unclutterDesktop();
@ -1187,7 +1180,7 @@ inline void Workspace::checkCompositeTimer()
inline bool Workspace::hasDecorationShadows() const inline bool Workspace::hasDecorationShadows() const
{ {
return mgr->factory()->supports( AbilityCompositingShadow ); return mgr->factory()->supports( AbilityProvidesShadow );
} }
inline bool Workspace::decorationHasAlpha() const inline bool Workspace::decorationHasAlpha() const
@ -1195,48 +1188,6 @@ inline bool Workspace::decorationHasAlpha() const
return mgr->factory()->supports( AbilityUsesAlphaChannel ); return mgr->factory()->supports( AbilityUsesAlphaChannel );
} }
inline QList< QList<QImage> > Workspace::decorationShadowTextures()
{
if( KDecorationFactoryUnstable* factory = dynamic_cast<KDecorationFactoryUnstable*>( mgr->factory() ))
return factory->shadowTextures();
return QList< QList<QImage> >();
}
inline int Workspace::decorationShadowTextureList( ShadowType type ) const
{
if( KDecorationFactoryUnstable* factory = dynamic_cast<KDecorationFactoryUnstable*>( mgr->factory() ))
return factory->shadowTextureList( type );
return -1;
}
inline QList<QRect> Workspace::decorationShadowQuads( ShadowType type, QSize size ) const
{
if( KDecorationFactoryUnstable* factory = dynamic_cast<KDecorationFactoryUnstable*>( mgr->factory() ))
return factory->shadowQuads( type, size );
return QList<QRect>();
}
inline double Workspace::decorationShadowOpacity( ShadowType type ) const
{
if( KDecorationFactoryUnstable* factory = dynamic_cast<KDecorationFactoryUnstable*>( mgr->factory() ))
return factory->shadowOpacity( type );
return 1.0;
}
inline double Workspace::decorationShadowBrightness( ShadowType type ) const
{
if( KDecorationFactoryUnstable* factory = dynamic_cast<KDecorationFactoryUnstable*>( 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 } // namespace
#endif #endif