diff options
Diffstat (limited to 'amarok/src/osd.cpp')
-rw-r--r-- | amarok/src/osd.cpp | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/amarok/src/osd.cpp b/amarok/src/osd.cpp index cc475524..a9c2f517 100644 --- a/amarok/src/osd.cpp +++ b/amarok/src/osd.cpp @@ -139,7 +139,7 @@ OSDWidget::show() //virtual newGeometry.width(), newGeometry.height() )); - else if( m_translucency ) + else if (( m_translucency ) && (!kapp->isX11CompositionAvailable())) { const TQRect unite = oldGeometry.unite( newGeometry ); KPixmap pix = TQPixmap(TQPixmap::grabWindow( qt_xrootwin(), unite.x(), unite.y(), unite.width(), unite.height() )); @@ -158,7 +158,7 @@ OSDWidget::show() //virtual render( M, newGeometry.size() ); setGeometry( newGeometry ); TQWidget::show(); - bitBlt( this, 0, 0, &m_buffer ); + paintMe(); if( m_duration ) //duration 0 -> stay forever m_timer->start( m_duration, true ); //calls hide() @@ -308,7 +308,7 @@ OSDWidget::render( const uint M, const TQSize &size ) m_buffer.resize( rect.size() ); TQPainter p( &m_buffer ); - if( m_translucency ) + if (( m_translucency ) && (!kapp->isX11CompositionAvailable())) { KPixmap background( m_screenshot ); KPixmapEffect::fade( background, 0.80, backgroundColor() ); @@ -386,7 +386,7 @@ OSDWidget::render( const uint M, const TQSize &size ) pixmapGradient.setMask( mask ); } - if( m_translucency ) + if (( m_translucency ) && (!kapp->isX11CompositionAvailable())) { KPixmap background( m_screenshot ); KPixmapEffect::fade( background, 0.80, backgroundColor() ); @@ -487,6 +487,45 @@ OSDWidget::render( const uint M, const TQSize &size ) p.end(); } +void +OSDWidget::paintMe() +{ + if ((m_translucency) && (kapp->isX11CompositionAvailable())) { + // We have true composition support, so make the OSD truly transparent + TQImage blendedImage = m_buffer.convertToImage(); + blendedImage = blendedImage.convertDepth(32); + blendedImage.setAlphaBuffer(true); + + int w = blendedImage.width(); + int h = blendedImage.height(); + + for (int y = 0; y < h; ++y) { + TQRgb *ls = (TQRgb *)blendedImage.scanLine( y ); + for (int x = 0; x < w; ++x) { + TQRgb l = ls[x]; + //int desired_alpha = 127; + int desired_alpha = 204; + float alpha_adjust = (desired_alpha/256.0); + int r = int( tqRed( l ) * alpha_adjust ); + int g = int( tqGreen( l ) * alpha_adjust ); + int b = int( tqBlue( l ) * alpha_adjust ); + int a = int( desired_alpha ); + ls[x] = tqRgba( r, g, b, a ); + } + } + + // Finally, paint it + TQPainter p1; + p1.begin( this ); + blendedImage.setAlphaBuffer(false); + p1.drawImage( 0, 0, blendedImage ); + p1.end(); + } + else { + bitBlt( this, 0, 0, &m_buffer ); + } +} + bool OSDWidget::event( TQEvent *e ) { @@ -497,7 +536,7 @@ OSDWidget::event( TQEvent *e ) unsetColors(); //use new palette's colours return true; case TQEvent::Paint: - bitBlt( this, 0, 0, &m_buffer ); + paintMe(); return true; default: return TQWidget::event( e ); |