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();
}
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<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

View File

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

View File

@ -300,11 +300,6 @@ class Client
}
// 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 *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<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 );
} // namespace

View File

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

View File

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

View File

@ -192,16 +192,6 @@ bool EffectsHandlerImpl::hasDecorationShadows() const
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
void EffectsHandlerImpl::startPaint()
{
@ -1445,50 +1435,6 @@ EffectWindowList EffectWindowImpl::mainWindows() const
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
{
return sceneWindow()->buildQuads( force );

View File

@ -134,8 +134,6 @@ class EffectsHandlerImpl : public EffectsHandler
virtual void registerPropertyType( long atom, bool reg );
virtual bool hasDecorationShadows() const;
virtual QList< QList<QImage> > 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<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;
const Toplevel* window() const;

View File

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

View File

@ -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<GLTexture*> > mShadowTextures;
QList<GLTexture*> mDefaultShadowTextures;
#endif
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
QList< QList<XRenderPicture*> > mShadowPics;
QList<XRenderPicture*> mDefaultShadowPics;
XRenderPicture cachedBlendPicture;
#endif
QList<WindowQuadType> mShadowQuadTypes;
WindowQuadType mDefaultShadowQuadType;
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->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);
}

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>
<widget class="QWidget" name="KWin::ShadowEffectConfigForm" >
<property name="geometry" >
<widget class="QWidget" name="KWin::ShadowEffectConfigForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>521</width>
<height>267</height>
<width>292</width>
<height>219</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Default Shadow</string>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;X offset:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>xOffsetSpin</cstring>
</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>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>xOffsetSpin</cstring>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2" >
<widget class="QCheckBox" name="strongerActiveBox" >
<property name="text" >
<string>&amp;Active windows have stronger shadows</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>&amp;Y offset:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>yOffsetSpin</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QSpinBox" name="yOffsetSpin" >
<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="3" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>&amp;Opacity:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>opacitySpin</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QSpinBox" name="opacitySpin" >
<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>%</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_5" >
<property name="text" >
<string>&amp;Fuzziness:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>fuzzinessSpin</cstring>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>&amp;Size:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>sizeSpin</cstring>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QSpinBox" name="fuzzinessSpin" >
<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>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="5" column="1" >
<widget class="QSpinBox" name="sizeSpin" >
<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>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>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>colorButton</cstring>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2" >
<spacer name="verticalSpacer_2" >
<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>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3" >
<property name="title" >
<string>Decoration Shadows</string>
<item row="0" column="1">
<widget class="QSpinBox" name="xOffsetSpin">
<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>-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="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&amp;Y offset:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>yOffsetSpin</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="yOffsetSpin">
<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>-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="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&amp;Opacity:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>opacitySpin</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="opacitySpin">
<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>%</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="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>&amp;Fuzziness:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>fuzzinessSpin</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="fuzzinessSpin">
<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>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>sizeSpin</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="sizeSpin">
<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="5" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>&amp;Color:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>colorButton</cstring>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="KColorButton" name="colorButton"/>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="strongerActiveBox">
<property name="text">
<string>&amp;Active windows have stronger shadows</string>
</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>
</item>
</layout>
@ -319,18 +248,6 @@
<header>kcolorbutton.h</header>
</customwidget>
</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/>
<connections/>
</ui>

View File

@ -1249,46 +1249,10 @@ KCommonDecorationUnstable::~KCommonDecorationUnstable()
}
// 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
{
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;

View File

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

View File

@ -113,34 +113,6 @@ void KCommonDecorationWrapper::reset( unsigned long 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
{
left = decoration->layoutMetric(KCommonDecoration::LM_OuterPaddingLeft);

View File

@ -59,11 +59,6 @@ class KCommonDecorationWrapper
virtual bool windowDocked( Position side );
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;
private:
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
{
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;

View File

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

View File

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

View File

@ -78,39 +78,3 @@ NET::WindowType KDecorationFactory::windowType( unsigned long supported_types, K
{
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
: 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()

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_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<QImage> > 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<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.
*/

View File

@ -367,13 +367,6 @@ class Workspace : public QObject, public KDecorationDefines
bool hasDecorationShadows() 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
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<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
#endif