diff options
author | Timothy Pearson <[email protected]> | 2013-05-02 14:19:29 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2013-05-02 14:19:29 -0500 |
commit | 8ab00086554fa825a8d878f313fea674be37e748 (patch) | |
tree | 90fc48bafb6aefc7fd176207bdbe2bff44d9f991 /src/kernel | |
parent | c69c3400cbccaa8273918a68a749ce98a2340290 (diff) | |
download | qt3-8ab00086554fa825a8d878f313fea674be37e748.tar.gz qt3-8ab00086554fa825a8d878f313fea674be37e748.zip |
Fix corrupted titlebar icons in subwindows of ARGB applications
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/qwidget_x11.cpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/kernel/qwidget_x11.cpp b/src/kernel/qwidget_x11.cpp index 34acfa5..f98a5cb 100644 --- a/src/kernel/qwidget_x11.cpp +++ b/src/kernel/qwidget_x11.cpp @@ -44,6 +44,7 @@ #include "qpaintdevicemetrics.h" #include "qpainter.h" #include "qbitmap.h" +#include "qimage.h" #include "qobjectlist.h" #include "qlayout.h" #include "qtextcodec.h" @@ -1310,14 +1311,47 @@ void QWidget::setIcon( const QPixmap &pixmap ) } Pixmap icon_pixmap = 0; Pixmap mask_pixmap = 0; + QPixmap* pm = NULL; if ( !pixmap.isNull() ) { - QPixmap* pm = new QPixmap( pixmap ); + if (pixmap.depth() == 24) { + pm = new QPixmap( 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 QPixmap( pixmap.width(), pixmap.height(), 24 ); + QImage iconImage = pixmap.convertToImage(); + + // Load the new 24-bit RGB pixmap with data + GC gc; + pm->detach(); + Qt::HANDLE pmHandle = pm->handle(); + gc = XCreateGC(x11Display(), pmHandle, 0, 0); + for (int y = 0; y < h; ++y) { + QRgb *ls = (QRgb *)iconImage.scanLine( y ); + for (int x = 0; x < w; ++x) { + QRgb l = ls[x]; + int r = int( qRed( l ) ); + int g = int( qGreen( l ) ); + int b = int( qBlue( l ) ); + ls[x] = qRgb( 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; |