|
|
|
|
@ -386,113 +386,6 @@ KConfigGroup EffectsHandler::effectConfig( const QString& effectname ) |
|
|
|
|
return kwinconfig->group( "Effect-" + effectname ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool EffectsHandler::paintText( const QString& text, const QRect& rect, const QColor& color, |
|
|
|
|
const QFont& font, const Qt::Alignment& alignment ) |
|
|
|
|
{ |
|
|
|
|
QPainter p; |
|
|
|
|
// Calculate size of the text
|
|
|
|
|
QFontMetrics fm( font ); |
|
|
|
|
QString painttext = fm.elidedText( text, Qt::ElideRight, rect.width() ); |
|
|
|
|
QRect textrect = fm.boundingRect( painttext ); |
|
|
|
|
|
|
|
|
|
// Create temporary QImage where the text will be drawn onto
|
|
|
|
|
QImage textImage( textrect.width(), textrect.height(), QImage::Format_ARGB32 ); |
|
|
|
|
textImage.fill( Qt::transparent ); |
|
|
|
|
|
|
|
|
|
// Draw the text
|
|
|
|
|
p.begin( &textImage ); |
|
|
|
|
p.setFont( font ); |
|
|
|
|
p.setRenderHint( QPainter::TextAntialiasing ); |
|
|
|
|
p.setPen( color ); |
|
|
|
|
p.drawText( -textrect.topLeft(), painttext ); |
|
|
|
|
p.end(); |
|
|
|
|
|
|
|
|
|
// Area covered by text
|
|
|
|
|
int rectX, rectY; |
|
|
|
|
if( alignment & Qt::AlignLeft ) |
|
|
|
|
rectX = rect.x(); |
|
|
|
|
else if( alignment & Qt::AlignRight ) |
|
|
|
|
rectX = rect.right() - textrect.width(); |
|
|
|
|
else |
|
|
|
|
rectX = rect.center().x() - textrect.width() / 2; |
|
|
|
|
if( alignment & Qt::AlignTop ) |
|
|
|
|
rectY = rect.y(); |
|
|
|
|
else if( alignment & Qt::AlignBottom ) |
|
|
|
|
rectY = rect.bottom() - textrect.height(); |
|
|
|
|
else |
|
|
|
|
rectY = rect.center().y() - textrect.height() / 2; |
|
|
|
|
QRect area( rectX, rectY, textrect.width(), textrect.height() ); |
|
|
|
|
|
|
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING |
|
|
|
|
if( effects->compositingType() == OpenGLCompositing ) |
|
|
|
|
{ |
|
|
|
|
GLTexture textTexture( textImage, GL_TEXTURE_RECTANGLE_ARB ); |
|
|
|
|
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT ); |
|
|
|
|
glEnable( GL_BLEND ); |
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); |
|
|
|
|
textTexture.bind(); |
|
|
|
|
textTexture.render( infiniteRegion(), area ); |
|
|
|
|
textTexture.unbind(); |
|
|
|
|
glPopAttrib(); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING |
|
|
|
|
if( effects->compositingType() == XRenderCompositing ) |
|
|
|
|
{ |
|
|
|
|
XRenderPicture textPicture( QPixmap::fromImage( textImage )); |
|
|
|
|
XRenderComposite( display(), textImage.depth() == 32 ? PictOpOver : PictOpSrc, |
|
|
|
|
textPicture, None, effects->xrenderBufferPicture(), |
|
|
|
|
0, 0, 0, 0, area.x(), area.y(), area.width(), area.height()); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool EffectsHandler::paintTextWithBackground( const QString& text, const QRect& rect, const QColor& color, |
|
|
|
|
const QColor& bgcolor, const QFont& font, const Qt::Alignment& alignment ) |
|
|
|
|
{ |
|
|
|
|
// Calculate size of the text
|
|
|
|
|
QFontMetrics fm( font ); |
|
|
|
|
QString painttext = fm.elidedText( text, Qt::ElideRight, rect.width() ); |
|
|
|
|
QRect textrect = fm.boundingRect( painttext ); |
|
|
|
|
|
|
|
|
|
// Area covered by text
|
|
|
|
|
int rectX, rectY; |
|
|
|
|
if( alignment & Qt::AlignLeft ) |
|
|
|
|
rectX = rect.x(); |
|
|
|
|
else if( alignment & Qt::AlignRight ) |
|
|
|
|
rectX = rect.right() - textrect.width(); |
|
|
|
|
else |
|
|
|
|
rectX = rect.center().x() - textrect.width() / 2; |
|
|
|
|
if( alignment & Qt::AlignTop ) |
|
|
|
|
rectY = rect.y(); |
|
|
|
|
else if( alignment & Qt::AlignBottom ) |
|
|
|
|
rectY = rect.bottom() - textrect.height(); |
|
|
|
|
else |
|
|
|
|
rectY = rect.center().y() - textrect.height() / 2; |
|
|
|
|
QRect area( rectX, rectY, textrect.width(), textrect.height() ); |
|
|
|
|
|
|
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING |
|
|
|
|
if( effects->compositingType() == OpenGLCompositing ) |
|
|
|
|
{ |
|
|
|
|
glColor4f( bgcolor.redF(), bgcolor.greenF(), bgcolor.blueF(), bgcolor.alphaF() ); |
|
|
|
|
renderRoundBox( area.adjusted( -8, -3, 8, 3 ), 5 ); |
|
|
|
|
|
|
|
|
|
return paintText( text, rect, color, font, alignment ); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING |
|
|
|
|
if( effects->compositingType() == XRenderCompositing ) |
|
|
|
|
{ |
|
|
|
|
xRenderRoundBox( effects->xrenderBufferPicture(), area.adjusted( -8, -3, 8, 3 ), 5, bgcolor ); |
|
|
|
|
return paintText( text, rect, color, font, alignment ); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool EffectsHandler::checkDriverBlacklist( const KConfigGroup& blacklist ) |
|
|
|
|
{ |
|
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING |
|
|
|
|
|