summaryrefslogtreecommitdiffstats
path: root/kicker/applets
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-28 05:11:10 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-28 05:11:10 +0000
commitaca04c8c0d2c7cfbc9c9de499b3808fb9a0492c3 (patch)
tree72637c5b3f968adf2859d93b1453b4878ba6f13c /kicker/applets
parentf62a335a9aa23c9a10a9768caf5a9c2eae922861 (diff)
downloadtdebase-aca04c8c0d2c7cfbc9c9de499b3808fb9a0492c3.tar.gz
tdebase-aca04c8c0d2c7cfbc9c9de499b3808fb9a0492c3.zip
Fix up system tray RGB<-->ARGB hack
It is now fully deterministic and will work on all systems git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1249856 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kicker/applets')
-rw-r--r--kicker/applets/systemtray/systemtrayapplet.cpp62
1 files changed, 35 insertions, 27 deletions
diff --git a/kicker/applets/systemtray/systemtrayapplet.cpp b/kicker/applets/systemtray/systemtrayapplet.cpp
index 9be1bbfe2..619fdebcc 100644
--- a/kicker/applets/systemtray/systemtrayapplet.cpp
+++ b/kicker/applets/systemtray/systemtrayapplet.cpp
@@ -1169,39 +1169,47 @@ void TrayEmbed::setBackground()
if (!isHidden())
{
XClearArea(x11Display(), embeddedWinId(), 0, 0, 0, 0, True);
-
- if (pbg)
- {
- ensureBackgroundSet();
- TQTimer::singleShot( 250, this, SLOT(ensureBackgroundSet()) );
- }
+ ensureBackgroundSet();
}
}
void TrayEmbed::ensureBackgroundSet()
{
- // This is a nasty little hack to make sure that tray icons / applications which do not match our QXEmbed native depth are still displayed properly,
- // i.e without irritating white/grey borders where the tray icon's transparency is supposed to be...
-
- const TQPixmap *pbg = parentWidget()->backgroundPixmap();
+ XWindowAttributes winprops;
+ XGetWindowAttributes(x11Display(), embeddedWinId(), &winprops);
+ if (winprops.depth == 32) {
+ // This is a nasty little hack to make sure that tray icons / applications which do not match our QXEmbed native depth are still displayed properly,
+ // i.e without irritating white/grey borders where the tray icon's transparency is supposed to be...
+ // Essentially it converts a 24 bit Xlib Pixmap to a 32 bit Xlib Pixmap
- if (pbg)
- {
TQPixmap bg(width(), height());
- bg.fill(parentWidget(), pos());
- setPaletteBackgroundPixmap(bg);
- }
- if (!isHidden())
- {
- XFlush(x11Display());
- TQPixmap bg(width(), height(), 32);
- TQRgb blend_color = tqRgba(0, 0, 0, 0); // RGBA
- float alpha = tqAlpha(blend_color) / 255.0;
- int pixel = tqAlpha(blend_color) << 24 | int(tqRed(blend_color) * alpha) << 16 | int(tqGreen(blend_color) * alpha) << 8 | int(tqBlue(blend_color) * alpha);
- bg.fill(TQColor(blend_color, pixel));
- Pixmap bgPm = bg.handle();
- XSetWindowBackgroundPixmap(x11Display(), embeddedWinId(), bgPm);
- XClearArea(x11Display(), embeddedWinId(), 0, 0, 0, 0, True);
+ // Get the RGB background image
+ bg.fill(parentWidget(), pos());
+ TQImage bgImage = bg.convertToImage();
+
+ // Create the ARGB pixmap
+ Pixmap argbpixmap = XCreatePixmap(x11Display(), embeddedWinId(), width(), height(), 32);
+ GC gc;
+ gc = XCreateGC(x11Display(), embeddedWinId(), 0, 0);
+ int w = bgImage.width();
+ int h = bgImage.height();
+ for (int y = 0; y < h; ++y) {
+ TQRgb *ls = (TQRgb *)bgImage.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 ) );
+ ls[x] = tqRgba( r, g, b, a );
+ XSetForeground(x11Display(), gc, (r << 16) | (g << 8) | b );
+ XDrawPoint(x11Display(), argbpixmap, gc, x, y);
+ }
+ }
+ XFlush(x11Display());
+ XSetWindowBackgroundPixmap(x11Display(), embeddedWinId(), argbpixmap);
+ XFreePixmap(x11Display(), argbpixmap);
+ XFreeGC(x11Display(), gc);
}
-} \ No newline at end of file
+}