summaryrefslogtreecommitdiffstats
path: root/kdeui
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-25 20:08:02 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-25 20:08:02 +0000
commiteab043fd0dea1332165e5f57f4d7fd8ed0422398 (patch)
tree545d1411e56696fd226235da922e9a6fb03ed9be /kdeui
parent00892b3ece0c219a4cb4d6a3f1f5e6573c9a07de (diff)
downloadtdelibs-eab043fd0dea1332165e5f57f4d7fd8ed0422398.tar.gz
tdelibs-eab043fd0dea1332165e5f57f4d7fd8ed0422398.zip
Fix lack of system tray icon transparency when parent application utilizes ARGB visuals
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1249526 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdeui')
-rw-r--r--kdeui/ksystemtray.cpp36
1 files changed, 31 insertions, 5 deletions
diff --git a/kdeui/ksystemtray.cpp b/kdeui/ksystemtray.cpp
index 5374c49f8..c1cea624a 100644
--- a/kdeui/ksystemtray.cpp
+++ b/kdeui/ksystemtray.cpp
@@ -39,6 +39,7 @@
#include <kconfig.h>
#include <tqapplication.h>
+#include <tqbitmap.h>
class KSystemTrayPrivate
{
@@ -326,12 +327,37 @@ TQPixmap KSystemTray::loadSizedIcon( const TQString &icon, int iconWidth, KInsta
void KSystemTray::setPixmap( const TQPixmap& p )
{
- TQPixmap iconPixmapToSet = p;
- if (TQPaintDevice::x11AppDepth() == 32) iconPixmapToSet.convertFromImage(KImageEffect::convertToPremultipliedAlpha( iconPixmapToSet.convertToImage() ));
- if (TQPaintDevice::x11AppDepth() == 32) setBackgroundMode( NoBackground );
- TQLabel::setPixmap( iconPixmapToSet );
+ TQPixmap iconPixmapToSet = p;
+ if (TQPaintDevice::x11AppDepth() == 32) {
+ // Since full ARGB visuals are in use, we must handle the three primary data
+ // channel types (color, alpha, and mask) separately.
+ // First, make the actual color and internal alpha of the icon is correct
+ TQImage correctedImage = KImageEffect::convertToPremultipliedAlpha( iconPixmapToSet.convertToImage() );
+ iconPixmapToSet.convertFromImage(correctedImage);
+ // Next, handle the mask channel to make sure that the transparent
+ // sections remain transparent when drawn on the screen
+ TQBitmap maskBitmap;
+ // Generate the mask utilizing ONLY the pixels that are fully opaque
+ TQImage newMaskImage = correctedImage;
+ int w = newMaskImage.width();
+ int h = newMaskImage.height();
+ for (int y = 0; y < h; ++y) {
+ TQRgb *ls = (TQRgb *)newMaskImage.scanLine( y );
+ for (int x = 0; x < w; ++x) {
+ TQRgb l = ls[x];
+ int r = int( tqRed( l ) );
+ int g = int( tqGreen( l ) );
+ int b = int( tqBlue( l ) );
+ int a = int( (tqAlpha( l ) == 255) ? 255 : 0 );
+ ls[x] = tqRgba( r, g, b, a );
+ }
+ }
+ maskBitmap.convertFromImage(newMaskImage.createAlphaMask());
+ setMask(maskBitmap);
+ }
+ TQLabel::setPixmap( iconPixmapToSet );
#ifdef Q_WS_X11
- KWin::setIcons( winId(), iconPixmapToSet, TQPixmap());
+ KWin::setIcons( winId(), iconPixmapToSet, TQPixmap());
#endif
}