summaryrefslogtreecommitdiffstats
path: root/src/kernel
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2013-05-02 14:20:33 -0500
committerTimothy Pearson <[email protected]>2013-05-02 14:20:33 -0500
commite980c0380f96c0eea185e86a464f140b012e2818 (patch)
treedb9744723df9c5a58783008f7bf9f09f3c75590b /src/kernel
parent5faba37f113b6a4d75d7526cbbc1f363a465c39f (diff)
downloadtqt3-e980c0380f96c0eea185e86a464f140b012e2818.tar.gz
tqt3-e980c0380f96c0eea185e86a464f140b012e2818.zip
Automated update from Qt3
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/qwidget_x11.cpp40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/kernel/qwidget_x11.cpp b/src/kernel/qwidget_x11.cpp
index 67463d0cf..1479342e9 100644
--- a/src/kernel/qwidget_x11.cpp
+++ b/src/kernel/qwidget_x11.cpp
@@ -44,6 +44,7 @@
#include "ntqpaintdevicemetrics.h"
#include "ntqpainter.h"
#include "ntqbitmap.h"
+#include "ntqimage.h"
#include "ntqobjectlist.h"
#include "ntqlayout.h"
#include "ntqtextcodec.h"
@@ -1310,14 +1311,47 @@ void TQWidget::setIcon( const TQPixmap &pixmap )
}
Pixmap icon_pixmap = 0;
Pixmap mask_pixmap = 0;
+ TQPixmap* pm = NULL;
if ( !pixmap.isNull() ) {
- TQPixmap* pm = new TQPixmap( pixmap );
+ if (pixmap.depth() == 24) {
+ pm = new TQPixmap( pixmap );
+ }
+ else {
+ // With most window managers, only 24-bit icon pixmaps are allowed in the WM hints, otherwise corrupt icons will be displayed
+ // Convert provided pixmaps to 24-bit here
+ int w = pixmap.width();
+ int h = pixmap.height();
+ pm = new TQPixmap( pixmap.width(), pixmap.height(), 24 );
+ TQImage iconImage = pixmap.convertToImage();
+
+ // Load the new 24-bit RGB pixmap with data
+ GC gc;
+ pm->detach();
+ TQt::HANDLE pmHandle = pm->handle();
+ gc = XCreateGC(x11Display(), pmHandle, 0, 0);
+ for (int y = 0; y < h; ++y) {
+ TQRgb *ls = (TQRgb *)iconImage.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 ) );
+ ls[x] = tqRgb( r, g, b );
+ XSetForeground(x11Display(), gc, (r << 16) | (g << 8) | b );
+ XDrawPoint(x11Display(), pmHandle, gc, x, y);
+ }
+ }
+ XFreeGC(x11Display(), gc);
+ }
+
extra->topextra->icon = pm;
- if ( !pm->mask() )
+ if ( !pm->mask() ) {
pm->setMask( pm->createHeuristicMask() ); // may do detach()
+ }
icon_pixmap = pm->handle();
- if ( pm->mask() )
+ if ( pm->mask() ) {
mask_pixmap = pm->mask()->handle();
+ }
}
XWMHints *h = XGetWMHints( x11Display(), winId() );
XWMHints wm_hints;