summaryrefslogtreecommitdiffstats
path: root/kdm/kfrontend/themer/kdmpixmap.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-13 02:31:25 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-13 02:31:25 +0000
commitf50ce50331053efe6b06b3917bf07a5a64398736 (patch)
tree3b6de07bf3f62b177816725b61650cf4589a9db0 /kdm/kfrontend/themer/kdmpixmap.cpp
parentecb591aa8446dd7b133e1674287924a5e2c0ac14 (diff)
downloadtdebase-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/kdmpixmap.cpp')
-rw-r--r--kdm/kfrontend/themer/kdmpixmap.cpp51
1 files changed, 42 insertions, 9 deletions
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()) {