diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-08-13 02:31:25 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-08-13 02:31:25 +0000 |
commit | f50ce50331053efe6b06b3917bf07a5a64398736 (patch) | |
tree | 3b6de07bf3f62b177816725b61650cf4589a9db0 /kdm/kfrontend/themer | |
parent | ecb591aa8446dd7b133e1674287924a5e2c0ac14 (diff) | |
download | tdebase-f50ce50331053efe6b06b3917bf07a5a64398736.tar.gz tdebase-f50ce50331053efe6b06b3917bf07a5a64398736.zip |
Add Xorg composition support to kdm
KDM composition can be enabled in the control center
When enabled, it provides seamless composited logins to Trinity sessions
It also gets rid of the remaining artifacts in the themed kdm login screen
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1246834 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdm/kfrontend/themer')
-rw-r--r-- | kdm/kfrontend/themer/kdmitem.cpp | 30 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmpixmap.cpp | 51 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmrect.cpp | 25 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmthemer.cpp | 40 | ||||
-rw-r--r-- | kdm/kfrontend/themer/kdmthemer.h | 1 |
5 files changed, 119 insertions, 28 deletions
diff --git a/kdm/kfrontend/themer/kdmitem.cpp b/kdm/kfrontend/themer/kdmitem.cpp index 88e5a7489..eb5283cd9 100644 --- a/kdm/kfrontend/themer/kdmitem.cpp +++ b/kdm/kfrontend/themer/kdmitem.cpp @@ -38,6 +38,8 @@ #include <tqimage.h> #include <tqpainter.h> +extern bool argb_visual_available; + KdmItem::KdmItem( KdmItem *parent, const TQDomNode &node, const char *name ) : TQObject( parent, name ) , boxManager( 0 ) @@ -289,11 +291,13 @@ KdmItem::paint( TQPainter *p, const TQRect &rect ) if (myWidget || (myLayoutItem && myLayoutItem->widget())) { // KListView because it's missing a Q_OBJECT' - // FIXME: This is a nice idea intheory, but in practice it is + // FIXME: This is a nice idea in theory, but in practice it is // very confusing for the user not to see the empty list box // delineated from the rest of the greeter. // Maybe set a darker version of the background instead of an exact copy? if ( myWidget && myWidget->isA( "KListView" ) ) { + if ((_compositor.isEmpty()) || (!argb_visual_available)) { + // Software blend only (no compositing support) TQPixmap copy( myWidget->size() ); kdDebug() << myWidget->tqgeometry() << " " << area << " " << myWidget->size() << endl; bitBlt( ©, TQPoint( 0, 0), p->device(), myWidget->geometry(), TQt::CopyROP ); @@ -327,6 +331,30 @@ KdmItem::paint( TQPainter *p, const TQRect &rect ) copy = lightVersion; // Set it myWidget->setPaletteBackgroundPixmap( copy ); + } + else { + // We have compositing support! + TQRgb blend_color = tqRgba(m_backgroundModifier, m_backgroundModifier, m_backgroundModifier, 0); // RGBA overlay + float alpha = tqAlpha(blend_color) / 255.; + int pixel = tqAlpha(blend_color) << 24 | + int(tqRed(blend_color) * alpha) << 16 | + int(tqGreen(blend_color) * alpha) << 8 | + int(tqBlue(blend_color) * alpha); + + TQImage img( myWidget->size(), 32 ); + img = img.convertDepth(32); + img.setAlphaBuffer(true); + register uchar * rd = img.bits(); + for( int y = 0; y < img.height(); ++y ) + { + for( short int x = 0; x < img.width(); ++x ) + { + *reinterpret_cast<TQRgb*>(rd) = blend_color; + rd += 4; + } + } + myWidget->setPaletteBackgroundPixmap( img ); + } } return; } diff --git a/kdm/kfrontend/themer/kdmpixmap.cpp b/kdm/kfrontend/themer/kdmpixmap.cpp index af64714b8..436483c48 100644 --- a/kdm/kfrontend/themer/kdmpixmap.cpp +++ b/kdm/kfrontend/themer/kdmpixmap.cpp @@ -37,6 +37,8 @@ #include <tqpixmap.h> #include <tqimage.h> +extern bool argb_visual_available; + KdmPixmap::KdmPixmap( KdmItem *parent, const TQDomNode &node, const char *name ) : KdmItem( parent, node, name ) { @@ -47,6 +49,7 @@ KdmPixmap::KdmPixmap( KdmItem *parent, const TQDomNode &node, const char *name ) pixmap.normal.alpha = 0.0; pixmap.active.present = false; pixmap.prelight.present = false; + bool true_transparency = false; // Read PIXMAP ID // it rarely happens that a pixmap can be a button too! @@ -66,13 +69,20 @@ KdmPixmap::KdmPixmap( KdmItem *parent, const TQDomNode &node, const char *name ) pixmap.normal.alpha = el.attribute( "alpha", "1.0" ).toFloat(); if (el.attribute( "file", "" ) == "@@@KDMBACKGROUND@@@") { - // Use the preset KDM background... - KStandardDirs *m_pDirs = KGlobal::dirs(); - KSimpleConfig *config = new KSimpleConfig( TQFile::decodeName( _backgroundCfg ) ); - config->setGroup("Desktop0"); - pixmap.normal.fullpath = m_pDirs->findResource("wallpaper", config->readPathEntry("Wallpaper")); - // TODO: Detect when there is no wallpaper and use the background settings instead - delete config; + if ((_compositor.isEmpty()) || (!argb_visual_available)) { + // Software blend only (no compositing support) + // Use the preset KDM background... + KStandardDirs *m_pDirs = KGlobal::dirs(); + KSimpleConfig *config = new KSimpleConfig( TQFile::decodeName( _backgroundCfg ) ); + config->setGroup("Desktop0"); + pixmap.normal.fullpath = m_pDirs->findResource("wallpaper", config->readPathEntry("Wallpaper")); + // TODO: Detect when there is no wallpaper and use the background settings instead + delete config; + } + else { + true_transparency = true; + pixmap.normal.alpha = 0.0; + } } } else if (tagName == "active") { @@ -189,7 +199,6 @@ KdmPixmap::drawContents( TQPainter *p, const TQRect &r ) kdDebug() << "draw " << id << " " << pClass->pixmap.isNull() << endl; if (pClass->pixmap.isNull()) { - if (pClass->fullpath.isEmpty()) // if neither is set, we're empty return; @@ -246,7 +255,7 @@ KdmPixmap::drawContents( TQPainter *p, const TQRect &r ) if (haveTint || haveAlpha) { scaledImage = pClass->pixmap.convertToImage(); - // enforce rgba values for the later + // enforce rgba values for the latter scaledImage = scaledImage.convertDepth( 32 ); } else @@ -275,7 +284,31 @@ KdmPixmap::drawContents( TQPainter *p, const TQRect &r ) ls[x] = tqRgba( r, g, b, a ); } } + } + if ((_compositor.isEmpty()) || (!argb_visual_available)) { + // Software blend only (no compositing support) + } + else { + // We have a compositor! + // Apply the alpha in the same manner as above, exept we are now + // using the hardware blending engine for all painting + scaledImage = pClass->readyPixmap; + scaledImage = scaledImage.convertDepth( 32 ); + int w = scaledImage.width(); + int h = scaledImage.height(); + for (int y = 0; y < h; ++y) { + QRgb *ls = (QRgb *)scaledImage.scanLine( y ); + for (int x = 0; x < w; ++x) { + QRgb l = ls[x]; + float alpha_adjust = (tqAlpha( l )/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( tqAlpha( l ) * 1 ); + ls[x] = tqRgba( r, g, b, a ); + } + } } if (!scaledImage.isNull()) { diff --git a/kdm/kfrontend/themer/kdmrect.cpp b/kdm/kfrontend/themer/kdmrect.cpp index 1d854d213..1db128da0 100644 --- a/kdm/kfrontend/themer/kdmrect.cpp +++ b/kdm/kfrontend/themer/kdmrect.cpp @@ -21,6 +21,7 @@ #include "kdmrect.h" #include "kdmthemer.h" +#include "kdmconfig.h" #include <kimageeffect.h> #include <kdebug.h> @@ -30,6 +31,8 @@ #include <tqwidget.h> #include <tqlayout.h> +extern bool argb_visual_available; + KdmRect::KdmRect( KdmItem *parent, const TQDomNode &node, const char *name ) : KdmItem( parent, node, name ) { @@ -103,14 +106,20 @@ KdmRect::drawContents( TQPainter *p, const TQRect &r ) if (rClass->alpha == 1) p->fillRect( area, TQBrush( rClass->color ) ); else { - TQRect backRect = r; - backRect.moveBy( area.x(), area.y() ); - TQPixmap backPixmap( backRect.size() ); - bitBlt( &backPixmap, TQPoint( 0, 0 ), p->device(), backRect ); - TQImage backImage = backPixmap.convertToImage(); - KImageEffect::blend( rClass->color, backImage, rClass->alpha ); - p->drawImage( backRect.x(), backRect.y(), backImage ); - // area.moveBy(1,1); +// if ((_compositor.isEmpty()) || (!argb_visual_available)) { + // Software blend only (no compositing support) + TQRect backRect = r; + backRect.moveBy( area.x(), area.y() ); + TQPixmap backPixmap( backRect.size() ); + bitBlt( &backPixmap, TQPoint( 0, 0 ), p->device(), backRect ); + TQImage backImage = backPixmap.convertToImage(); + KImageEffect::blend( rClass->color, backImage, rClass->alpha ); + p->drawImage( backRect.x(), backRect.y(), backImage ); + // area.moveBy(1,1); +// } +// else { +// // We have compositing support! +// } } } diff --git a/kdm/kfrontend/themer/kdmthemer.cpp b/kdm/kfrontend/themer/kdmthemer.cpp index d6b2e6e0e..39a1abe81 100644 --- a/kdm/kfrontend/themer/kdmthemer.cpp +++ b/kdm/kfrontend/themer/kdmthemer.cpp @@ -46,6 +46,8 @@ #include <unistd.h> +extern bool argb_visual_available; + /* * KdmThemer. The main theming interface */ @@ -159,17 +161,35 @@ KdmThemer::widgetEvent( TQEvent *e ) TQRect paintRect = TQT_TQPAINTEVENT(e)->rect(); kdDebug() << timestamp() << " paint on: " << paintRect << endl; - if (!backBuffer) - backBuffer = new TQPixmap( widget()->size() ); - if (backBuffer->size() != widget()->size()) - backBuffer->resize( widget()->size() ); - - TQPainter p; - p.begin( backBuffer ); - rootItem->paint( &p, paintRect ); - p.end(); + if ((_compositor.isEmpty()) || (!argb_visual_available)) { + // Software blend only (no compositing support) + if (!backBuffer) + backBuffer = new TQPixmap( widget()->size() ); + if (backBuffer->size() != widget()->size()) + backBuffer->resize( widget()->size() ); + + TQPainter p; + p.begin( backBuffer ); + rootItem->paint( &p, paintRect ); + p.end(); + + bitBlt( widget(), paintRect.topLeft(), backBuffer, paintRect ); + } + else { + // We have compositing support! + TQRgb blend_color = tqRgba(0, 0, 0, 0); // RGBA + float alpha = tqAlpha(blend_color) / 255.; + int pixel = tqAlpha(blend_color) << 24 | + int(tqRed(blend_color) * alpha) << 16 | + int(tqGreen(blend_color) * alpha) << 8 | + int(tqBlue(blend_color) * alpha); + TQPainter p1; + p1.begin( widget() ); + p1.fillRect( paintRect, TQColor(blend_color, pixel) ); + rootItem->paint( &p1, paintRect ); + p1.end(); + } - bitBlt( widget(), paintRect.topLeft(), backBuffer, paintRect ); } break; default: diff --git a/kdm/kfrontend/themer/kdmthemer.h b/kdm/kfrontend/themer/kdmthemer.h index e5228973e..e6e5efdb4 100644 --- a/kdm/kfrontend/themer/kdmthemer.h +++ b/kdm/kfrontend/themer/kdmthemer.h @@ -24,6 +24,7 @@ #include <tqobject.h> #include <tqdom.h> +#include <tqimage.h> class KdmThemer; class KdmItem; |