src/gui/image/qpixmap_x11.cpp
changeset 30 5dc02b23752f
parent 22 79de32ba3296
child 33 3e2da88830cd
--- a/src/gui/image/qpixmap_x11.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/gui/image/qpixmap_x11.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -314,8 +314,8 @@
 int Q_GUI_EXPORT qt_x11_preferred_pixmap_depth = 0;
 
 QX11PixmapData::QX11PixmapData(PixelType type)
-    : QPixmapData(type, X11Class), hd(0),
-      flags(Uninitialized), x11_mask(0), picture(0), mask_picture(0), hd2(0), gl_surface(0),
+    : QPixmapData(type, X11Class), gl_surface(0), hd(0),
+      flags(Uninitialized), x11_mask(0), picture(0), mask_picture(0), hd2(0),
       share_mode(QPixmap::ImplicitlyShared), pengine(0)
 {
 }
@@ -1142,7 +1142,7 @@
     }
 }
 
-void QX11PixmapData::bitmapFromImage(const QImage &image)
+Qt::HANDLE QX11PixmapData::createBitmapFromImage(const QImage &image)
 {
     QImage img = image.convertToFormat(QImage::Format_MonoLSB);
     const QRgb c0 = QColor(Qt::black).rgb();
@@ -1155,10 +1155,8 @@
 
     char  *bits;
     uchar *tmp_bits;
-    w = img.width();
-    h = img.height();
-    d = 1;
-    is_null = (w <= 0 || h <= 0);
+    int w = img.width();
+    int h = img.height();
     int bpl = (w + 7) / 8;
     int ibpl = img.bytesPerLine();
     if (bpl != ibpl) {
@@ -1177,18 +1175,26 @@
         bits = (char *)img.bits();
         tmp_bits = 0;
     }
-    hd = (Qt::HANDLE)XCreateBitmapFromData(xinfo.display(),
-                                           RootWindow(xinfo.display(), xinfo.screen()),
+    Qt::HANDLE hd = (Qt::HANDLE)XCreateBitmapFromData(X11->display,
+                                           QX11Info::appRootWindow(),
                                            bits, w, h);
+    if (tmp_bits)                                // Avoid purify complaint
+        delete [] tmp_bits;
+    return hd;
+}
 
+void QX11PixmapData::bitmapFromImage(const QImage &image)
+{
+    w = image.width();
+    h = image.height();
+    d = 1;
+    is_null = (w <= 0 || h <= 0);
+    hd = createBitmapFromImage(image);
 #ifndef QT_NO_XRENDER
     if (X11->use_xrender)
         picture = XRenderCreatePicture(X11->display, hd,
                                        XRenderFindStandardFormat(X11->display, PictStandardA1), 0, 0);
 #endif // QT_NO_XRENDER
-
-    if (tmp_bits)                                // Avoid purify complaint
-        delete [] tmp_bits;
 }
 
 void QX11PixmapData::fill(const QColor &fillColor)