an attempt to solve the "Status" as well as "QPaintEngine::X11" problem

unfortunetly some deeclarative sources still exhibit it, most of the
cruft is in private headers and I've not observed the problem as
often so this is nothing but a good start, to be continue..

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2017-08-09 11:51:23 +00:00
parent be048dee40
commit a78f51acfc
44 changed files with 1123 additions and 1134 deletions

View file

@ -616,12 +616,16 @@ add_subdirectory(src/sql)
add_subdirectory(src/svg) add_subdirectory(src/svg)
add_subdirectory(src/test) add_subdirectory(src/test)
add_subdirectory(src/uitools) add_subdirectory(src/uitools)
# generators
add_subdirectory(src/tools) add_subdirectory(src/tools)
# tests and benchmarks
if(ENABLE_TESTING) if(ENABLE_TESTING)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
# utilities needed for Katie maintainance # utilities for maintainance
if(KATIE_UTILS) if(KATIE_UTILS)
add_subdirectory(util) add_subdirectory(util)
endif() endif()

View file

@ -215,7 +215,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\enum QDataStream::StreamStatus \enum QDataStream::DataStatus
This enum describes the current status of the data stream. This enum describes the current status of the data stream.
@ -450,7 +450,7 @@ void QDataStream::setFloatingPointPrecision(QDataStream::FloatingPointPrecision
\sa Status setStatus() resetStatus() \sa Status setStatus() resetStatus()
*/ */
QDataStream::StreamStatus QDataStream::status() const QDataStream::DataStatus QDataStream::status() const
{ {
return q_status; return q_status;
} }
@ -473,7 +473,7 @@ void QDataStream::resetStatus()
\sa Status status() resetStatus() \sa Status status() resetStatus()
*/ */
void QDataStream::setStatus(StreamStatus status) void QDataStream::setStatus(DataStatus status)
{ {
if (q_status == Ok) if (q_status == Ok)
q_status = status; q_status = status;

View file

@ -86,7 +86,7 @@ public:
LittleEndian = QSysInfo::LittleEndian LittleEndian = QSysInfo::LittleEndian
}; };
enum StreamStatus { enum DataStatus {
Ok, Ok,
ReadPastEnd, ReadPastEnd,
ReadCorruptData, ReadCorruptData,
@ -109,8 +109,8 @@ public:
bool atEnd() const; bool atEnd() const;
StreamStatus status() const; DataStatus status() const;
void setStatus(StreamStatus status); void setStatus(DataStatus status);
void resetStatus(); void resetStatus();
FloatingPointPrecision floatingPointPrecision() const; FloatingPointPrecision floatingPointPrecision() const;
@ -168,7 +168,7 @@ private:
bool noswap; bool noswap;
ByteOrder byteorder; ByteOrder byteorder;
int ver; int ver;
StreamStatus q_status; DataStatus q_status;
}; };
@ -321,7 +321,7 @@ QDataStream& operator<<(QDataStream &out, const QSet<T> &set)
template <class Key, class T> template <class Key, class T>
Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QHash<Key, T> &hash) Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QHash<Key, T> &hash)
{ {
QDataStream::StreamStatus oldStatus = in.status(); QDataStream::DataStatus oldStatus = in.status();
in.resetStatus(); in.resetStatus();
hash.clear(); hash.clear();
@ -360,7 +360,7 @@ Q_OUTOFLINE_TEMPLATE QDataStream &operator<<(QDataStream &out, const QHash<Key,
template <class aKey, class aT> template <class aKey, class aT>
Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QMap<aKey, aT> &map) Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QMap<aKey, aT> &map)
{ {
QDataStream::StreamStatus oldStatus = in.status(); QDataStream::DataStatus oldStatus = in.status();
in.resetStatus(); in.resetStatus();
map.clear(); map.clear();

View file

@ -382,7 +382,7 @@ void QSettingsPrivate::beginGroupOrArray(const QSettingsGroup &group)
first error that occurred. We always allow clearing errors. first error that occurred. We always allow clearing errors.
*/ */
void QSettingsPrivate::setStatus(QSettings::Status status) const void QSettingsPrivate::setStatus(QSettings::SettingsStatus status) const
{ {
if (status == QSettings::NoError || this->status == QSettings::NoError) if (status == QSettings::NoError || this->status == QSettings::NoError)
this->status = status; this->status = status;
@ -2167,7 +2167,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
\sa QVariant, QSessionManager, {Settings Editor Example}, {Application Example} \sa QVariant, QSessionManager, {Settings Editor Example}, {Application Example}
*/ */
/*! \enum QSettings::Status /*! \enum QSettings::SettingsStatus
The following status values are possible: The following status values are possible:
@ -2635,7 +2635,7 @@ QTextCodec *QSettings::iniCodec() const
\sa sync() \sa sync()
*/ */
QSettings::Status QSettings::status() const QSettings::SettingsStatus QSettings::status() const
{ {
Q_D(const QSettings); Q_D(const QSettings);
return d->status; return d->status;

View file

@ -48,14 +48,8 @@ QT_BEGIN_HEADER
#ifndef QT_NO_SETTINGS #ifndef QT_NO_SETTINGS
#include <ctype.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#ifdef Status
#error qsettings.h must be included before any header file that defines Status
#endif
class QIODevice; class QIODevice;
class QSettingsPrivate; class QSettingsPrivate;
@ -73,7 +67,7 @@ class Q_CORE_EXPORT QSettings
Q_DECLARE_PRIVATE(QSettings) Q_DECLARE_PRIVATE(QSettings)
public: public:
enum Status { enum SettingsStatus {
NoError = 0, NoError = 0,
AccessError, AccessError,
FormatError FormatError
@ -113,7 +107,7 @@ public:
QSettings(Scope scope, const QString &organization, QSettings(Scope scope, const QString &organization,
const QString &application = QString(), QObject *parent = Q_NULLPTR); const QString &application = QString(), QObject *parent = Q_NULLPTR);
QSettings(Format format, Scope scope, const QString &organization, QSettings(Format format, Scope scope, const QString &organization,
const QString &application = QString(), QObject *parent = Q_NULLPTR); const QString &application = QString(), QObject *parent = Q_NULLPTR);
QSettings(const QString &fileName, Format format, QObject *parent = Q_NULLPTR); QSettings(const QString &fileName, Format format, QObject *parent = Q_NULLPTR);
explicit QSettings(QObject *parent = Q_NULLPTR); explicit QSettings(QObject *parent = Q_NULLPTR);
#else #else
@ -129,7 +123,7 @@ public:
void clear(); void clear();
void sync(); void sync();
Status status() const; SettingsStatus status() const;
void beginGroup(const QString &prefix); void beginGroup(const QString &prefix);
void endGroup(); void endGroup();

View file

@ -200,7 +200,7 @@ public:
QString actualKey(const QString &key) const; QString actualKey(const QString &key) const;
void beginGroupOrArray(const QSettingsGroup &group); void beginGroupOrArray(const QSettingsGroup &group);
void setStatus(QSettings::Status status) const; void setStatus(QSettings::SettingsStatus status) const;
void requestUpdate(); void requestUpdate();
void update(); void update();
@ -252,7 +252,7 @@ protected:
int spec; int spec;
bool fallbacks; bool fallbacks;
bool pendingChanges; bool pendingChanges;
mutable QSettings::Status status; mutable QSettings::SettingsStatus status;
}; };
class QConfFileSettingsPrivate : public QSettingsPrivate class QConfFileSettingsPrivate : public QSettingsPrivate

View file

@ -211,7 +211,7 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384;
\sa setNumberFlags() \sa setNumberFlags()
*/ */
/*! \enum QTextStream::Status /*! \enum QTextStream::TextStatus
This enum describes the current status of the text stream. This enum describes the current status of the text stream.
@ -419,7 +419,7 @@ public:
QTextStream::NumberFlags numberFlags; QTextStream::NumberFlags numberFlags;
// status // status
QTextStream::Status status; QTextStream::TextStatus status;
QLocale locale; QLocale locale;
@ -1534,10 +1534,10 @@ int QTextStream::realNumberPrecision() const
/*! /*!
Returns the status of the text stream. Returns the status of the text stream.
\sa QTextStream::Status, setStatus(), resetStatus() \sa QTextStream::TextStatus, setStatus(), resetStatus()
*/ */
QTextStream::Status QTextStream::status() const QTextStream::TextStatus QTextStream::status() const
{ {
Q_D(const QTextStream); Q_D(const QTextStream);
return d->status; return d->status;
@ -1548,7 +1548,7 @@ QTextStream::Status QTextStream::status() const
Resets the status of the text stream. Resets the status of the text stream.
\sa QTextStream::Status, status(), setStatus() \sa QTextStream::TextStatus, status(), setStatus()
*/ */
void QTextStream::resetStatus() void QTextStream::resetStatus()
{ {
@ -1564,9 +1564,9 @@ void QTextStream::resetStatus()
Subsequent calls to setStatus() are ignored until resetStatus() Subsequent calls to setStatus() are ignored until resetStatus()
is called. is called.
\sa Status status() resetStatus() \sa TextStatus status() resetStatus()
*/ */
void QTextStream::setStatus(Status status) void QTextStream::setStatus(TextStatus status)
{ {
Q_D(QTextStream); Q_D(QTextStream);
if (d->status == Ok) if (d->status == Ok)

View file

@ -46,10 +46,6 @@
#include <stdio.h> #include <stdio.h>
#ifdef Status
#error qtextstream.h must be included before any header file that defines Status
#endif
QT_BEGIN_HEADER QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -74,7 +70,7 @@ public:
AlignCenter, AlignCenter,
AlignAccountingStyle AlignAccountingStyle
}; };
enum Status { enum TextStatus {
Ok, Ok,
ReadPastEnd, ReadPastEnd,
ReadCorruptData, ReadCorruptData,
@ -116,8 +112,8 @@ public:
void setString(QString *string, QIODevice::OpenMode openMode = QIODevice::ReadWrite); void setString(QString *string, QIODevice::OpenMode openMode = QIODevice::ReadWrite);
QString *string() const; QString *string() const;
Status status() const; TextStatus status() const;
void setStatus(Status status); void setStatus(TextStatus status);
void resetStatus(); void resetStatus();
bool atEnd() const; bool atEnd() const;

View file

@ -674,7 +674,7 @@ void QDialog::adjustPosition(QWidget* w)
{ {
#ifdef Q_WS_X11 #ifdef Q_WS_X11
// if the WM advertises that it will place the windows properly for us, let it do it :) // if the WM advertises that it will place the windows properly for us, let it do it :)
if (X11->isSupportedByWM(ATOM(_NET_WM_FULL_PLACEMENT))) if (qt_x11Data->isSupportedByWM(ATOM(_NET_WM_FULL_PLACEMENT)))
return; return;
#endif #endif

View file

@ -4309,7 +4309,7 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
// Render directly, using no cache. // Render directly, using no cache.
if (cacheMode == QGraphicsItem::NoCache if (cacheMode == QGraphicsItem::NoCache
#ifdef Q_WS_X11 #ifdef Q_WS_X11
|| !X11->use_xrender || !qt_x11Data->use_xrender
#endif #endif
) { ) {
_q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget, true, painterStateProtection); _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget, true, painterStateProtection);

View file

@ -3338,7 +3338,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
// Draw background // Draw background
if ((d->cacheMode & CacheBackground) if ((d->cacheMode & CacheBackground)
#ifdef Q_WS_X11 #ifdef Q_WS_X11
&& X11->use_xrender && qt_x11Data->use_xrender
#endif #endif
) { ) {
// Recreate the background pixmap, and flag the whole background as // Recreate the background pixmap, and flag the whole background as
@ -3533,7 +3533,7 @@ void QGraphicsView::scrollContentsBy(int dx, int dy)
if ((d->cacheMode & CacheBackground) if ((d->cacheMode & CacheBackground)
#ifdef Q_WS_X11 #ifdef Q_WS_X11
&& X11->use_xrender && qt_x11Data->use_xrender
#endif #endif
) { ) {
// Scroll the background pixmap // Scroll the background pixmap

View file

@ -71,10 +71,10 @@ Q_GLOBAL_STATIC(QIconLoader, iconLoaderInstance)
static QString fallbackTheme() static QString fallbackTheme()
{ {
#ifdef Q_WS_X11 #ifdef Q_WS_X11
if (X11->desktopEnvironment == DE_GNOME) { if (qt_x11Data->desktopEnvironment == DE_GNOME) {
return QLatin1String("gnome"); return QLatin1String("gnome");
} else if (X11->desktopEnvironment == DE_KDE) { } else if (qt_x11Data->desktopEnvironment == DE_KDE) {
return X11->desktopVersion >= 4 return qt_x11Data->desktopVersion >= 4
? QString::fromLatin1("oxygen") ? QString::fromLatin1("oxygen")
: QString::fromLatin1("crystalsvg"); : QString::fromLatin1("crystalsvg");
} else { } else {

View file

@ -1750,7 +1750,7 @@ void QPixmap::detach()
// reset the cache data // reset the cache data
if (d->hd2) { if (d->hd2) {
XFreePixmap(X11->display, d->hd2); XFreePixmap(qt_x11Data->display, d->hd2);
d->hd2 = 0; d->hd2 = 0;
} }
} }

View file

@ -114,10 +114,10 @@ QBitmap QX11PixmapData::mask_to_bitmap(int screen) const
return QBitmap(); return QBitmap();
QPixmap::x11SetDefaultScreen(screen); QPixmap::x11SetDefaultScreen(screen);
QBitmap bm(w, h); QBitmap bm(w, h);
GC gc = XCreateGC(X11->display, bm.handle(), 0, 0); GC gc = XCreateGC(qt_x11Data->display, bm.handle(), 0, 0);
XCopyArea(X11->display, x11_mask, bm.handle(), gc, 0, 0, XCopyArea(qt_x11Data->display, x11_mask, bm.handle(), gc, 0, 0,
bm.data->width(), bm.data->height(), 0, 0); bm.data->width(), bm.data->height(), 0, 0);
XFreeGC(X11->display, gc); XFreeGC(qt_x11Data->display, gc);
return bm; return bm;
} }
@ -128,12 +128,12 @@ Qt::HANDLE QX11PixmapData::bitmap_to_mask(const QBitmap &bitmap, int screen)
QBitmap bm = bitmap; QBitmap bm = bitmap;
bm.x11SetScreen(screen); bm.x11SetScreen(screen);
Pixmap mask = XCreatePixmap(X11->display, RootWindow(X11->display, screen), Pixmap mask = XCreatePixmap(qt_x11Data->display, RootWindow(qt_x11Data->display, screen),
bm.data->width(), bm.data->height(), 1); bm.data->width(), bm.data->height(), 1);
GC gc = XCreateGC(X11->display, mask, 0, 0); GC gc = XCreateGC(qt_x11Data->display, mask, 0, 0);
XCopyArea(X11->display, bm.handle(), mask, gc, 0, 0, XCopyArea(qt_x11Data->display, bm.handle(), mask, gc, 0, 0,
bm.data->width(), bm.data->height(), 0, 0); bm.data->width(), bm.data->height(), 0, 0);
XFreeGC(X11->display, gc); XFreeGC(qt_x11Data->display, gc);
return mask; return mask;
} }
@ -346,15 +346,15 @@ void QX11PixmapData::resize(int width, int height)
qWarning("QPixmap: Invalid pixmap parameters"); qWarning("QPixmap: Invalid pixmap parameters");
return; return;
} }
hd = (Qt::HANDLE)XCreatePixmap(X11->display, hd = (Qt::HANDLE)XCreatePixmap(qt_x11Data->display,
RootWindow(X11->display, xinfo.screen()), RootWindow(qt_x11Data->display, xinfo.screen()),
w, h, d); w, h, d);
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (X11->use_xrender) { if (qt_x11Data->use_xrender) {
XRenderPictFormat *format = d == 1 XRenderPictFormat *format = d == 1
? XRenderFindStandardFormat(X11->display, PictStandardA1) ? XRenderFindStandardFormat(qt_x11Data->display, PictStandardA1)
: XRenderFindVisualFormat(X11->display, (Visual *)xinfo.visual()); : XRenderFindVisualFormat(qt_x11Data->display, (Visual *)xinfo.visual());
picture = XRenderCreatePicture(X11->display, hd, format, 0, 0); picture = XRenderCreatePicture(qt_x11Data->display, hd, format, 0, 0);
} }
#endif // QT_NO_XRENDER #endif // QT_NO_XRENDER
} }
@ -371,7 +371,7 @@ struct QX11AlphaDetector
} }
bool hasXRenderAndAlpha() const { bool hasXRenderAndAlpha() const {
if (!X11->use_xrender) if (!qt_x11Data->use_xrender)
return false; return false;
return hasAlpha(); return hasAlpha();
} }
@ -474,7 +474,7 @@ void QX11PixmapData::fromImage(const QImage &img,
return; return;
} }
Display *dpy = X11->display; Display *dpy = qt_x11Data->display;
Visual *visual = (Visual *)xinfo.visual(); Visual *visual = (Visual *)xinfo.visual();
XImage *xi = 0; XImage *xi = 0;
bool trucol = (visual->c_class >= TrueColor); bool trucol = (visual->c_class >= TrueColor);
@ -505,8 +505,8 @@ void QX11PixmapData::fromImage(const QImage &img,
hd = (Qt::HANDLE)XCreatePixmap(dpy, RootWindow(dpy, xinfo.screen()), hd = (Qt::HANDLE)XCreatePixmap(dpy, RootWindow(dpy, xinfo.screen()),
w, h, d); w, h, d);
picture = XRenderCreatePicture(X11->display, hd, picture = XRenderCreatePicture(qt_x11Data->display, hd,
XRenderFindStandardFormat(X11->display, PictStandardARGB32), 0, 0); XRenderFindStandardFormat(qt_x11Data->display, PictStandardARGB32), 0, 0);
xi = XCreateImage(dpy, visual, d, ZPixmap, 0, 0, w, h, 32, 0); xi = XCreateImage(dpy, visual, d, ZPixmap, 0, 0, w, h, 32, 0);
Q_CHECK_PTR(xi); Q_CHECK_PTR(xi);
@ -1107,8 +1107,8 @@ void QX11PixmapData::fromImage(const QImage &img,
xi->data = (char *)newbits; xi->data = (char *)newbits;
} }
hd = (Qt::HANDLE)XCreatePixmap(X11->display, hd = (Qt::HANDLE)XCreatePixmap(qt_x11Data->display,
RootWindow(X11->display, xinfo.screen()), RootWindow(qt_x11Data->display, xinfo.screen()),
w, h, dd); w, h, dd);
GC gc = XCreateGC(dpy, hd, 0, 0); GC gc = XCreateGC(dpy, hd, 0, 0);
@ -1119,11 +1119,11 @@ void QX11PixmapData::fromImage(const QImage &img,
d = dd; d = dd;
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (X11->use_xrender) { if (qt_x11Data->use_xrender) {
XRenderPictFormat *format = d == 1 XRenderPictFormat *format = d == 1
? XRenderFindStandardFormat(X11->display, PictStandardA1) ? XRenderFindStandardFormat(qt_x11Data->display, PictStandardA1)
: XRenderFindVisualFormat(X11->display, (Visual *)xinfo.visual()); : XRenderFindVisualFormat(qt_x11Data->display, (Visual *)xinfo.visual());
picture = XRenderCreatePicture(X11->display, hd, format, 0, 0); picture = XRenderCreatePicture(qt_x11Data->display, hd, format, 0, 0);
} }
#endif #endif
@ -1166,7 +1166,7 @@ Qt::HANDLE QX11PixmapData::createBitmapFromImage(const QImage &image)
bits = (char *)img.bits(); bits = (char *)img.bits();
tmp_bits = 0; tmp_bits = 0;
} }
Qt::HANDLE hd = (Qt::HANDLE)XCreateBitmapFromData(X11->display, Qt::HANDLE hd = (Qt::HANDLE)XCreateBitmapFromData(qt_x11Data->display,
QX11Info::appRootWindow(), QX11Info::appRootWindow(),
bits, w, h); bits, w, h);
if (tmp_bits) // Avoid purify complaint if (tmp_bits) // Avoid purify complaint
@ -1182,9 +1182,9 @@ void QX11PixmapData::bitmapFromImage(const QImage &image)
is_null = (w <= 0 || h <= 0); is_null = (w <= 0 || h <= 0);
hd = createBitmapFromImage(image); hd = createBitmapFromImage(image);
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (X11->use_xrender) if (qt_x11Data->use_xrender)
picture = XRenderCreatePicture(X11->display, hd, picture = XRenderCreatePicture(qt_x11Data->display, hd,
XRenderFindStandardFormat(X11->display, PictStandardA1), 0, 0); XRenderFindStandardFormat(qt_x11Data->display, PictStandardA1), 0, 0);
#endif // QT_NO_XRENDER #endif // QT_NO_XRENDER
} }
@ -1192,12 +1192,12 @@ void QX11PixmapData::fill(const QColor &fillColor)
{ {
if (fillColor.alpha() != 255) { if (fillColor.alpha() != 255) {
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (X11->use_xrender) { if (qt_x11Data->use_xrender) {
if (!picture || d != 32) if (!picture || d != 32)
convertToARGB32(/*preserveContents = */false); convertToARGB32(/*preserveContents = */false);
::Picture src = X11->getSolidFill(xinfo.screen(), fillColor); ::Picture src = qt_x11Data->getSolidFill(xinfo.screen(), fillColor);
XRenderComposite(X11->display, PictOpSrc, src, 0, picture, XRenderComposite(qt_x11Data->display, PictOpSrc, src, 0, picture,
0, 0, width(), height(), 0, 0, width(), height(),
0, 0, width(), height()); 0, 0, width(), height());
} else } else
@ -1211,17 +1211,17 @@ void QX11PixmapData::fill(const QColor &fillColor)
return; return;
} }
GC gc = XCreateGC(X11->display, hd, 0, 0); GC gc = XCreateGC(qt_x11Data->display, hd, 0, 0);
if (depth() == 1) { if (depth() == 1) {
XSetForeground(X11->display, gc, qGray(fillColor.rgb()) > 127 ? 0 : 1); XSetForeground(qt_x11Data->display, gc, qGray(fillColor.rgb()) > 127 ? 0 : 1);
} else if (X11->use_xrender && d >= 24) { } else if (qt_x11Data->use_xrender && d >= 24) {
XSetForeground(X11->display, gc, fillColor.rgba()); XSetForeground(qt_x11Data->display, gc, fillColor.rgba());
} else { } else {
XSetForeground(X11->display, gc, XSetForeground(qt_x11Data->display, gc,
QColormap::instance(xinfo.screen()).pixel(fillColor)); QColormap::instance(xinfo.screen()).pixel(fillColor));
} }
XFillRectangle(X11->display, hd, gc, 0, 0, width(), height()); XFillRectangle(qt_x11Data->display, hd, gc, 0, 0, width(), height());
XFreeGC(X11->display, gc); XFreeGC(qt_x11Data->display, gc);
} }
QX11PixmapData::~QX11PixmapData() QX11PixmapData::~QX11PixmapData()
@ -1234,7 +1234,7 @@ void QX11PixmapData::release()
delete pengine; delete pengine;
pengine = 0; pengine = 0;
if (!X11) { if (!qt_x11Data) {
// At this point, the X server will already have freed our resources, // At this point, the X server will already have freed our resources,
// so there is nothing to do. // so there is nothing to do.
return; return;
@ -1243,17 +1243,17 @@ void QX11PixmapData::release()
if (x11_mask) { if (x11_mask) {
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (mask_picture) if (mask_picture)
XRenderFreePicture(X11->display, mask_picture); XRenderFreePicture(qt_x11Data->display, mask_picture);
mask_picture = 0; mask_picture = 0;
#endif #endif
XFreePixmap(X11->display, x11_mask); XFreePixmap(qt_x11Data->display, x11_mask);
x11_mask = 0; x11_mask = 0;
} }
if (hd) { if (hd) {
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (picture) { if (picture) {
XRenderFreePicture(X11->display, picture); XRenderFreePicture(qt_x11Data->display, picture);
picture = 0; picture = 0;
} }
#endif // QT_NO_XRENDER #endif // QT_NO_XRENDER
@ -1335,7 +1335,7 @@ void QX11PixmapData::setMask(const QBitmap &newmask)
QX11PixmapData newData(pixelType()); QX11PixmapData newData(pixelType());
newData.resize(w, h); newData.resize(w, h);
newData.fill(Qt::black); newData.fill(Qt::black);
XRenderComposite(X11->display, PictOpOver, XRenderComposite(qt_x11Data->display, PictOpOver,
picture, 0, newData.picture, picture, 0, newData.picture,
0, 0, 0, 0, 0, 0, w, h); 0, 0, 0, 0, 0, 0, w, h);
release(); release();
@ -1358,14 +1358,14 @@ void QX11PixmapData::setMask(const QBitmap &newmask)
if (picture) { if (picture) {
XRenderPictureAttributes attrs; XRenderPictureAttributes attrs;
attrs.alpha_map = 0; attrs.alpha_map = 0;
XRenderChangePicture(X11->display, picture, CPAlphaMap, XRenderChangePicture(qt_x11Data->display, picture, CPAlphaMap,
&attrs); &attrs);
} }
if (mask_picture) if (mask_picture)
XRenderFreePicture(X11->display, mask_picture); XRenderFreePicture(qt_x11Data->display, mask_picture);
mask_picture = 0; mask_picture = 0;
#endif #endif
XFreePixmap(X11->display, x11_mask); XFreePixmap(qt_x11Data->display, x11_mask);
x11_mask = 0; x11_mask = 0;
} }
return; return;
@ -1373,7 +1373,7 @@ void QX11PixmapData::setMask(const QBitmap &newmask)
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (picture && d == 32) { if (picture && d == 32) {
XRenderComposite(X11->display, PictOpSrc, XRenderComposite(qt_x11Data->display, PictOpSrc,
picture, newmask.x11PictureHandle(), picture, newmask.x11PictureHandle(),
picture, 0, 0, 0, 0, 0, 0, w, h); picture, 0, 0, 0, 0, 0, 0, w, h);
} else } else
@ -1381,27 +1381,27 @@ void QX11PixmapData::setMask(const QBitmap &newmask)
if (depth() == 1) { if (depth() == 1) {
XGCValues vals; XGCValues vals;
vals.function = GXand; vals.function = GXand;
GC gc = XCreateGC(X11->display, hd, GCFunction, &vals); GC gc = XCreateGC(qt_x11Data->display, hd, GCFunction, &vals);
XCopyArea(X11->display, newmask.handle(), hd, gc, 0, 0, XCopyArea(qt_x11Data->display, newmask.handle(), hd, gc, 0, 0,
width(), height(), 0, 0); width(), height(), 0, 0);
XFreeGC(X11->display, gc); XFreeGC(qt_x11Data->display, gc);
} else { } else {
// ##### should or the masks together // ##### should or the masks together
if (x11_mask) { if (x11_mask) {
XFreePixmap(X11->display, x11_mask); XFreePixmap(qt_x11Data->display, x11_mask);
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (mask_picture) if (mask_picture)
XRenderFreePicture(X11->display, mask_picture); XRenderFreePicture(qt_x11Data->display, mask_picture);
#endif #endif
} }
x11_mask = QX11PixmapData::bitmap_to_mask(newmask, xinfo.screen()); x11_mask = QX11PixmapData::bitmap_to_mask(newmask, xinfo.screen());
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (picture) { if (picture) {
mask_picture = XRenderCreatePicture(X11->display, x11_mask, mask_picture = XRenderCreatePicture(qt_x11Data->display, x11_mask,
XRenderFindStandardFormat(X11->display, PictStandardA1), 0, 0); XRenderFindStandardFormat(qt_x11Data->display, PictStandardA1), 0, 0);
XRenderPictureAttributes attrs; XRenderPictureAttributes attrs;
attrs.alpha_map = mask_picture; attrs.alpha_map = mask_picture;
XRenderChangePicture(X11->display, picture, CPAlphaMap, &attrs); XRenderChangePicture(qt_x11Data->display, picture, CPAlphaMap, &attrs);
} }
#endif #endif
} }
@ -1420,14 +1420,14 @@ int QX11PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
return d; return d;
case QPaintDevice::PdmWidthMM: { case QPaintDevice::PdmWidthMM: {
const int screen = xinfo.screen(); const int screen = xinfo.screen();
const int mm = DisplayWidthMM(X11->display, screen) * w const int mm = DisplayWidthMM(qt_x11Data->display, screen) * w
/ DisplayWidth(X11->display, screen); / DisplayWidth(qt_x11Data->display, screen);
return mm; return mm;
} }
case QPaintDevice::PdmHeightMM: { case QPaintDevice::PdmHeightMM: {
const int screen = xinfo.screen(); const int screen = xinfo.screen();
const int mm = (DisplayHeightMM(X11->display, screen) * h) const int mm = (DisplayHeightMM(qt_x11Data->display, screen) * h)
/ DisplayHeight(X11->display, screen); / DisplayHeight(qt_x11Data->display, screen);
return mm; return mm;
} }
case QPaintDevice::PdmDpiX: case QPaintDevice::PdmDpiX:
@ -1526,7 +1526,7 @@ QImage QX11PixmapData::takeQImageFromXImage(const QXImageWrapper &xiWrapper) con
QImage QX11PixmapData::toImage(const QRect &rect) const QImage QX11PixmapData::toImage(const QRect &rect) const
{ {
QXImageWrapper xiWrapper; QXImageWrapper xiWrapper;
xiWrapper.xi = XGetImage(X11->display, hd, rect.x(), rect.y(), rect.width(), rect.height(), xiWrapper.xi = XGetImage(qt_x11Data->display, hd, rect.x(), rect.y(), rect.width(), rect.height(),
AllPlanes, (depth() == 1) ? XYPixmap : ZPixmap); AllPlanes, (depth() == 1) ? XYPixmap : ZPixmap);
Q_CHECK_PTR(xiWrapper.xi); Q_CHECK_PTR(xiWrapper.xi);
@ -1854,7 +1854,7 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform,
int sbpl; // bytes per line in original int sbpl; // bytes per line in original
int bpp; // bits per pixel int bpp; // bits per pixel
bool depth1 = depth() == 1; bool depth1 = depth() == 1;
Display *dpy = X11->display; Display *dpy = qt_x11Data->display;
ws = width(); ws = width();
hs = height(); hs = height();
@ -1902,7 +1902,7 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform,
bool use_mitshm = xshmimg && !depth1 && bool use_mitshm = xshmimg && !depth1 &&
xshmimg->width >= w && xshmimg->height >= h; xshmimg->width >= w && xshmimg->height >= h;
#endif #endif
XImage *xi = XGetImage(X11->display, handle(), 0, 0, ws, hs, AllPlanes, XImage *xi = XGetImage(qt_x11Data->display, handle(), 0, 0, ws, hs, AllPlanes,
depth1 ? XYPixmap : ZPixmap); depth1 ? XYPixmap : ZPixmap);
if (!xi) if (!xi)
@ -1931,7 +1931,7 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform,
if (depth1) // fill with zeros if (depth1) // fill with zeros
memset(dptr, 0, dbytes); memset(dptr, 0, dbytes);
else if (bpp == 8) // fill with background color else if (bpp == 8) // fill with background color
memset(dptr, WhitePixel(X11->display, xinfo.screen()), dbytes); memset(dptr, WhitePixel(qt_x11Data->display, xinfo.screen()), dbytes);
else else
memset(dptr, 0, dbytes); memset(dptr, 0, dbytes);
#if defined(QT_MITSHM) #if defined(QT_MITSHM)
@ -1981,7 +1981,7 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform,
if (depth1) { // mono bitmap if (depth1) { // mono bitmap
QBitmap bm = QBitmap::fromData(QSize(w, h), dptr, QBitmap bm = QBitmap::fromData(QSize(w, h), dptr,
BitmapBitOrder(X11->display) == MSBFirst BitmapBitOrder(qt_x11Data->display) == MSBFirst
? QImage::Format_Mono ? QImage::Format_Mono
: QImage::Format_MonoLSB); : QImage::Format_MonoLSB);
free(dptr); free(dptr);
@ -1995,21 +1995,21 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform,
x11Data->w = w; x11Data->w = w;
x11Data->h = h; x11Data->h = h;
x11Data->is_null = (w <= 0 || h <= 0); x11Data->is_null = (w <= 0 || h <= 0);
x11Data->hd = (Qt::HANDLE)XCreatePixmap(X11->display, x11Data->hd = (Qt::HANDLE)XCreatePixmap(qt_x11Data->display,
RootWindow(X11->display, xinfo.screen()), RootWindow(qt_x11Data->display, xinfo.screen()),
w, h, d); w, h, d);
x11Data->setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1)); x11Data->setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1));
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (X11->use_xrender) { if (qt_x11Data->use_xrender) {
XRenderPictFormat *format = x11Data->d == 32 XRenderPictFormat *format = x11Data->d == 32
? XRenderFindStandardFormat(X11->display, PictStandardARGB32) ? XRenderFindStandardFormat(qt_x11Data->display, PictStandardARGB32)
: XRenderFindVisualFormat(X11->display, (Visual *) x11Data->xinfo.visual()); : XRenderFindVisualFormat(qt_x11Data->display, (Visual *) x11Data->xinfo.visual());
x11Data->picture = XRenderCreatePicture(X11->display, x11Data->hd, format, 0, 0); x11Data->picture = XRenderCreatePicture(qt_x11Data->display, x11Data->hd, format, 0, 0);
} }
#endif // QT_NO_XRENDER #endif // QT_NO_XRENDER
GC gc = XCreateGC(X11->display, x11Data->hd, 0, 0); GC gc = XCreateGC(qt_x11Data->display, x11Data->hd, 0, 0);
#if defined(QT_MITSHM) #if defined(QT_MITSHM)
if (use_mitshm) { if (use_mitshm) {
XCopyArea(dpy, xshmpm, x11Data->hd, gc, 0, 0, w, h, 0, 0); XCopyArea(dpy, xshmpm, x11Data->hd, gc, 0, 0, w, h, 0, 0);
@ -2022,7 +2022,7 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform,
XPutImage(dpy, pm.handle(), gc, xi, 0, 0, 0, 0, w, h); XPutImage(dpy, pm.handle(), gc, xi, 0, 0, 0, 0, w, h);
qSafeXDestroyImage(xi); qSafeXDestroyImage(xi);
} }
XFreeGC(X11->display, gc); XFreeGC(qt_x11Data->display, gc);
if (x11_mask) { // xform mask, too if (x11_mask) { // xform mask, too
pm.setMask(mask_to_bitmap(xinfo.screen()).transformed(transform)); pm.setMask(mask_to_bitmap(xinfo.screen()).transformed(transform));
@ -2087,7 +2087,7 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
if (w == 0 || h == 0) if (w == 0 || h == 0)
return QPixmap(); return QPixmap();
Display *dpy = X11->display; Display *dpy = qt_x11Data->display;
XWindowAttributes window_attr; XWindowAttributes window_attr;
if (!XGetWindowAttributes(dpy, window, &window_attr)) if (!XGetWindowAttributes(dpy, window, &window_attr))
return QPixmap(); return QPixmap();
@ -2166,11 +2166,11 @@ const QX11Info &QPixmap::x11Info() const
static XRenderPictFormat *qt_renderformat_for_depth(const QX11Info &xinfo, int depth) static XRenderPictFormat *qt_renderformat_for_depth(const QX11Info &xinfo, int depth)
{ {
if (depth == 1) if (depth == 1)
return XRenderFindStandardFormat(X11->display, PictStandardA1); return XRenderFindStandardFormat(qt_x11Data->display, PictStandardA1);
else if (depth == 32) else if (depth == 32)
return XRenderFindStandardFormat(X11->display, PictStandardARGB32); return XRenderFindStandardFormat(qt_x11Data->display, PictStandardARGB32);
else else
return XRenderFindVisualFormat(X11->display, (Visual *)xinfo.visual()); return XRenderFindVisualFormat(qt_x11Data->display, (Visual *)xinfo.visual());
} }
#endif #endif
@ -2181,25 +2181,25 @@ QPaintEngine* QX11PixmapData::paintEngine() const
if ((flags & Readonly) && share_mode == QPixmap::ImplicitlyShared) { if ((flags & Readonly) && share_mode == QPixmap::ImplicitlyShared) {
// if someone wants to draw onto us, copy the shared contents // if someone wants to draw onto us, copy the shared contents
// and turn it into a fully fledged QPixmap // and turn it into a fully fledged QPixmap
::Pixmap hd_copy = XCreatePixmap(X11->display, RootWindow(X11->display, xinfo.screen()), ::Pixmap hd_copy = XCreatePixmap(qt_x11Data->display, RootWindow(qt_x11Data->display, xinfo.screen()),
w, h, d); w, h, d);
#if !defined(QT_NO_XRENDER) #if !defined(QT_NO_XRENDER)
if (picture && d == 32) { if (picture && d == 32) {
XRenderPictFormat *format = qt_renderformat_for_depth(xinfo, d); XRenderPictFormat *format = qt_renderformat_for_depth(xinfo, d);
::Picture picture_copy = XRenderCreatePicture(X11->display, ::Picture picture_copy = XRenderCreatePicture(qt_x11Data->display,
hd_copy, format, hd_copy, format,
0, 0); 0, 0);
XRenderComposite(X11->display, PictOpSrc, picture, 0, picture_copy, XRenderComposite(qt_x11Data->display, PictOpSrc, picture, 0, picture_copy,
0, 0, 0, 0, 0, 0, w, h); 0, 0, 0, 0, 0, 0, w, h);
XRenderFreePicture(X11->display, picture); XRenderFreePicture(qt_x11Data->display, picture);
that->picture = picture_copy; that->picture = picture_copy;
} else } else
#endif #endif
{ {
GC gc = XCreateGC(X11->display, hd_copy, 0, 0); GC gc = XCreateGC(qt_x11Data->display, hd_copy, 0, 0);
XCopyArea(X11->display, hd, hd_copy, gc, 0, 0, w, h, 0, 0); XCopyArea(qt_x11Data->display, hd, hd_copy, gc, 0, 0, w, h, 0, 0);
XFreeGC(X11->display, gc); XFreeGC(qt_x11Data->display, gc);
} }
that->hd = hd_copy; that->hd = hd_copy;
that->flags &= ~QX11PixmapData::Readonly; that->flags &= ~QX11PixmapData::Readonly;
@ -2225,7 +2225,7 @@ Qt::HANDLE QPixmap::x11PictureHandle() const
Qt::HANDLE QX11PixmapData::x11ConvertToDefaultDepth() Qt::HANDLE QX11PixmapData::x11ConvertToDefaultDepth()
{ {
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (d == QX11Info::appDepth() || !X11->use_xrender) if (d == QX11Info::appDepth() || !qt_x11Data->use_xrender)
return hd; return hd;
if (!hd2) { if (!hd2) {
hd2 = XCreatePixmap(xinfo.display(), hd, w, h, QX11Info::appDepth()); hd2 = XCreatePixmap(xinfo.display(), hd, w, h, QX11Info::appDepth());
@ -2259,87 +2259,87 @@ void QX11PixmapData::copy(const QPixmapData *data, const QRect &rect)
w = rect.width(); w = rect.width();
h = rect.height(); h = rect.height();
is_null = (w <= 0 || h <= 0); is_null = (w <= 0 || h <= 0);
hd = (Qt::HANDLE)XCreatePixmap(X11->display, hd = (Qt::HANDLE)XCreatePixmap(qt_x11Data->display,
RootWindow(X11->display, x11Data->xinfo.screen()), RootWindow(qt_x11Data->display, x11Data->xinfo.screen()),
w, h, d); w, h, d);
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (X11->use_xrender) { if (qt_x11Data->use_xrender) {
XRenderPictFormat *format = d == 32 XRenderPictFormat *format = d == 32
? XRenderFindStandardFormat(X11->display, PictStandardARGB32) ? XRenderFindStandardFormat(qt_x11Data->display, PictStandardARGB32)
: XRenderFindVisualFormat(X11->display, (Visual *)xinfo.visual()); : XRenderFindVisualFormat(qt_x11Data->display, (Visual *)xinfo.visual());
picture = XRenderCreatePicture(X11->display, hd, format, 0, 0); picture = XRenderCreatePicture(qt_x11Data->display, hd, format, 0, 0);
} }
#endif // QT_NO_XRENDER #endif // QT_NO_XRENDER
if (x11Data->x11_mask) { if (x11Data->x11_mask) {
x11_mask = XCreatePixmap(X11->display, hd, w, h, 1); x11_mask = XCreatePixmap(qt_x11Data->display, hd, w, h, 1);
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (X11->use_xrender) { if (qt_x11Data->use_xrender) {
mask_picture = XRenderCreatePicture(X11->display, x11_mask, mask_picture = XRenderCreatePicture(qt_x11Data->display, x11_mask,
XRenderFindStandardFormat(X11->display, PictStandardA1), 0, 0); XRenderFindStandardFormat(qt_x11Data->display, PictStandardA1), 0, 0);
XRenderPictureAttributes attrs; XRenderPictureAttributes attrs;
attrs.alpha_map = x11Data->mask_picture; attrs.alpha_map = x11Data->mask_picture;
XRenderChangePicture(X11->display, x11Data->picture, CPAlphaMap, &attrs); XRenderChangePicture(qt_x11Data->display, x11Data->picture, CPAlphaMap, &attrs);
} }
#endif #endif
} }
#if !defined(QT_NO_XRENDER) #if !defined(QT_NO_XRENDER)
if (x11Data->picture && x11Data->d == 32) { if (x11Data->picture && x11Data->d == 32) {
XRenderComposite(X11->display, PictOpSrc, XRenderComposite(qt_x11Data->display, PictOpSrc,
x11Data->picture, 0, picture, x11Data->picture, 0, picture,
rect.x(), rect.y(), 0, 0, 0, 0, w, h); rect.x(), rect.y(), 0, 0, 0, 0, w, h);
} else } else
#endif #endif
{ {
GC gc = XCreateGC(X11->display, hd, 0, 0); GC gc = XCreateGC(qt_x11Data->display, hd, 0, 0);
XCopyArea(X11->display, x11Data->hd, hd, gc, XCopyArea(qt_x11Data->display, x11Data->hd, hd, gc,
rect.x(), rect.y(), w, h, 0, 0); rect.x(), rect.y(), w, h, 0, 0);
if (x11Data->x11_mask) { if (x11Data->x11_mask) {
GC monogc = XCreateGC(X11->display, x11_mask, 0, 0); GC monogc = XCreateGC(qt_x11Data->display, x11_mask, 0, 0);
XCopyArea(X11->display, x11Data->x11_mask, x11_mask, monogc, XCopyArea(qt_x11Data->display, x11Data->x11_mask, x11_mask, monogc,
rect.x(), rect.y(), w, h, 0, 0); rect.x(), rect.y(), w, h, 0, 0);
XFreeGC(X11->display, monogc); XFreeGC(qt_x11Data->display, monogc);
} }
XFreeGC(X11->display, gc); XFreeGC(qt_x11Data->display, gc);
} }
} }
bool QX11PixmapData::scroll(int dx, int dy, const QRect &rect) bool QX11PixmapData::scroll(int dx, int dy, const QRect &rect)
{ {
GC gc = XCreateGC(X11->display, hd, 0, 0); GC gc = XCreateGC(qt_x11Data->display, hd, 0, 0);
XCopyArea(X11->display, hd, hd, gc, XCopyArea(qt_x11Data->display, hd, hd, gc,
rect.left(), rect.top(), rect.width(), rect.height(), rect.left(), rect.top(), rect.width(), rect.height(),
rect.left() + dx, rect.top() + dy); rect.left() + dx, rect.top() + dy);
XFreeGC(X11->display, gc); XFreeGC(qt_x11Data->display, gc);
return true; return true;
} }
#if !defined(QT_NO_XRENDER) #if !defined(QT_NO_XRENDER)
void QX11PixmapData::convertToARGB32(bool preserveContents) void QX11PixmapData::convertToARGB32(bool preserveContents)
{ {
if (!X11->use_xrender) if (!qt_x11Data->use_xrender)
return; return;
// Q_ASSERT(count == 1); // Q_ASSERT(count == 1);
if ((flags & Readonly) && share_mode == QPixmap::ExplicitlyShared) if ((flags & Readonly) && share_mode == QPixmap::ExplicitlyShared)
return; return;
Pixmap pm = XCreatePixmap(X11->display, RootWindow(X11->display, xinfo.screen()), Pixmap pm = XCreatePixmap(qt_x11Data->display, RootWindow(qt_x11Data->display, xinfo.screen()),
w, h, 32); w, h, 32);
Picture p = XRenderCreatePicture(X11->display, pm, Picture p = XRenderCreatePicture(qt_x11Data->display, pm,
XRenderFindStandardFormat(X11->display, PictStandardARGB32), 0, 0); XRenderFindStandardFormat(qt_x11Data->display, PictStandardARGB32), 0, 0);
if (picture) { if (picture) {
if (preserveContents) if (preserveContents)
XRenderComposite(X11->display, PictOpSrc, picture, 0, p, 0, 0, 0, 0, 0, 0, w, h); XRenderComposite(qt_x11Data->display, PictOpSrc, picture, 0, p, 0, 0, 0, 0, 0, 0, w, h);
if (!(flags & Readonly)) if (!(flags & Readonly))
XRenderFreePicture(X11->display, picture); XRenderFreePicture(qt_x11Data->display, picture);
} }
if (hd && !(flags & Readonly)) if (hd && !(flags & Readonly))
XFreePixmap(X11->display, hd); XFreePixmap(qt_x11Data->display, hd);
if (x11_mask) { if (x11_mask) {
XFreePixmap(X11->display, x11_mask); XFreePixmap(qt_x11Data->display, x11_mask);
if (mask_picture) if (mask_picture)
XRenderFreePicture(X11->display, mask_picture); XRenderFreePicture(qt_x11Data->display, mask_picture);
x11_mask = 0; x11_mask = 0;
mask_picture = 0; mask_picture = 0;
} }
@ -2359,14 +2359,14 @@ QPixmap QPixmap::fromX11Pixmap(Qt::HANDLE pixmap, QPixmap::ShareMode mode)
uint border_width; uint border_width;
uint depth; uint depth;
XWindowAttributes win_attribs; XWindowAttributes win_attribs;
int num_screens = ScreenCount(X11->display); int num_screens = ScreenCount(qt_x11Data->display);
int screen = 0; int screen = 0;
XGetGeometry(X11->display, pixmap, &root, &x, &y, &width, &height, &border_width, &depth); XGetGeometry(qt_x11Data->display, pixmap, &root, &x, &y, &width, &height, &border_width, &depth);
XGetWindowAttributes(X11->display, root, &win_attribs); XGetWindowAttributes(qt_x11Data->display, root, &win_attribs);
for (; screen < num_screens; ++screen) { for (; screen < num_screens; ++screen) {
if (win_attribs.screen == ScreenOfDisplay(X11->display, screen)) if (win_attribs.screen == ScreenOfDisplay(qt_x11Data->display, screen))
break; break;
} }
@ -2393,9 +2393,9 @@ QPixmap QPixmap::fromX11Pixmap(Qt::HANDLE pixmap, QPixmap::ShareMode mode)
} }
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (X11->use_xrender) { if (qt_x11Data->use_xrender) {
XRenderPictFormat *format = qt_renderformat_for_depth(data->xinfo, depth); XRenderPictFormat *format = qt_renderformat_for_depth(data->xinfo, depth);
data->picture = XRenderCreatePicture(X11->display, data->hd, format, 0, 0); data->picture = XRenderCreatePicture(qt_x11Data->display, data->hd, format, 0, 0);
} }
#endif // QT_NO_XRENDER #endif // QT_NO_XRENDER

View file

@ -4604,11 +4604,11 @@ uint QApplicationPrivate::currentPlatform(){
uint platform = KB_None; uint platform = KB_None;
#if defined Q_WS_X11 #if defined Q_WS_X11
platform = KB_X11; platform = KB_X11;
if (X11->desktopEnvironment == DE_KDE) if (qt_x11Data->desktopEnvironment == DE_KDE)
platform |= KB_KDE; platform |= KB_KDE;
if (X11->desktopEnvironment == DE_GNOME) if (qt_x11Data->desktopEnvironment == DE_GNOME)
platform |= KB_Gnome; platform |= KB_Gnome;
if (X11->desktopEnvironment == DE_CDE) if (qt_x11Data->desktopEnvironment == DE_CDE)
platform |= KB_CDE; platform |= KB_CDE;
#endif #endif
return platform; return platform;

File diff suppressed because it is too large Load diff

View file

@ -306,7 +306,7 @@ QClipboardINCRTransaction::QClipboardINCRTransaction(Window w, Atom p, Atom t, i
{ {
DEBUG("QClipboard: sending %d bytes (INCR transaction %p)", d.size(), this); DEBUG("QClipboard: sending %d bytes (INCR transaction %p)", d.size(), this);
XSelectInput(X11->display, window, PropertyChangeMask); XSelectInput(qt_x11Data->display, window, PropertyChangeMask);
if (! transactions) { if (! transactions) {
VDEBUG("QClipboard: created INCR transaction map"); VDEBUG("QClipboard: created INCR transaction map");
@ -321,7 +321,7 @@ QClipboardINCRTransaction::~QClipboardINCRTransaction(void)
{ {
VDEBUG("QClipboard: destroyed INCR transacton %p", this); VDEBUG("QClipboard: destroyed INCR transacton %p", this);
XSelectInput(X11->display, window, NoEventMask); XSelectInput(qt_x11Data->display, window, NoEventMask);
transactions->remove(window); transactions->remove(window);
if (transactions->isEmpty()) { if (transactions->isEmpty()) {
@ -355,12 +355,12 @@ int QClipboardINCRTransaction::x11Event(XEvent *event)
VDEBUG("QClipboard: sending %d bytes, %d remaining (INCR transaction %p)", VDEBUG("QClipboard: sending %d bytes, %d remaining (INCR transaction %p)",
xfer, bytes_left - xfer, this); xfer, bytes_left - xfer, this);
XChangeProperty(X11->display, window, property, target, format, XChangeProperty(qt_x11Data->display, window, property, target, format,
PropModeReplace, (uchar *) data.data() + offset, xfer); PropModeReplace, (uchar *) data.data() + offset, xfer);
offset += xfer; offset += xfer;
} else { } else {
// INCR transaction finished... // INCR transaction finished...
XChangeProperty(X11->display, window, property, target, format, XChangeProperty(qt_x11Data->display, window, property, target, format,
PropModeReplace, (uchar *) data.data(), 0); PropModeReplace, (uchar *) data.data(), 0);
delete this; delete this;
} }
@ -413,7 +413,7 @@ static Bool qt_init_timestamp_scanner(Display*, XEvent *event, XPointer arg)
break; break;
} }
#ifndef QT_NO_XFIXES #ifndef QT_NO_XFIXES
if (X11->use_xfixes && event->type == (X11->xfixes_eventbase + XFixesSelectionNotify)) { if (qt_x11Data->use_xfixes && event->type == (qt_x11Data->xfixes_eventbase + XFixesSelectionNotify)) {
XFixesSelectionNotifyEvent *req = XFixesSelectionNotifyEvent *req =
reinterpret_cast<XFixesSelectionNotifyEvent *>(event); reinterpret_cast<XFixesSelectionNotifyEvent *>(event);
data->timestamp = req->selection_timestamp; data->timestamp = req->selection_timestamp;
@ -435,37 +435,37 @@ QClipboard::QClipboard(QObject *parent)
(void)QApplication::desktop(); (void)QApplication::desktop();
#ifndef QT_NO_XFIXES #ifndef QT_NO_XFIXES
if (X11->use_xfixes) { if (qt_x11Data->use_xfixes) {
const unsigned long eventMask = const unsigned long eventMask =
XFixesSetSelectionOwnerNotifyMask | XFixesSelectionWindowDestroyNotifyMask | XFixesSelectionClientCloseNotifyMask; XFixesSetSelectionOwnerNotifyMask | XFixesSelectionWindowDestroyNotifyMask | XFixesSelectionClientCloseNotifyMask;
for (int i = 0; i < X11->screenCount; ++i) { for (int i = 0; i < qt_x11Data->screenCount; ++i) {
XFixesSelectSelectionInput(X11->display, QX11Info::appRootWindow(i), XFixesSelectSelectionInput(qt_x11Data->display, QX11Info::appRootWindow(i),
XA_PRIMARY, eventMask); XA_PRIMARY, eventMask);
XFixesSelectSelectionInput(X11->display, QX11Info::appRootWindow(i), XFixesSelectSelectionInput(qt_x11Data->display, QX11Info::appRootWindow(i),
ATOM(CLIPBOARD), eventMask); ATOM(CLIPBOARD), eventMask);
} }
} }
#endif // QT_NO_XFIXES #endif // QT_NO_XFIXES
if (X11->time == CurrentTime) { if (qt_x11Data->time == CurrentTime) {
// send a dummy event to myself to get the timestamp from X11. // send a dummy event to myself to get the timestamp from X11.
qt_init_timestamp_data data; qt_init_timestamp_data data;
data.timestamp = CurrentTime; data.timestamp = CurrentTime;
XEvent ev; XEvent ev;
XCheckIfEvent(X11->display, &ev, &qt_init_timestamp_scanner, (XPointer)&data); XCheckIfEvent(qt_x11Data->display, &ev, &qt_init_timestamp_scanner, (XPointer)&data);
if (data.timestamp == CurrentTime) { if (data.timestamp == CurrentTime) {
setupOwner(); setupOwner();
// We need this value just for completeness, we don't use it. // We need this value just for completeness, we don't use it.
long dummy = 0; long dummy = 0;
Window ownerId = owner->internalWinId(); Window ownerId = owner->internalWinId();
XChangeProperty(X11->display, ownerId, XChangeProperty(qt_x11Data->display, ownerId,
ATOM(CLIP_TEMPORARY), XA_INTEGER, 32, ATOM(CLIP_TEMPORARY), XA_INTEGER, 32,
PropModeReplace, (uchar*)&dummy, 1); PropModeReplace, (uchar*)&dummy, 1);
XWindowEvent(X11->display, ownerId, PropertyChangeMask, &ev); XWindowEvent(qt_x11Data->display, ownerId, PropertyChangeMask, &ev);
data.timestamp = ev.xproperty.time; data.timestamp = ev.xproperty.time;
XDeleteProperty(X11->display, ownerId, ATOM(CLIP_TEMPORARY)); XDeleteProperty(qt_x11Data->display, ownerId, ATOM(CLIP_TEMPORARY));
} }
X11->time = data.timestamp; qt_x11Data->time = data.timestamp;
} }
} }
@ -543,10 +543,10 @@ bool QX11Data::clipboardWaitForEvent(Window win, int type, XEvent *event, int ti
return true; return true;
} }
if (checkManager && XGetSelectionOwner(X11->display, ATOM(CLIPBOARD_MANAGER)) == XNone) if (checkManager && XGetSelectionOwner(qt_x11Data->display, ATOM(CLIPBOARD_MANAGER)) == XNone)
return false; return false;
XSync(X11->display, false); XSync(qt_x11Data->display, false);
usleep(50000); usleep(50000);
now.start(); now.start();
@ -570,23 +570,23 @@ bool QX11Data::clipboardWaitForEvent(Window win, int type, XEvent *event, int ti
qApp->setEventFilter(old_event_filter); qApp->setEventFilter(old_event_filter);
} else { } else {
do { do {
if (XCheckTypedWindowEvent(X11->display,win,type,event)) if (XCheckTypedWindowEvent(qt_x11Data->display,win,type,event))
return true; return true;
if (checkManager && XGetSelectionOwner(X11->display, ATOM(CLIPBOARD_MANAGER)) == XNone) if (checkManager && XGetSelectionOwner(qt_x11Data->display, ATOM(CLIPBOARD_MANAGER)) == XNone)
return false; return false;
// process other clipboard events, since someone is probably requesting data from us // process other clipboard events, since someone is probably requesting data from us
XEvent e; XEvent e;
// Pass the event through the event dispatcher filter so that applications // Pass the event through the event dispatcher filter so that applications
// which install an event filter on the dispatcher get to handle it first. // which install an event filter on the dispatcher get to handle it first.
if (XCheckIfEvent(X11->display, &e, checkForClipboardEvents, 0) && if (XCheckIfEvent(qt_x11Data->display, &e, checkForClipboardEvents, 0) &&
!QAbstractEventDispatcher::instance()->filterEvent(&e)) !QAbstractEventDispatcher::instance()->filterEvent(&e))
qApp->x11ProcessEvent(&e); qApp->x11ProcessEvent(&e);
now.start(); now.start();
XFlush(X11->display); XFlush(qt_x11Data->display);
// sleep 50 ms, so we don't use up CPU cycles all the time. // sleep 50 ms, so we don't use up CPU cycles all the time.
struct timeval usleep_tv; struct timeval usleep_tv;
@ -746,7 +746,7 @@ QByteArray QX11Data::clipboardReadIncrementalProperty(Window win, Atom property,
if (event.xproperty.atom != property || if (event.xproperty.atom != property ||
event.xproperty.state != PropertyNewValue) event.xproperty.state != PropertyNewValue)
continue; continue;
if (X11->clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0)) { if (qt_x11Data->clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0)) {
if (length == 0) { // no more data, we're done if (length == 0) { // no more data, we're done
if (nullterm) { if (nullterm) {
buf.resize(offset+1); buf.resize(offset+1);
@ -789,7 +789,7 @@ static Atom send_targets_selection(QClipboardData *d, Window window, Atom proper
QVector<Atom> types; QVector<Atom> types;
QStringList formats = QInternalMimeData::formatsHelper(d->source()); QStringList formats = QInternalMimeData::formatsHelper(d->source());
for (int i = 0; i < formats.size(); ++i) { for (int i = 0; i < formats.size(); ++i) {
QList<Atom> atoms = X11->xdndMimeAtomsForFormat(formats.at(i)); QList<Atom> atoms = qt_x11Data->xdndMimeAtomsForFormat(formats.at(i));
for (int j = 0; j < atoms.size(); ++j) { for (int j = 0; j < atoms.size(); ++j) {
if (!types.contains(atoms.at(j))) if (!types.contains(atoms.at(j)))
types.append(atoms.at(j)); types.append(atoms.at(j));
@ -800,7 +800,7 @@ static Atom send_targets_selection(QClipboardData *d, Window window, Atom proper
types.append(ATOM(TIMESTAMP)); types.append(ATOM(TIMESTAMP));
types.append(ATOM(SAVE_TARGETS)); types.append(ATOM(SAVE_TARGETS));
XChangeProperty(X11->display, window, property, XA_ATOM, 32, XChangeProperty(qt_x11Data->display, window, property, XA_ATOM, 32,
PropModeReplace, (uchar *) types.data(), types.size()); PropModeReplace, (uchar *) types.data(), types.size());
return property; return property;
} }
@ -811,21 +811,21 @@ static Atom send_selection(QClipboardData *d, Atom target, Window window, Atom p
int dataFormat = 0; int dataFormat = 0;
QByteArray data; QByteArray data;
QByteArray fmt = X11->xdndAtomToString(target); QByteArray fmt = qt_x11Data->xdndAtomToString(target);
if (fmt.isEmpty()) { // Not a MIME type we have if (fmt.isEmpty()) { // Not a MIME type we have
DEBUG("QClipboard: send_selection(): converting to type '%s' is not supported", fmt.data()); DEBUG("QClipboard: send_selection(): converting to type '%s' is not supported", fmt.data());
return XNone; return XNone;
} }
DEBUG("QClipboard: send_selection(): converting to type '%s'", fmt.data()); DEBUG("QClipboard: send_selection(): converting to type '%s'", fmt.data());
if (X11->xdndMimeDataForAtom(target, d->source(), &data, &atomFormat, &dataFormat)) { if (qt_x11Data->xdndMimeDataForAtom(target, d->source(), &data, &atomFormat, &dataFormat)) {
VDEBUG("QClipboard: send_selection():\n" VDEBUG("QClipboard: send_selection():\n"
" property type %lx\n" " property type %lx\n"
" property name '%s'\n" " property name '%s'\n"
" format %d\n" " format %d\n"
" %d bytes\n", " %d bytes\n",
target, X11->xdndMimeAtomToString(atomFormat).toLatin1().data(), dataFormat, data.size()); target, qt_x11Data->xdndMimeAtomToString(atomFormat).toLatin1().data(), dataFormat, data.size());
// don't allow INCR transfers when using MULTIPLE or to // don't allow INCR transfers when using MULTIPLE or to
// Motif clients (since Motif doesn't support INCR) // Motif clients (since Motif doesn't support INCR)
@ -833,10 +833,10 @@ static Atom send_selection(QClipboardData *d, Atom target, Window window, Atom p
bool allow_incr = property != motif_clip_temporary; bool allow_incr = property != motif_clip_temporary;
// X_ChangeProperty protocol request is 24 bytes // X_ChangeProperty protocol request is 24 bytes
const int increment = (XMaxRequestSize(X11->display) * 4) - 24; const int increment = (XMaxRequestSize(qt_x11Data->display) * 4) - 24;
if (data.size() > increment && allow_incr) { if (data.size() > increment && allow_incr) {
long bytes = data.size(); long bytes = data.size();
XChangeProperty(X11->display, window, property, XChangeProperty(qt_x11Data->display, window, property,
ATOM(INCR), 32, PropModeReplace, (uchar *) &bytes, 1); ATOM(INCR), 32, PropModeReplace, (uchar *) &bytes, 1);
(void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment); (void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment);
@ -848,7 +848,7 @@ static Atom send_selection(QClipboardData *d, Atom target, Window window, Atom p
return XNone; // ### perhaps use several XChangeProperty calls w/ PropModeAppend? return XNone; // ### perhaps use several XChangeProperty calls w/ PropModeAppend?
int dataSize = data.size() / (dataFormat / 8); int dataSize = data.size() / (dataFormat / 8);
// use a single request to transfer data // use a single request to transfer data
XChangeProperty(X11->display, window, property, atomFormat, XChangeProperty(qt_x11Data->display, window, property, atomFormat,
dataFormat, PropModeReplace, (uchar *) data.data(), dataFormat, PropModeReplace, (uchar *) data.data(),
dataSize); dataSize);
} }
@ -914,27 +914,27 @@ bool QClipboard::event(QEvent *e)
} }
XEvent *xevent = (XEvent *)(((QClipboardEvent *)e)->data()); XEvent *xevent = (XEvent *)(((QClipboardEvent *)e)->data());
Display *dpy = X11->display; Display *dpy = qt_x11Data->display;
if (!xevent) { if (!xevent) {
// That means application exits and we need to give clipboard // That means application exits and we need to give clipboard
// content to the clipboard manager. // content to the clipboard manager.
// First we check if there is a clipboard manager. // First we check if there is a clipboard manager.
if (XGetSelectionOwner(X11->display, ATOM(CLIPBOARD_MANAGER)) == XNone if (XGetSelectionOwner(qt_x11Data->display, ATOM(CLIPBOARD_MANAGER)) == XNone
|| !owner) || !owner)
return true; return true;
Window ownerId = owner->internalWinId(); Window ownerId = owner->internalWinId();
Q_ASSERT(ownerId); Q_ASSERT(ownerId);
// we delete the property so the manager saves all TARGETS. // we delete the property so the manager saves all TARGETS.
XDeleteProperty(X11->display, ownerId, ATOM(_QT_SELECTION)); XDeleteProperty(qt_x11Data->display, ownerId, ATOM(_QT_SELECTION));
XConvertSelection(X11->display, ATOM(CLIPBOARD_MANAGER), ATOM(SAVE_TARGETS), XConvertSelection(qt_x11Data->display, ATOM(CLIPBOARD_MANAGER), ATOM(SAVE_TARGETS),
ATOM(_QT_SELECTION), ownerId, X11->time); ATOM(_QT_SELECTION), ownerId, qt_x11Data->time);
XSync(dpy, false); XSync(dpy, false);
XEvent event; XEvent event;
// waiting until the clipboard manager fetches the content. // waiting until the clipboard manager fetches the content.
if (!X11->clipboardWaitForEvent(ownerId, SelectionNotify, &event, 10000, true)) { if (!qt_x11Data->clipboardWaitForEvent(ownerId, SelectionNotify, &event, 10000, true)) {
qWarning("QClipboard: Unable to receive an event from the " qWarning("QClipboard: Unable to receive an event from the "
"clipboard manager in a reasonable time"); "clipboard manager in a reasonable time");
} }
@ -1021,9 +1021,9 @@ bool QClipboard::event(QEvent *e)
" selection 0x%lx (%s) target 0x%lx (%s)", " selection 0x%lx (%s) target 0x%lx (%s)",
req->requestor, req->requestor,
req->selection, req->selection,
X11->xdndAtomToString(req->selection).data(), qt_x11Data->xdndAtomToString(req->selection).data(),
req->target, req->target,
X11->xdndAtomToString(req->target).data()); qt_x11Data->xdndAtomToString(req->target).data());
QClipboardData *d; QClipboardData *d;
if (req->selection == XA_PRIMARY) { if (req->selection == XA_PRIMARY) {
@ -1066,7 +1066,7 @@ bool QClipboard::event(QEvent *e)
if (req->target == xa_multiple) { if (req->target == xa_multiple) {
QByteArray multi_data; QByteArray multi_data;
if (req->property == XNone if (req->property == XNone
|| !X11->clipboardReadProperty(req->requestor, req->property, false, &multi_data, || !qt_x11Data->clipboardReadProperty(req->requestor, req->property, false, &multi_data,
0, &multi_type, &multi_format) 0, &multi_type, &multi_format)
|| multi_format != 32) { || multi_format != 32) {
// MULTIPLE property not formatted correctly // MULTIPLE property not formatted correctly
@ -1139,7 +1139,7 @@ bool QClipboard::event(QEvent *e)
DEBUG("QClipboard: SelectionNotify to 0x%lx\n" DEBUG("QClipboard: SelectionNotify to 0x%lx\n"
" property 0x%lx (%s)", " property 0x%lx (%s)",
req->requestor, event.xselection.property, req->requestor, event.xselection.property,
X11->xdndAtomToString(event.xselection.property).data()); qt_x11Data->xdndAtomToString(event.xselection.property).data());
} }
break; break;
} }
@ -1182,7 +1182,7 @@ QClipboardWatcher::~QClipboardWatcher()
bool QClipboardWatcher::empty() const bool QClipboardWatcher::empty() const
{ {
Display *dpy = X11->display; Display *dpy = qt_x11Data->display;
Window win = XGetSelectionOwner(dpy, atom); Window win = XGetSelectionOwner(dpy, atom);
if(win == requestor->internalWinId()) { if(win == requestor->internalWinId()) {
@ -1213,12 +1213,12 @@ QStringList QClipboardWatcher::formats_sys() const
if (targets[i] == 0) if (targets[i] == 0)
continue; continue;
QStringList formatsForAtom = X11->xdndMimeFormatsForAtom(targets[i]); QStringList formatsForAtom = qt_x11Data->xdndMimeFormatsForAtom(targets[i]);
for (int j = 0; j < formatsForAtom.size(); ++j) { for (int j = 0; j < formatsForAtom.size(); ++j) {
if (!formatList.contains(formatsForAtom.at(j))) if (!formatList.contains(formatsForAtom.at(j)))
formatList.append(formatsForAtom.at(j)); formatList.append(formatsForAtom.at(j));
} }
VDEBUG(" format: %s", X11->xdndAtomToString(targets[i]).data()); VDEBUG(" format: %s", qt_x11Data->xdndAtomToString(targets[i]).data());
VDEBUG(" data:\n%s\n", getDataInFormat(targets[i]).data()); VDEBUG(" data:\n%s\n", getDataInFormat(targets[i]).data());
} }
DEBUG("QClipboardWatcher::format: %d formats available", formatList.count()); DEBUG("QClipboardWatcher::format: %d formats available", formatList.count());
@ -1249,36 +1249,36 @@ QVariant QClipboardWatcher::retrieveData_sys(const QString &fmt, QVariant::Type
atoms.append(targets[i]); atoms.append(targets[i]);
QByteArray encoding; QByteArray encoding;
Atom fmtatom = X11->xdndMimeAtomForFormat(fmt, requestedType, atoms, &encoding); Atom fmtatom = qt_x11Data->xdndMimeAtomForFormat(fmt, requestedType, atoms, &encoding);
if (fmtatom == 0) if (fmtatom == 0)
return QVariant(); return QVariant();
return X11->xdndMimeConvertToFormat(fmtatom, getDataInFormat(fmtatom), fmt, requestedType, encoding); return qt_x11Data->xdndMimeConvertToFormat(fmtatom, getDataInFormat(fmtatom), fmt, requestedType, encoding);
} }
QByteArray QClipboardWatcher::getDataInFormat(Atom fmtatom) const QByteArray QClipboardWatcher::getDataInFormat(Atom fmtatom) const
{ {
QByteArray buf; QByteArray buf;
Display *dpy = X11->display; Display *dpy = qt_x11Data->display;
requestor->createWinId(); requestor->createWinId();
Window win = requestor->internalWinId(); Window win = requestor->internalWinId();
Q_ASSERT(requestor->testAttribute(Qt::WA_WState_Created)); Q_ASSERT(requestor->testAttribute(Qt::WA_WState_Created));
DEBUG("QClipboardWatcher::getDataInFormat: selection '%s' format '%s'", DEBUG("QClipboardWatcher::getDataInFormat: selection '%s' format '%s'",
X11->xdndAtomToString(atom).data(), X11->xdndAtomToString(fmtatom).data()); qt_x11Data->xdndAtomToString(atom).data(), qt_x11Data->xdndAtomToString(fmtatom).data());
XSelectInput(dpy, win, NoEventMask); // don't listen for any events XSelectInput(dpy, win, NoEventMask); // don't listen for any events
XDeleteProperty(dpy, win, ATOM(_QT_SELECTION)); XDeleteProperty(dpy, win, ATOM(_QT_SELECTION));
XConvertSelection(dpy, atom, fmtatom, ATOM(_QT_SELECTION), win, X11->time); XConvertSelection(dpy, atom, fmtatom, ATOM(_QT_SELECTION), win, qt_x11Data->time);
XSync(dpy, false); XSync(dpy, false);
VDEBUG("QClipboardWatcher::getDataInFormat: waiting for SelectionNotify event"); VDEBUG("QClipboardWatcher::getDataInFormat: waiting for SelectionNotify event");
XEvent xevent; XEvent xevent;
if (!X11->clipboardWaitForEvent(win,SelectionNotify,&xevent,clipboard_timeout) || if (!qt_x11Data->clipboardWaitForEvent(win,SelectionNotify,&xevent,clipboard_timeout) ||
xevent.xselection.property == XNone) { xevent.xselection.property == XNone) {
DEBUG("QClipboardWatcher::getDataInFormat: format not available"); DEBUG("QClipboardWatcher::getDataInFormat: format not available");
return buf; return buf;
@ -1289,10 +1289,10 @@ QByteArray QClipboardWatcher::getDataInFormat(Atom fmtatom) const
Atom type; Atom type;
XSelectInput(dpy, win, PropertyChangeMask); XSelectInput(dpy, win, PropertyChangeMask);
if (X11->clipboardReadProperty(win, ATOM(_QT_SELECTION), true, &buf, 0, &type, 0)) { if (qt_x11Data->clipboardReadProperty(win, ATOM(_QT_SELECTION), true, &buf, 0, &type, 0)) {
if (type == ATOM(INCR)) { if (type == ATOM(INCR)) {
int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0; int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0;
buf = X11->clipboardReadIncrementalProperty(win, ATOM(_QT_SELECTION), nbytes, false); buf = qt_x11Data->clipboardReadIncrementalProperty(win, ATOM(_QT_SELECTION), nbytes, false);
} }
} }
@ -1367,7 +1367,7 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode)
return; return;
} }
Display *dpy = X11->display; Display *dpy = qt_x11Data->display;
Window newOwner; Window newOwner;
if (! src) { // no data, clear clipboard contents if (! src) { // no data, clear clipboard contents
@ -1379,12 +1379,12 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode)
newOwner = owner->internalWinId(); newOwner = owner->internalWinId();
d->setSource(src); d->setSource(src);
d->timestamp = X11->time; d->timestamp = qt_x11Data->time;
} }
Window prevOwner = XGetSelectionOwner(dpy, atom); Window prevOwner = XGetSelectionOwner(dpy, atom);
// use X11->time, since d->timestamp == CurrentTime when clearing // use qt_x11Data->time, since d->timestamp == CurrentTime when clearing
XSetSelectionOwner(dpy, atom, newOwner, X11->time); XSetSelectionOwner(dpy, atom, newOwner, qt_x11Data->time);
if (mode == Selection) if (mode == Selection)
emitChanged(QClipboard::Selection); emitChanged(QClipboard::Selection);
@ -1393,7 +1393,7 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode)
if (XGetSelectionOwner(dpy, atom) != newOwner) { if (XGetSelectionOwner(dpy, atom) != newOwner) {
qWarning("QClipboard::setData: Cannot set X11 selection owner for %s", qWarning("QClipboard::setData: Cannot set X11 selection owner for %s",
X11->xdndAtomToString(atom).data()); qt_x11Data->xdndAtomToString(atom).data());
d->clear(); d->clear();
return; return;
} }
@ -1419,7 +1419,7 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode)
bool qt_check_selection_sentinel() bool qt_check_selection_sentinel()
{ {
bool doIt = true; bool doIt = true;
if (owner && !X11->use_xfixes) { if (owner && !qt_x11Data->use_xfixes) {
/* /*
Since the X selection mechanism cannot give any signal when Since the X selection mechanism cannot give any signal when
the selection has changed, we emulate it (for Qt processes) here. the selection has changed, we emulate it (for Qt processes) here.
@ -1437,7 +1437,7 @@ bool qt_check_selection_sentinel()
ulong nitems; ulong nitems;
ulong bytesLeft; ulong bytesLeft;
if (XGetWindowProperty(X11->display, if (XGetWindowProperty(qt_x11Data->display,
QApplication::desktop()->screen(0)->internalWinId(), QApplication::desktop()->screen(0)->internalWinId(),
ATOM(_QT_SELECTION_SENTINEL), 0, 2, False, XA_WINDOW, ATOM(_QT_SELECTION_SENTINEL), 0, 2, False, XA_WINDOW,
&actualType, &actualFormat, &nitems, &actualType, &actualFormat, &nitems,
@ -1471,13 +1471,13 @@ bool qt_check_selection_sentinel()
bool qt_check_clipboard_sentinel() bool qt_check_clipboard_sentinel()
{ {
bool doIt = true; bool doIt = true;
if (owner && !X11->use_xfixes) { if (owner && !qt_x11Data->use_xfixes) {
unsigned char *retval; unsigned char *retval;
Atom actualType; Atom actualType;
int actualFormat; int actualFormat;
unsigned long nitems, bytesLeft; unsigned long nitems, bytesLeft;
if (XGetWindowProperty(X11->display, if (XGetWindowProperty(qt_x11Data->display,
QApplication::desktop()->screen(0)->internalWinId(), QApplication::desktop()->screen(0)->internalWinId(),
ATOM(_QT_CLIPBOARD_SENTINEL), 0, 2, False, XA_WINDOW, ATOM(_QT_CLIPBOARD_SENTINEL), 0, 2, False, XA_WINDOW,
&actualType, &actualFormat, &nitems, &bytesLeft, &actualType, &actualFormat, &nitems, &bytesLeft,

View file

@ -53,6 +53,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap); // qpixmap_x11.cpp
// Define QT_USE_APPROXIMATE_CURSORS when compiling if you REALLY want to // Define QT_USE_APPROXIMATE_CURSORS when compiling if you REALLY want to
// use the ugly X11 cursors. // use the ugly X11 cursors.
@ -68,7 +70,7 @@ QCursorData::QCursorData(Qt::CursorShape s)
QCursorData::~QCursorData() QCursorData::~QCursorData()
{ {
Display *dpy = X11 ? X11->display : (Display*)0; Display *dpy = qt_x11Data ? qt_x11Data->display : (Display*)0;
// Add in checking for the display too as on HP-UX // Add in checking for the display too as on HP-UX
// we seem to get a core dump as the cursor data is // we seem to get a core dump as the cursor data is
@ -107,7 +109,6 @@ QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask,
QCursorData *d = new QCursorData; QCursorData *d = new QCursorData;
d->ref = 1; d->ref = 1;
extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap); // qpixmap_x11.cpp
d->bm = new QBitmap(qt_toX11Pixmap(bitmap)); d->bm = new QBitmap(qt_toX11Pixmap(bitmap));
d->bmm = new QBitmap(qt_toX11Pixmap(mask)); d->bmm = new QBitmap(qt_toX11Pixmap(mask));
@ -143,7 +144,7 @@ QPoint QCursor::pos()
Window child; Window child;
int root_x, root_y, win_x, win_y; int root_x, root_y, win_x, win_y;
uint buttons; uint buttons;
Display* dpy = X11->display; Display* dpy = qt_x11Data->display;
for (int i = 0; i < ScreenCount(dpy); ++i) { for (int i = 0; i < ScreenCount(dpy); ++i) {
if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y, if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
&win_x, &win_y, &buttons)) &win_x, &win_y, &buttons))
@ -162,7 +163,7 @@ int QCursor::x11Screen()
Window child; Window child;
int root_x, root_y, win_x, win_y; int root_x, root_y, win_x, win_y;
uint buttons; uint buttons;
Display* dpy = X11->display; Display* dpy = qt_x11Data->display;
for (int i = 0; i < ScreenCount(dpy); ++i) { for (int i = 0; i < ScreenCount(dpy); ++i) {
if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y, if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
&win_x, &win_y, &buttons)) &win_x, &win_y, &buttons))
@ -182,7 +183,7 @@ void QCursor::setPos(int x, int y)
Window child; Window child;
int root_x, root_y, win_x, win_y; int root_x, root_y, win_x, win_y;
uint buttons; uint buttons;
Display* dpy = X11->display; Display* dpy = qt_x11Data->display;
int screen; int screen;
for (screen = 0; screen < ScreenCount(dpy); ++screen) { for (screen = 0; screen < ScreenCount(dpy); ++screen) {
if (XQueryPointer(dpy, QX11Info::appRootWindow(screen), &root, &child, &root_x, &root_y, if (XQueryPointer(dpy, QX11Info::appRootWindow(screen), &root, &child, &root_x, &root_y,
@ -202,7 +203,7 @@ void QCursor::setPos(int x, int y)
if (current == target) if (current == target)
return; return;
XWarpPointer(X11->display, XNone, QX11Info::appRootWindow(screen), 0, 0, 0, 0, x, y); XWarpPointer(qt_x11Data->display, XNone, QX11Info::appRootWindow(screen), 0, 0, 0, 0, x, y);
} }
@ -219,15 +220,14 @@ void QCursorData::update()
if (hcurs) if (hcurs)
return; return;
Display *dpy = X11->display; Display *dpy = qt_x11Data->display;
Window rootwin = QX11Info::appRootWindow(); Window rootwin = QX11Info::appRootWindow();
if (cshape == Qt::BitmapCursor) { if (cshape == Qt::BitmapCursor) {
extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap); // qpixmap_x11.cpp
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (!pixmap.isNull() && X11->use_xrender) { if (!pixmap.isNull() && qt_x11Data->use_xrender) {
pixmap = qt_toX11Pixmap(pixmap); pixmap = qt_toX11Pixmap(pixmap);
hcurs = XRenderCreateCursor (X11->display, pixmap.x11PictureHandle(), hx, hy); hcurs = XRenderCreateCursor (qt_x11Data->display, pixmap.x11PictureHandle(), hx, hy);
} else } else
#endif #endif
{ {
@ -532,7 +532,7 @@ void QCursorData::update()
if (hcurs) if (hcurs)
{ {
#ifndef QT_NO_XFIXES #ifndef QT_NO_XFIXES
if (X11->use_xfixes) if (qt_x11Data->use_xfixes)
XFixesSetCursorName(dpy, hcurs, cursorNames[cshape]); XFixesSetCursorName(dpy, hcurs, cursorNames[cshape]);
#endif /* ! QT_NO_XFIXES */ #endif /* ! QT_NO_XFIXES */
return; return;
@ -617,7 +617,7 @@ void QCursorData::update()
hcurs = XCreateFontCursor(dpy, sh); hcurs = XCreateFontCursor(dpy, sh);
#ifndef QT_NO_XFIXES #ifndef QT_NO_XFIXES
if (X11->use_xfixes) if (qt_x11Data->use_xfixes)
XFixesSetCursorName(dpy, hcurs, cursorNames[cshape]); XFixesSetCursorName(dpy, hcurs, cursorNames[cshape]);
#endif /* ! QT_NO_XFIXES */ #endif /* ! QT_NO_XFIXES */
} }

View file

@ -125,7 +125,7 @@ QDesktopWidgetPrivate::~QDesktopWidgetPrivate()
void QDesktopWidgetPrivate::init() void QDesktopWidgetPrivate::init()
{ {
// get the screen count // get the screen count
int newScreenCount = ScreenCount(X11->display); int newScreenCount = ScreenCount(qt_x11Data->display);
#ifndef QT_NO_XINERAMA #ifndef QT_NO_XINERAMA
XineramaScreenInfo *xinerama_screeninfo = 0; XineramaScreenInfo *xinerama_screeninfo = 0;
@ -134,12 +134,12 @@ void QDesktopWidgetPrivate::init()
// using traditional multi-screen (with multiple root windows) // using traditional multi-screen (with multiple root windows)
if (newScreenCount == 1) { if (newScreenCount == 1) {
int unused; int unused;
use_xinerama = (XineramaQueryExtension(X11->display, &unused, &unused) use_xinerama = (XineramaQueryExtension(qt_x11Data->display, &unused, &unused)
&& XineramaIsActive(X11->display)); && XineramaIsActive(qt_x11Data->display));
} }
if (use_xinerama) { if (use_xinerama) {
xinerama_screeninfo = XineramaQueryScreens(X11->display, &newScreenCount); xinerama_screeninfo = XineramaQueryScreens(qt_x11Data->display, &newScreenCount);
} }
if (xinerama_screeninfo) { if (xinerama_screeninfo) {
@ -147,8 +147,8 @@ void QDesktopWidgetPrivate::init()
} else } else
#endif // QT_NO_XINERAMA #endif // QT_NO_XINERAMA
{ {
defaultScreen = DefaultScreen(X11->display); defaultScreen = DefaultScreen(qt_x11Data->display);
newScreenCount = ScreenCount(X11->display); newScreenCount = ScreenCount(qt_x11Data->display);
use_xinerama = false; use_xinerama = false;
} }
@ -172,8 +172,8 @@ void QDesktopWidgetPrivate::init()
{ {
x = 0; x = 0;
y = 0; y = 0;
w = WidthOfScreen(ScreenOfDisplay(X11->display, i)); w = WidthOfScreen(ScreenOfDisplay(qt_x11Data->display, i));
h = HeightOfScreen(ScreenOfDisplay(X11->display, i)); h = HeightOfScreen(ScreenOfDisplay(qt_x11Data->display, i));
} }
rects[j].setRect(x, y, w, h); rects[j].setRect(x, y, w, h);
@ -280,15 +280,15 @@ const QRect QDesktopWidget::availableGeometry(int screen) const
if (d->workareas[screen].isValid()) if (d->workareas[screen].isValid())
return d->workareas[screen]; return d->workareas[screen];
if (X11->isSupportedByWM(ATOM(_NET_WORKAREA))) { if (qt_x11Data->isSupportedByWM(ATOM(_NET_WORKAREA))) {
int x11Screen = isVirtualDesktop() ? DefaultScreen(X11->display) : screen; int x11Screen = isVirtualDesktop() ? DefaultScreen(qt_x11Data->display) : screen;
Atom ret; Atom ret;
int format, e; int format, e;
unsigned char *data = 0; unsigned char *data = 0;
unsigned long nitems, after; unsigned long nitems, after;
e = XGetWindowProperty(X11->display, e = XGetWindowProperty(qt_x11Data->display,
QX11Info::appRootWindow(x11Screen), QX11Info::appRootWindow(x11Screen),
ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL, ATOM(_NET_WORKAREA), 0, 4, False, XA_CARDINAL,
&ret, &format, &nitems, &after, &data); &ret, &format, &nitems, &after, &data);

View file

@ -94,8 +94,8 @@ QT_BEGIN_NAMESPACE
static int findXdndDropTransactionByWindow(Window window) static int findXdndDropTransactionByWindow(Window window)
{ {
int at = -1; int at = -1;
for (int i = 0; i < X11->dndDropTransactions.count(); ++i) { for (int i = 0; i < qt_x11Data->dndDropTransactions.count(); ++i) {
const QXdndDropTransaction &t = X11->dndDropTransactions.at(i); const QXdndDropTransaction &t = qt_x11Data->dndDropTransactions.at(i);
if (t.target == window || t.proxy_target == window) { if (t.target == window || t.proxy_target == window) {
at = i; at = i;
break; break;
@ -107,8 +107,8 @@ static int findXdndDropTransactionByWindow(Window window)
static int findXdndDropTransactionByTime(Time timestamp) static int findXdndDropTransactionByTime(Time timestamp)
{ {
int at = -1; int at = -1;
for (int i = 0; i < X11->dndDropTransactions.count(); ++i) { for (int i = 0; i < qt_x11Data->dndDropTransactions.count(); ++i) {
const QXdndDropTransaction &t = X11->dndDropTransactions.at(i); const QXdndDropTransaction &t = qt_x11Data->dndDropTransactions.at(i);
if (t.timestamp == timestamp) { if (t.timestamp == timestamp) {
at = i; at = i;
break; break;
@ -139,7 +139,7 @@ static Window findXdndAwareParent(Window window)
int f; int f;
unsigned long n, a; unsigned long n, a;
unsigned char *data = 0; unsigned char *data = 0;
if (XGetWindowProperty(X11->display, window, ATOM(XdndAware), 0, 0, False, if (XGetWindowProperty(qt_x11Data->display, window, ATOM(XdndAware), 0, 0, False,
AnyPropertyType, &type, &f,&n,&a,&data) == Success) { AnyPropertyType, &type, &f,&n,&a,&data) == Success) {
if (data) if (data)
XFree(data); XFree(data);
@ -154,7 +154,7 @@ static Window findXdndAwareParent(Window window)
Window parent; Window parent;
Window *children; Window *children;
uint unused; uint unused;
if (!XQueryTree(X11->display, window, &root, &parent, &children, &unused)) if (!XQueryTree(qt_x11Data->display, window, &root, &parent, &children, &unused))
break; break;
if (children) if (children)
XFree(children); XFree(children);
@ -338,7 +338,7 @@ static WId xdndProxy(WId w)
int f; int f;
unsigned long n, a; unsigned long n, a;
unsigned char *retval = 0; unsigned char *retval = 0;
XGetWindowProperty(X11->display, w, ATOM(XdndProxy), 0, 1, False, XGetWindowProperty(qt_x11Data->display, w, ATOM(XdndProxy), 0, 1, False,
XA_WINDOW, &type, &f,&n,&a,&retval); XA_WINDOW, &type, &f,&n,&a,&retval);
WId *proxy_id_ptr = (WId *)retval; WId *proxy_id_ptr = (WId *)retval;
WId proxy_id = 0; WId proxy_id = 0;
@ -347,11 +347,11 @@ static WId xdndProxy(WId w)
XFree(proxy_id_ptr); XFree(proxy_id_ptr);
proxy_id_ptr = 0; proxy_id_ptr = 0;
// Already exists. Real? // Already exists. Real?
X11->ignoreBadwindow(); qt_x11Data->ignoreBadwindow();
XGetWindowProperty(X11->display, proxy_id, ATOM(XdndProxy), 0, 1, False, XGetWindowProperty(qt_x11Data->display, proxy_id, ATOM(XdndProxy), 0, 1, False,
XA_WINDOW, &type, &f,&n,&a,&retval); XA_WINDOW, &type, &f,&n,&a,&retval);
proxy_id_ptr = (WId *)retval; proxy_id_ptr = (WId *)retval;
if (X11->badwindow() || type != XA_WINDOW || !proxy_id_ptr || *proxy_id_ptr != proxy_id) if (qt_x11Data->badwindow() || type != XA_WINDOW || !proxy_id_ptr || *proxy_id_ptr != proxy_id)
// Bogus - we will overwrite. // Bogus - we will overwrite.
proxy_id = 0; proxy_id = 0;
} }
@ -370,20 +370,20 @@ static bool xdndEnable(QWidget* w, bool on)
return false; return false;
// As per Xdnd4, use XdndProxy // As per Xdnd4, use XdndProxy
XGrabServer(X11->display); XGrabServer(qt_x11Data->display);
Q_ASSERT(w->testAttribute(Qt::WA_WState_Created)); Q_ASSERT(w->testAttribute(Qt::WA_WState_Created));
WId proxy_id = xdndProxy(w->effectiveWinId()); WId proxy_id = xdndProxy(w->effectiveWinId());
if (!proxy_id) { if (!proxy_id) {
xdnd_widget = xdnd_data.desktop_proxy = new QWidget; xdnd_widget = xdnd_data.desktop_proxy = new QWidget;
proxy_id = xdnd_data.desktop_proxy->effectiveWinId(); proxy_id = xdnd_data.desktop_proxy->effectiveWinId();
XChangeProperty (X11->display, w->effectiveWinId(), ATOM(XdndProxy), XChangeProperty (qt_x11Data->display, w->effectiveWinId(), ATOM(XdndProxy),
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&proxy_id, 1); XA_WINDOW, 32, PropModeReplace, (unsigned char *)&proxy_id, 1);
XChangeProperty (X11->display, proxy_id, ATOM(XdndProxy), XChangeProperty (qt_x11Data->display, proxy_id, ATOM(XdndProxy),
XA_WINDOW, 32, PropModeReplace, (unsigned char *)&proxy_id, 1); XA_WINDOW, 32, PropModeReplace, (unsigned char *)&proxy_id, 1);
} }
XUngrabServer(X11->display); XUngrabServer(qt_x11Data->display);
} else { } else {
xdnd_widget = w->window(); xdnd_widget = w->window();
} }
@ -391,7 +391,7 @@ static bool xdndEnable(QWidget* w, bool on)
DNDDEBUG << "setting XdndAware for" << xdnd_widget << xdnd_widget->effectiveWinId(); DNDDEBUG << "setting XdndAware for" << xdnd_widget << xdnd_widget->effectiveWinId();
Atom atm = (Atom)xdnd_version; Atom atm = (Atom)xdnd_version;
Q_ASSERT(xdnd_widget->testAttribute(Qt::WA_WState_Created)); Q_ASSERT(xdnd_widget->testAttribute(Qt::WA_WState_Created));
XChangeProperty(X11->display, xdnd_widget->effectiveWinId(), ATOM(XdndAware), XChangeProperty(qt_x11Data->display, xdnd_widget->effectiveWinId(), ATOM(XdndAware),
XA_ATOM, 32, PropModeReplace, (unsigned char *)&atm, 1); XA_ATOM, 32, PropModeReplace, (unsigned char *)&atm, 1);
return true; return true;
} else { } else {
@ -399,7 +399,7 @@ static bool xdndEnable(QWidget* w, bool on)
} }
} else { } else {
if ((w->windowType() == Qt::Desktop)) { if ((w->windowType() == Qt::Desktop)) {
XDeleteProperty(X11->display, w->internalWinId(), ATOM(XdndProxy)); XDeleteProperty(qt_x11Data->display, w->internalWinId(), ATOM(XdndProxy));
delete xdnd_data.desktop_proxy; delete xdnd_data.desktop_proxy;
xdnd_data.desktop_proxy = 0; xdnd_data.desktop_proxy = 0;
} else { } else {
@ -507,7 +507,7 @@ bool QX11Data::xdndMimeDataForAtom(Atom a, QMimeData *mimeData, QByteArray *data
? XCompoundTextStyle : XStdICCTextStyle; ? XCompoundTextStyle : XStdICCTextStyle;
XTextProperty textprop; XTextProperty textprop;
if (list[0] != NULL if (list[0] != NULL
&& XmbTextListToTextProperty(X11->display, list, 1, style, && XmbTextListToTextProperty(qt_x11Data->display, list, 1, style,
&textprop) == Success) { &textprop) == Success) {
*atomFormat = textprop.encoding; *atomFormat = textprop.encoding;
*dataFormat = textprop.format; *dataFormat = textprop.format;
@ -520,7 +520,7 @@ bool QX11Data::xdndMimeDataForAtom(Atom a, QMimeData *mimeData, QByteArray *data
" %ld items\n" " %ld items\n"
" %d bytes\n", " %d bytes\n",
textprop.encoding, textprop.encoding,
X11->xdndMimeAtomToString(textprop.encoding).toLatin1().data(), qt_x11Data->xdndMimeAtomToString(textprop.encoding).toLatin1().data(),
textprop.format, textprop.nitems, data->size()); textprop.format, textprop.nitems, data->size());
XFree(textprop.value); XFree(textprop.value);
@ -784,12 +784,12 @@ static bool checkEmbedded(QWidget* w, const XEvent* xe)
if (current_embedding_widget != w) { if (current_embedding_widget != w) {
last_enter_event.xany.window = extra->xDndProxy; last_enter_event.xany.window = extra->xDndProxy;
XSendEvent(X11->display, extra->xDndProxy, False, NoEventMask, &last_enter_event); XSendEvent(qt_x11Data->display, extra->xDndProxy, False, NoEventMask, &last_enter_event);
current_embedding_widget = w; current_embedding_widget = w;
} }
((XEvent*)xe)->xany.window = extra->xDndProxy; ((XEvent*)xe)->xany.window = extra->xDndProxy;
XSendEvent(X11->display, extra->xDndProxy, False, NoEventMask, (XEvent*)xe); XSendEvent(qt_x11Data->display, extra->xDndProxy, False, NoEventMask, (XEvent*)xe);
if (qt_xdnd_current_widget != w) { if (qt_xdnd_current_widget != w) {
qt_xdnd_current_widget = w; qt_xdnd_current_widget = w;
} }
@ -820,7 +820,7 @@ void QX11Data::xdndHandleEnter(QWidget *, const XEvent * xe, bool /*passive*/)
int f; int f;
unsigned long n, a; unsigned long n, a;
unsigned char *retval = 0; unsigned char *retval = 0;
XGetWindowProperty(X11->display, qt_xdnd_dragsource_xid, ATOM(XdndTypelist), 0, XGetWindowProperty(qt_x11Data->display, qt_xdnd_dragsource_xid, ATOM(XdndTypelist), 0,
qt_xdnd_max_type, False, XA_ATOM, &type, &f,&n,&a,&retval); qt_xdnd_max_type, False, XA_ATOM, &type, &f,&n,&a,&retval);
if (retval) { if (retval) {
Atom *data = (Atom *)retval; Atom *data = (Atom *)retval;
@ -861,7 +861,7 @@ static void handle_xdnd_position(QWidget *w, const XEvent * xe, bool passive)
if (l[3] != 0) { if (l[3] != 0) {
// Some X server/client combination swallow the first 32 bit and // Some X server/client combination swallow the first 32 bit and
// interpret a set bit 31 as negative sign. // interpret a set bit 31 as negative sign.
qt_xdnd_target_current_time = X11->userTime = qt_xdnd_target_current_time = qt_x11Data->userTime =
((sizeof(Time) == 8 && xe->xclient.data.l[3] < 0) ((sizeof(Time) == 8 && xe->xclient.data.l[3] < 0)
? uint(l[3]) ? uint(l[3])
: l[3]); : l[3]);
@ -920,7 +920,7 @@ static void handle_xdnd_position(QWidget *w, const XEvent * xe, bool passive)
} }
} }
DEBUG() << "qt_handle_xdnd_position action=" << X11->xdndAtomToString(l[4]); DEBUG() << "qt_handle_xdnd_position action=" << qt_x11Data->xdndAtomToString(l[4]);
if (!target_widget) { if (!target_widget) {
answerRect = QRect(p, QSize(1, 1)); answerRect = QRect(p, QSize(1, 1));
} else { } else {
@ -973,7 +973,7 @@ static void handle_xdnd_position(QWidget *w, const XEvent * xe, bool passive)
if (source) if (source)
handle_xdnd_status(source, (const XEvent *)&response, passive); handle_xdnd_status(source, (const XEvent *)&response, passive);
else else
XSendEvent(X11->display, qt_xdnd_dragsource_xid, False, NoEventMask, (XEvent*)&response); XSendEvent(qt_x11Data->display, qt_xdnd_dragsource_xid, False, NoEventMask, (XEvent*)&response);
} }
static Bool xdnd_position_scanner(Display *, XEvent *event, XPointer) static Bool xdnd_position_scanner(Display *, XEvent *event, XPointer)
@ -991,7 +991,7 @@ static Bool xdnd_position_scanner(Display *, XEvent *event, XPointer)
void QX11Data::xdndHandlePosition(QWidget * w, const XEvent * xe, bool passive) void QX11Data::xdndHandlePosition(QWidget * w, const XEvent * xe, bool passive)
{ {
DEBUG("xdndHandlePosition"); DEBUG("xdndHandlePosition");
while (XCheckIfEvent(X11->display, (XEvent *)xe, xdnd_position_scanner, 0)) while (XCheckIfEvent(qt_x11Data->display, (XEvent *)xe, xdnd_position_scanner, 0))
; ;
handle_xdnd_position(w, xe, passive); handle_xdnd_position(w, xe, passive);
@ -1037,7 +1037,7 @@ static Bool xdnd_status_scanner(Display *, XEvent *event, XPointer)
void QX11Data::xdndHandleStatus(QWidget * w, const XEvent * xe, bool passive) void QX11Data::xdndHandleStatus(QWidget * w, const XEvent * xe, bool passive)
{ {
DEBUG("xdndHandleStatus"); DEBUG("xdndHandleStatus");
while (XCheckIfEvent(X11->display, (XEvent *)xe, xdnd_status_scanner, 0)) while (XCheckIfEvent(qt_x11Data->display, (XEvent *)xe, xdnd_status_scanner, 0))
; ;
handle_xdnd_status(w, xe, passive); handle_xdnd_status(w, xe, passive);
@ -1100,9 +1100,9 @@ void qt_xdnd_send_leave()
w = 0; w = 0;
if (w) if (w)
X11->xdndHandleLeave(w, (const XEvent *)&leave, false); qt_x11Data->xdndHandleLeave(w, (const XEvent *)&leave, false);
else else
XSendEvent(X11->display, qt_xdnd_current_proxy_target, False, XSendEvent(qt_x11Data->display, qt_xdnd_current_proxy_target, False,
NoEventMask, (XEvent*)&leave); NoEventMask, (XEvent*)&leave);
// reset the drag manager state // reset the drag manager state
@ -1145,7 +1145,7 @@ void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive)
if (l[2] != 0) { if (l[2] != 0) {
// Some X server/client combination swallow the first 32 bit and // Some X server/client combination swallow the first 32 bit and
// interpret a set bit 31 as negative sign. // interpret a set bit 31 as negative sign.
qt_xdnd_target_current_time = X11->userTime = qt_xdnd_target_current_time = qt_x11Data->userTime =
((sizeof(Time) == 8 && xe->xclient.data.l[2] < 0) ((sizeof(Time) == 8 && xe->xclient.data.l[2] < 0)
? uint(l[2]) ? uint(l[2])
: l[2]); : l[2]);
@ -1158,7 +1158,7 @@ void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive)
QMimeData *dropData = 0; QMimeData *dropData = 0;
const int at = findXdndDropTransactionByTime(qt_xdnd_target_current_time); const int at = findXdndDropTransactionByTime(qt_xdnd_target_current_time);
if (at != -1) { if (at != -1) {
dropData = QDragManager::dragPrivate(X11->dndDropTransactions.at(at).object)->data; dropData = QDragManager::dragPrivate(qt_x11Data->dndDropTransactions.at(at).object)->data;
// Can't use the source QMimeData if we need the image conversion code from xdndObtainData // Can't use the source QMimeData if we need the image conversion code from xdndObtainData
if (dropData && dropData->hasImage()) if (dropData && dropData->hasImage())
dropData = 0; dropData = 0;
@ -1199,7 +1199,7 @@ void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive)
finished.data.l[0] = qt_xdnd_current_widget?qt_xdnd_current_widget->window()->internalWinId():0; finished.data.l[0] = qt_xdnd_current_widget?qt_xdnd_current_widget->window()->internalWinId():0;
finished.data.l[1] = de.isAccepted() ? 1 : 0; // flags finished.data.l[1] = de.isAccepted() ? 1 : 0; // flags
finished.data.l[2] = qtaction_to_xdndaction(global_accepted_action); finished.data.l[2] = qtaction_to_xdndaction(global_accepted_action);
XSendEvent(X11->display, qt_xdnd_dragsource_xid, False, XSendEvent(qt_x11Data->display, qt_xdnd_dragsource_xid, False,
NoEventMask, (XEvent*)&finished); NoEventMask, (XEvent*)&finished);
} else { } else {
QDragLeaveEvent e; QDragLeaveEvent e;
@ -1228,7 +1228,7 @@ void QX11Data::xdndHandleFinished(QWidget *, const XEvent * xe, bool passive)
if (at != -1) { if (at != -1) {
restartXdndDropExpiryTimer(); restartXdndDropExpiryTimer();
QXdndDropTransaction t = X11->dndDropTransactions.takeAt(at); QXdndDropTransaction t = qt_x11Data->dndDropTransactions.takeAt(at);
QDragManager *manager = QDragManager::self(); QDragManager *manager = QDragManager::self();
Window target = qt_xdnd_current_target; Window target = qt_xdnd_current_target;
@ -1266,14 +1266,14 @@ void QDragManager::timerEvent(QTimerEvent* e)
if (e->timerId() == heartbeat && qt_xdnd_source_sameanswer.isNull()) { if (e->timerId() == heartbeat && qt_xdnd_source_sameanswer.isNull()) {
move(QCursor::pos()); move(QCursor::pos());
} else if (e->timerId() == transaction_expiry_timer) { } else if (e->timerId() == transaction_expiry_timer) {
for (int i = 0; i < X11->dndDropTransactions.count(); ++i) { for (int i = 0; i < qt_x11Data->dndDropTransactions.count(); ++i) {
const QXdndDropTransaction &t = X11->dndDropTransactions.at(i); const QXdndDropTransaction &t = qt_x11Data->dndDropTransactions.at(i);
if (t.targetWidget) { if (t.targetWidget) {
// dnd within the same process, don't delete these // dnd within the same process, don't delete these
continue; continue;
} }
t.object->deleteLater(); t.object->deleteLater();
X11->dndDropTransactions.removeAt(i--); qt_x11Data->dndDropTransactions.removeAt(i--);
} }
killTimer(transaction_expiry_timer); killTimer(transaction_expiry_timer);
@ -1441,10 +1441,10 @@ Window findRealWindow(const QPoint & pos, Window w, int md, bool ignoreNonXdndAw
return 0; return 0;
if (md) { if (md) {
X11->ignoreBadwindow(); qt_x11Data->ignoreBadwindow();
XWindowAttributes attr; XWindowAttributes attr;
XGetWindowAttributes(X11->display, w, &attr); XGetWindowAttributes(qt_x11Data->display, w, &attr);
if (X11->badwindow()) if (qt_x11Data->badwindow())
return 0; return 0;
if (attr.map_state == IsViewable if (attr.map_state == IsViewable
@ -1456,7 +1456,7 @@ Window findRealWindow(const QPoint & pos, Window w, int md, bool ignoreNonXdndAw
unsigned long n, a; unsigned long n, a;
unsigned char *data; unsigned char *data;
XGetWindowProperty(X11->display, w, ATOM(XdndAware), 0, 0, False, XGetWindowProperty(qt_x11Data->display, w, ATOM(XdndAware), 0, 0, False,
AnyPropertyType, &type, &f,&n,&a,&data); AnyPropertyType, &type, &f,&n,&a,&data);
if (data) XFree(data); if (data) XFree(data);
if (type) { if (type) {
@ -1482,7 +1482,7 @@ Window findRealWindow(const QPoint & pos, Window w, int md, bool ignoreNonXdndAw
Window r, p; Window r, p;
Window* c; Window* c;
uint nc; uint nc;
if (XQueryTree(X11->display, w, &r, &p, &c, &nc)) { if (XQueryTree(qt_x11Data->display, w, &r, &p, &c, &nc)) {
r=0; r=0;
for (uint i=nc; !r && i--;) { for (uint i=nc; !r && i--;) {
r = findRealWindow(pos-QPoint(attr.x,attr.y), r = findRealWindow(pos-QPoint(attr.x,attr.y),
@ -1519,7 +1519,7 @@ void QDragManager::move(const QPoint & globalPos)
} }
int screen = QCursor::x11Screen(); int screen = QCursor::x11Screen();
if ((qt_xdnd_current_screen == -1 && screen != X11->defaultScreen) || (screen != qt_xdnd_current_screen)) { if ((qt_xdnd_current_screen == -1 && screen != qt_x11Data->defaultScreen) || (screen != qt_xdnd_current_screen)) {
// recreate the pixmap on the new screen... // recreate the pixmap on the new screen...
delete xdnd_data.deco; delete xdnd_data.deco;
QWidget* parent = object->source()->window()->x11Info().screen() == screen QWidget* parent = object->source()->window()->x11Info().screen() == screen
@ -1539,7 +1539,7 @@ void QDragManager::move(const QPoint & globalPos)
Window rootwin = QX11Info::appRootWindow(qt_xdnd_current_screen); Window rootwin = QX11Info::appRootWindow(qt_xdnd_current_screen);
Window target = 0; Window target = 0;
int lx = 0, ly = 0; int lx = 0, ly = 0;
if (!XTranslateCoordinates(X11->display, rootwin, rootwin, globalPos.x(), globalPos.y(), &lx, &ly, &target)) if (!XTranslateCoordinates(qt_x11Data->display, rootwin, rootwin, globalPos.x(), globalPos.y(), &lx, &ly, &target))
// some weird error... // some weird error...
return; return;
@ -1553,7 +1553,7 @@ void QDragManager::move(const QPoint & globalPos)
int lx2, ly2; int lx2, ly2;
Window t; Window t;
// translate coordinates // translate coordinates
if (!XTranslateCoordinates(X11->display, src, target, lx, ly, &lx2, &ly2, &t)) { if (!XTranslateCoordinates(qt_x11Data->display, src, target, lx, ly, &lx2, &ly2, &t)) {
target = 0; target = 0;
break; break;
} }
@ -1566,7 +1566,7 @@ void QDragManager::move(const QPoint & globalPos)
int f; int f;
unsigned long n, a; unsigned long n, a;
unsigned char *data = 0; unsigned char *data = 0;
XGetWindowProperty(X11->display, target, ATOM(XdndAware), 0, 0, False, XGetWindowProperty(qt_x11Data->display, target, ATOM(XdndAware), 0, 0, False,
AnyPropertyType, &type, &f,&n,&a,&data); AnyPropertyType, &type, &f,&n,&a,&data);
if (data) if (data)
XFree(data); XFree(data);
@ -1576,7 +1576,7 @@ void QDragManager::move(const QPoint & globalPos)
} }
// find child at the coordinates // find child at the coordinates
if (!XTranslateCoordinates(X11->display, src, src, lx, ly, &lx2, &ly2, &target)) { if (!XTranslateCoordinates(qt_x11Data->display, src, src, lx, ly, &lx2, &ly2, &target)) {
target = 0; target = 0;
break; break;
} }
@ -1613,17 +1613,17 @@ void QDragManager::move(const QPoint & globalPos)
int r, f; int r, f;
unsigned long n, a; unsigned long n, a;
unsigned char *retval; unsigned char *retval;
X11->ignoreBadwindow(); qt_x11Data->ignoreBadwindow();
r = XGetWindowProperty(X11->display, proxy_target, ATOM(XdndAware), 0, r = XGetWindowProperty(qt_x11Data->display, proxy_target, ATOM(XdndAware), 0,
1, False, AnyPropertyType, &type, &f,&n,&a,&retval); 1, False, AnyPropertyType, &type, &f,&n,&a,&retval);
int *tv = (int *)retval; int *tv = (int *)retval;
if (r != Success || X11->badwindow()) { if (r != Success || qt_x11Data->badwindow()) {
target = 0; target = 0;
} else { } else {
target_version = qMin(xdnd_version,tv ? *tv : 1); target_version = qMin(xdnd_version,tv ? *tv : 1);
if (tv) if (tv)
XFree(tv); XFree(tv);
// if (!(!X11->badwindow() && type)) // if (!(!qt_x11Data->badwindow() && type))
// target = 0; // target = 0;
} }
} }
@ -1639,14 +1639,14 @@ void QDragManager::move(const QPoint & globalPos)
int flags = target_version << 24; int flags = target_version << 24;
QStringList fmts = QInternalMimeData::formatsHelper(dragPrivate()->data); QStringList fmts = QInternalMimeData::formatsHelper(dragPrivate()->data);
for (int i = 0; i < fmts.size(); ++i) { for (int i = 0; i < fmts.size(); ++i) {
QList<Atom> atoms = X11->xdndMimeAtomsForFormat(fmts.at(i)); QList<Atom> atoms = qt_x11Data->xdndMimeAtomsForFormat(fmts.at(i));
for (int j = 0; j < atoms.size(); ++j) { for (int j = 0; j < atoms.size(); ++j) {
if (!types.contains(atoms.at(j))) if (!types.contains(atoms.at(j)))
types.append(atoms.at(j)); types.append(atoms.at(j));
} }
} }
if (types.size() > 3) { if (types.size() > 3) {
XChangeProperty(X11->display, XChangeProperty(qt_x11Data->display,
dragPrivate()->source->effectiveWinId(), ATOM(XdndTypelist), dragPrivate()->source->effectiveWinId(), ATOM(XdndTypelist),
XA_ATOM, 32, PropModeReplace, XA_ATOM, 32, PropModeReplace,
(unsigned char *)types.data(), (unsigned char *)types.data(),
@ -1669,9 +1669,9 @@ void QDragManager::move(const QPoint & globalPos)
DEBUG("sending Xdnd enter"); DEBUG("sending Xdnd enter");
if (w) if (w)
X11->xdndHandleEnter(w, (const XEvent *)&enter, false); qt_x11Data->xdndHandleEnter(w, (const XEvent *)&enter, false);
else if (target) else if (target)
XSendEvent(X11->display, proxy_target, False, NoEventMask, (XEvent*)&enter); XSendEvent(qt_x11Data->display, proxy_target, False, NoEventMask, (XEvent*)&enter);
waiting_for_status = false; waiting_for_status = false;
} }
} }
@ -1690,16 +1690,16 @@ void QDragManager::move(const QPoint & globalPos)
move.data.l[0] = dragPrivate()->source->effectiveWinId(); move.data.l[0] = dragPrivate()->source->effectiveWinId();
move.data.l[1] = 0; // flags move.data.l[1] = 0; // flags
move.data.l[2] = (globalPos.x() << 16) + globalPos.y(); move.data.l[2] = (globalPos.x() << 16) + globalPos.y();
move.data.l[3] = X11->time; move.data.l[3] = qt_x11Data->time;
move.data.l[4] = qtaction_to_xdndaction(defaultAction(dragPrivate()->possible_actions, QApplication::keyboardModifiers())); move.data.l[4] = qtaction_to_xdndaction(defaultAction(dragPrivate()->possible_actions, QApplication::keyboardModifiers()));
DEBUG("sending Xdnd position"); DEBUG("sending Xdnd position");
qt_xdnd_source_current_time = X11->time; qt_xdnd_source_current_time = qt_x11Data->time;
if (w) if (w)
handle_xdnd_position(w, (const XEvent *)&move, false); handle_xdnd_position(w, (const XEvent *)&move, false);
else else
XSendEvent(X11->display, proxy_target, False, NoEventMask, XSendEvent(qt_x11Data->display, proxy_target, False, NoEventMask,
(XEvent*)&move); (XEvent*)&move);
} else { } else {
if (willDrop) { if (willDrop) {
@ -1732,7 +1732,7 @@ void QDragManager::drop()
drop.message_type = ATOM(XdndDrop); drop.message_type = ATOM(XdndDrop);
drop.data.l[0] = dragPrivate()->source->effectiveWinId(); drop.data.l[0] = dragPrivate()->source->effectiveWinId();
drop.data.l[1] = 0; // flags drop.data.l[1] = 0; // flags
drop.data.l[2] = X11->time; drop.data.l[2] = qt_x11Data->time;
drop.data.l[3] = 0; drop.data.l[3] = 0;
drop.data.l[4] = 0; drop.data.l[4] = 0;
@ -1743,20 +1743,20 @@ void QDragManager::drop()
w = 0; w = 0;
QXdndDropTransaction t = { QXdndDropTransaction t = {
X11->time, qt_x11Data->time,
qt_xdnd_current_target, qt_xdnd_current_target,
qt_xdnd_current_proxy_target, qt_xdnd_current_proxy_target,
w, w,
current_embedding_widget, current_embedding_widget,
object object
}; };
X11->dndDropTransactions.append(t); qt_x11Data->dndDropTransactions.append(t);
restartXdndDropExpiryTimer(); restartXdndDropExpiryTimer();
if (w) if (w)
X11->xdndHandleDrop(w, (const XEvent *)&drop, false); qt_x11Data->xdndHandleDrop(w, (const XEvent *)&drop, false);
else else
XSendEvent(X11->display, qt_xdnd_current_proxy_target, False, XSendEvent(qt_x11Data->display, qt_xdnd_current_proxy_target, False,
NoEventMask, (XEvent*)&drop); NoEventMask, (XEvent*)&drop);
qt_xdnd_current_target = 0; qt_xdnd_current_target = 0;
@ -1848,7 +1848,7 @@ void QX11Data::xdndHandleSelectionRequest(const XSelectionRequestEvent * req)
restartXdndDropExpiryTimer(); restartXdndDropExpiryTimer();
// use the drag object from an XdndDrop tansaction // use the drag object from an XdndDrop tansaction
manager->object = X11->dndDropTransactions.at(at).object; manager->object = qt_x11Data->dndDropTransactions.at(at).object;
} else if (at != -2) { } else if (at != -2) {
// no transaction found, we'll have to reject the request // no transaction found, we'll have to reject the request
manager->object = 0; manager->object = 0;
@ -1857,10 +1857,10 @@ void QX11Data::xdndHandleSelectionRequest(const XSelectionRequestEvent * req)
Atom atomFormat = req->target; Atom atomFormat = req->target;
int dataFormat = 0; int dataFormat = 0;
QByteArray data; QByteArray data;
if (X11->xdndMimeDataForAtom(req->target, manager->dragPrivate()->data, if (qt_x11Data->xdndMimeDataForAtom(req->target, manager->dragPrivate()->data,
&data, &atomFormat, &dataFormat)) { &data, &atomFormat, &dataFormat)) {
int dataSize = data.size() / (dataFormat / 8); int dataSize = data.size() / (dataFormat / 8);
XChangeProperty (X11->display, req->requestor, req->property, XChangeProperty (qt_x11Data->display, req->requestor, req->property,
atomFormat, dataFormat, PropModeReplace, atomFormat, dataFormat, PropModeReplace,
(unsigned char *)data.data(), dataSize); (unsigned char *)data.data(), dataSize);
evt.xselection.property = req->property; evt.xselection.property = req->property;
@ -1873,7 +1873,7 @@ void QX11Data::xdndHandleSelectionRequest(const XSelectionRequestEvent * req)
// ### this can die if req->requestor crashes at the wrong // ### this can die if req->requestor crashes at the wrong
// ### moment // ### moment
XSendEvent(X11->display, req->requestor, False, 0, &evt); XSendEvent(qt_x11Data->display, req->requestor, False, 0, &evt);
} }
static QVariant xdndObtainData(const char *format, QVariant::Type requestedType) static QVariant xdndObtainData(const char *format, QVariant::Type requestedType)
@ -1907,30 +1907,30 @@ static QVariant xdndObtainData(const char *format, QVariant::Type requestedType)
++i; ++i;
} }
QByteArray encoding; QByteArray encoding;
Atom a = X11->xdndMimeAtomForFormat(QLatin1String(format), requestedType, atoms, &encoding); Atom a = qt_x11Data->xdndMimeAtomForFormat(QLatin1String(format), requestedType, atoms, &encoding);
if (!a) if (!a)
return result; return result;
if (XGetSelectionOwner(X11->display, ATOM(XdndSelection)) == XNone) if (XGetSelectionOwner(qt_x11Data->display, ATOM(XdndSelection)) == XNone)
return result; // should never happen? return result; // should never happen?
QWidget* tw = qt_xdnd_current_widget; QWidget* tw = qt_xdnd_current_widget;
if (!qt_xdnd_current_widget || (qt_xdnd_current_widget->windowType() == Qt::Desktop)) if (!qt_xdnd_current_widget || (qt_xdnd_current_widget->windowType() == Qt::Desktop))
tw = new QWidget; tw = new QWidget;
XConvertSelection(X11->display, ATOM(XdndSelection), a, ATOM(XdndSelection), tw->effectiveWinId(), XConvertSelection(qt_x11Data->display, ATOM(XdndSelection), a, ATOM(XdndSelection), tw->effectiveWinId(),
qt_xdnd_target_current_time); qt_xdnd_target_current_time);
XFlush(X11->display); XFlush(qt_x11Data->display);
XEvent xevent; XEvent xevent;
bool got=X11->clipboardWaitForEvent(tw->effectiveWinId(), SelectionNotify, &xevent, 5000); bool got=qt_x11Data->clipboardWaitForEvent(tw->effectiveWinId(), SelectionNotify, &xevent, 5000);
if (got) { if (got) {
Atom type; Atom type;
if (X11->clipboardReadProperty(tw->effectiveWinId(), ATOM(XdndSelection), true, &result, 0, &type, 0)) { if (qt_x11Data->clipboardReadProperty(tw->effectiveWinId(), ATOM(XdndSelection), true, &result, 0, &type, 0)) {
if (type == ATOM(INCR)) { if (type == ATOM(INCR)) {
int nbytes = result.size() >= 4 ? *((int*)result.data()) : 0; int nbytes = result.size() >= 4 ? *((int*)result.data()) : 0;
result = X11->clipboardReadIncrementalProperty(tw->effectiveWinId(), ATOM(XdndSelection), nbytes, false); result = qt_x11Data->clipboardReadIncrementalProperty(tw->effectiveWinId(), ATOM(XdndSelection), nbytes, false);
} else if (type != a && type != XNone) { } else if (type != a && type != XNone) {
DEBUG("Qt clipboard: unknown atom %ld", type); DEBUG("Qt clipboard: unknown atom %ld", type);
} }
@ -1939,7 +1939,7 @@ static QVariant xdndObtainData(const char *format, QVariant::Type requestedType)
if (!qt_xdnd_current_widget || (qt_xdnd_current_widget->windowType() == Qt::Desktop)) if (!qt_xdnd_current_widget || (qt_xdnd_current_widget->windowType() == Qt::Desktop))
delete tw; delete tw;
return X11->xdndMimeConvertToFormat(a, result, QLatin1String(format), requestedType, encoding); return qt_x11Data->xdndMimeConvertToFormat(a, result, QLatin1String(format), requestedType, encoding);
} }
@ -1982,7 +1982,7 @@ Qt::DropAction QDragManager::drag(QDrag * o)
XEvent event; XEvent event;
// Pass the event through the event dispatcher filter so that applications // Pass the event through the event dispatcher filter so that applications
// which install an event filter on the dispatcher get to handle it first. // which install an event filter on the dispatcher get to handle it first.
if (XCheckTypedEvent(X11->display, ClientMessage, &event) && if (XCheckTypedEvent(qt_x11Data->display, ClientMessage, &event) &&
!QAbstractEventDispatcher::instance()->filterEvent(&event)) !QAbstractEventDispatcher::instance()->filterEvent(&event))
qApp->x11ProcessEvent(&event); qApp->x11ProcessEvent(&event);
@ -2003,7 +2003,7 @@ Qt::DropAction QDragManager::drag(QDrag * o)
updatePixmap(); updatePixmap();
qApp->installEventFilter(this); qApp->installEventFilter(this);
XSetSelectionOwner(X11->display, ATOM(XdndSelection), dragPrivate()->source->window()->internalWinId(), X11->time); XSetSelectionOwner(qt_x11Data->display, ATOM(XdndSelection), dragPrivate()->source->window()->internalWinId(), qt_x11Data->time);
global_accepted_action = Qt::CopyAction; global_accepted_action = Qt::CopyAction;
qt_xdnd_source_sameanswer = QRect(); qt_xdnd_source_sameanswer = QRect();
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
@ -2079,8 +2079,8 @@ void QDragManager::updatePixmap()
QVariant QDropData::retrieveData_sys(const QString &mimetype, QVariant::Type requestedType) const QVariant QDropData::retrieveData_sys(const QString &mimetype, QVariant::Type requestedType) const
{ {
QByteArray mime = mimetype.toLatin1(); QByteArray mime = mimetype.toLatin1();
QVariant data = X11->motifdnd_active QVariant data = qt_x11Data->motifdnd_active
? X11->motifdndObtainData(mime) ? qt_x11Data->motifdndObtainData(mime)
: xdndObtainData(mime, requestedType); : xdndObtainData(mime, requestedType);
return data; return data;
} }
@ -2093,17 +2093,17 @@ bool QDropData::hasFormat_sys(const QString &format) const
QStringList QDropData::formats_sys() const QStringList QDropData::formats_sys() const
{ {
QStringList formats; QStringList formats;
if (X11->motifdnd_active) { if (qt_x11Data->motifdnd_active) {
int i = 0; int i = 0;
QByteArray fmt; QByteArray fmt;
while (!(fmt = X11->motifdndFormat(i)).isEmpty()) { while (!(fmt = qt_x11Data->motifdndFormat(i)).isEmpty()) {
formats.append(QLatin1String(fmt)); formats.append(QLatin1String(fmt));
++i; ++i;
} }
} else { } else {
int i = 0; int i = 0;
while ((qt_xdnd_types[i])) { while ((qt_xdnd_types[i])) {
QStringList formatsForAtom = X11->xdndMimeFormatsForAtom(qt_xdnd_types[i]); QStringList formatsForAtom = qt_x11Data->xdndMimeFormatsForAtom(qt_xdnd_types[i]);
for (int j = 0; j < formatsForAtom.size(); ++j) { for (int j = 0; j < formatsForAtom.size(); ++j) {
if (!formats.contains(formatsForAtom.at(j))) if (!formats.contains(formatsForAtom.at(j)))
formats.append(formatsForAtom.at(j)); formats.append(formatsForAtom.at(j));

View file

@ -74,7 +74,7 @@ bool QEventDispatcherX11::processEvents(QEventLoop::ProcessEventsFlags flags)
d->interrupt = false; d->interrupt = false;
QApplication::sendPostedEvents(); QApplication::sendPostedEvents();
ulong marker = XNextRequest(X11->display); ulong marker = XNextRequest(qt_x11Data->display);
int nevents = 0; int nevents = 0;
do { do {
while (!d->interrupt) { while (!d->interrupt) {
@ -83,9 +83,9 @@ bool QEventDispatcherX11::processEvents(QEventLoop::ProcessEventsFlags flags)
&& !d->queuedUserInputEvents.isEmpty()) { && !d->queuedUserInputEvents.isEmpty()) {
// process a pending user input event // process a pending user input event
event = d->queuedUserInputEvents.takeFirst(); event = d->queuedUserInputEvents.takeFirst();
} else if (XEventsQueued(X11->display, QueuedAlready)) { } else if (XEventsQueued(qt_x11Data->display, QueuedAlready)) {
// process events from the X server // process events from the X server
XNextEvent(X11->display, &event); XNextEvent(qt_x11Data->display, &event);
if (flags & QEventLoop::ExcludeUserInputEvents) { if (flags & QEventLoop::ExcludeUserInputEvents) {
// queue user input events // queue user input events
@ -133,12 +133,12 @@ bool QEventDispatcherX11::processEvents(QEventLoop::ProcessEventsFlags flags)
return true; return true;
if (event.xany.serial >= marker) { if (event.xany.serial >= marker) {
if (XEventsQueued(X11->display, QueuedAfterFlush)) if (XEventsQueued(qt_x11Data->display, QueuedAfterFlush))
flags &= ~QEventLoop::WaitForMoreEvents; flags &= ~QEventLoop::WaitForMoreEvents;
goto out; goto out;
} }
} }
} while (!d->interrupt && XEventsQueued(X11->display, QueuedAfterFlush)); } while (!d->interrupt && XEventsQueued(qt_x11Data->display, QueuedAfterFlush));
out: out:
if (!d->interrupt) { if (!d->interrupt) {
@ -157,18 +157,18 @@ bool QEventDispatcherX11::processEvents(QEventLoop::ProcessEventsFlags flags)
bool QEventDispatcherX11::hasPendingEvents() bool QEventDispatcherX11::hasPendingEvents()
{ {
extern uint qGlobalPostedEventsCount(); // from qapplication.cpp extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
return (qGlobalPostedEventsCount() || XPending(X11->display)); return (qGlobalPostedEventsCount() || XPending(qt_x11Data->display));
} }
void QEventDispatcherX11::flush() void QEventDispatcherX11::flush()
{ {
XFlush(X11->display); XFlush(qt_x11Data->display);
} }
void QEventDispatcherX11::startingUp() void QEventDispatcherX11::startingUp()
{ {
Q_D(QEventDispatcherX11); Q_D(QEventDispatcherX11);
d->xfd = XConnectionNumber(X11->display); d->xfd = XConnectionNumber(qt_x11Data->display);
} }
void QEventDispatcherX11::closingDown() void QEventDispatcherX11::closingDown()

View file

@ -74,7 +74,7 @@ static gboolean x11EventSourcePrepare(GSource *s, gint *timeout)
if (timeout) if (timeout)
*timeout = -1; *timeout = -1;
GX11EventSource *source = reinterpret_cast<GX11EventSource *>(s); GX11EventSource *source = reinterpret_cast<GX11EventSource *>(s);
return (XEventsQueued(X11->display, QueuedAfterFlush) return (XEventsQueued(qt_x11Data->display, QueuedAfterFlush)
|| (!(source->flags & QEventLoop::ExcludeUserInputEvents) || (!(source->flags & QEventLoop::ExcludeUserInputEvents)
&& !source->d->queuedUserInputEvents.isEmpty())); && !source->d->queuedUserInputEvents.isEmpty()));
} }
@ -82,7 +82,7 @@ static gboolean x11EventSourcePrepare(GSource *s, gint *timeout)
static gboolean x11EventSourceCheck(GSource *s) static gboolean x11EventSourceCheck(GSource *s)
{ {
GX11EventSource *source = reinterpret_cast<GX11EventSource *>(s); GX11EventSource *source = reinterpret_cast<GX11EventSource *>(s);
return (XEventsQueued(X11->display, QueuedAfterFlush) return (XEventsQueued(qt_x11Data->display, QueuedAfterFlush)
|| (!(source->flags & QEventLoop::ExcludeUserInputEvents) || (!(source->flags & QEventLoop::ExcludeUserInputEvents)
&& !source->d->queuedUserInputEvents.isEmpty())); && !source->d->queuedUserInputEvents.isEmpty()));
} }
@ -91,16 +91,16 @@ static gboolean x11EventSourceDispatch(GSource *s, GSourceFunc callback, gpointe
{ {
GX11EventSource *source = reinterpret_cast<GX11EventSource *>(s); GX11EventSource *source = reinterpret_cast<GX11EventSource *>(s);
ulong marker = XNextRequest(X11->display); ulong marker = XNextRequest(qt_x11Data->display);
do { do {
XEvent event; XEvent event;
if (!(source->flags & QEventLoop::ExcludeUserInputEvents) if (!(source->flags & QEventLoop::ExcludeUserInputEvents)
&& !source->d->queuedUserInputEvents.isEmpty()) { && !source->d->queuedUserInputEvents.isEmpty()) {
// process a pending user input event // process a pending user input event
event = source->d->queuedUserInputEvents.takeFirst(); event = source->d->queuedUserInputEvents.takeFirst();
} else if (XEventsQueued(X11->display, QueuedAlready)) { } else if (XEventsQueued(qt_x11Data->display, QueuedAlready)) {
// process events from the X server // process events from the X server
XNextEvent(X11->display, &event); XNextEvent(qt_x11Data->display, &event);
if (source->flags & QEventLoop::ExcludeUserInputEvents) { if (source->flags & QEventLoop::ExcludeUserInputEvents) {
// queue user input events // queue user input events
@ -148,7 +148,7 @@ static gboolean x11EventSourceDispatch(GSource *s, GSourceFunc callback, gpointe
if (event.xany.serial >= marker) if (event.xany.serial >= marker)
goto out; goto out;
} while (XEventsQueued(X11->display, QueuedAfterFlush)); } while (XEventsQueued(qt_x11Data->display, QueuedAfterFlush));
out: out:
@ -209,7 +209,7 @@ bool QGuiEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags
void QGuiEventDispatcherGlib::startingUp() void QGuiEventDispatcherGlib::startingUp()
{ {
Q_D(QGuiEventDispatcherGlib); Q_D(QGuiEventDispatcherGlib);
d->x11EventSource->pollfd.fd = XConnectionNumber(X11->display); d->x11EventSource->pollfd.fd = XConnectionNumber(qt_x11Data->display);
d->x11EventSource->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR; d->x11EventSource->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
d->x11EventSource->q = this; d->x11EventSource->q = this;
d->x11EventSource->d = d; d->x11EventSource->d = d;
@ -218,7 +218,7 @@ void QGuiEventDispatcherGlib::startingUp()
void QGuiEventDispatcherGlib::flush() void QGuiEventDispatcherGlib::flush()
{ {
XFlush(X11->display); XFlush(qt_x11Data->display);
} }
QT_END_NAMESPACE QT_END_NAMESPACE

View file

@ -77,7 +77,7 @@ QGuiPlatformPlugin *qt_guiPlatformPlugin()
QString key = QString::fromLocal8Bit(qgetenv("QT_PLATFORM_PLUGIN")); QString key = QString::fromLocal8Bit(qgetenv("QT_PLATFORM_PLUGIN"));
#ifdef Q_WS_X11 #ifdef Q_WS_X11
if (key.isEmpty()) { if (key.isEmpty()) {
switch(X11->desktopEnvironment) { switch(qt_x11Data->desktopEnvironment) {
case DE_KDE: case DE_KDE:
key = QString::fromLatin1("kde"); key = QString::fromLatin1("kde");
break; break;
@ -125,12 +125,12 @@ QString QGuiPlatformPlugin::styleName()
return QLatin1String("CDE"); // default style for X11 on Solaris return QLatin1String("CDE"); // default style for X11 on Solaris
#elif defined(Q_WS_X11) #elif defined(Q_WS_X11)
QString stylename; QString stylename;
switch(X11->desktopEnvironment) { switch(qt_x11Data->desktopEnvironment) {
case DE_KDE: case DE_KDE:
stylename = QKde::kdeStyle(); stylename = QKde::kdeStyle();
break; break;
case DE_GNOME: { case DE_GNOME: {
if (X11->use_xrender) if (qt_x11Data->use_xrender)
stylename = QLatin1String("cleanlooks"); stylename = QLatin1String("cleanlooks");
else else
stylename = QLatin1String("windows"); stylename = QLatin1String("windows");
@ -151,7 +151,7 @@ QString QGuiPlatformPlugin::styleName()
QPalette QGuiPlatformPlugin::palette() QPalette QGuiPlatformPlugin::palette()
{ {
#ifdef Q_WS_X11 #ifdef Q_WS_X11
if (QApplication::desktopSettingsAware() && X11->desktopEnvironment == DE_KDE) if (QApplication::desktopSettingsAware() && qt_x11Data->desktopEnvironment == DE_KDE)
return QKde::kdePalette(); return QKde::kdePalette();
#endif #endif
@ -163,12 +163,12 @@ QString QGuiPlatformPlugin::systemIconThemeName()
{ {
QString result; QString result;
#ifdef Q_WS_X11 #ifdef Q_WS_X11
if (X11->desktopEnvironment == DE_GNOME) { if (qt_x11Data->desktopEnvironment == DE_GNOME) {
if (result.isEmpty()) { if (result.isEmpty()) {
result = QString::fromLatin1("gnome"); result = QString::fromLatin1("gnome");
} }
} else if (X11->desktopEnvironment == DE_KDE) { } else if (qt_x11Data->desktopEnvironment == DE_KDE) {
result = X11->desktopVersion >= 4 ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg"); result = qt_x11Data->desktopVersion >= 4 ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg");
QSettings settings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); QSettings settings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
settings.beginGroup(QLatin1String("Icons")); settings.beginGroup(QLatin1String("Icons"));
result = settings.value(QLatin1String("Theme"), result).toString(); result = settings.value(QLatin1String("Theme"), result).toString();
@ -193,7 +193,7 @@ QStringList QGuiPlatformPlugin::iconThemeSearchPaths()
if (dir.exists()) if (dir.exists())
paths.append(dir.path() + QLatin1String("/icons")); paths.append(dir.path() + QLatin1String("/icons"));
} }
if (X11->desktopEnvironment == DE_KDE) { if (qt_x11Data->desktopEnvironment == DE_KDE) {
paths << QLatin1Char(':') + QKde::kdeHome() + QLatin1String("/share/icons"); paths << QLatin1Char(':') + QKde::kdeHome() + QLatin1String("/share/icons");
QStringList kdeDirs = QFile::decodeName(getenv("KDEDIRS")).split(QLatin1Char(':')); QStringList kdeDirs = QFile::decodeName(getenv("KDEDIRS")).split(QLatin1Char(':'));
for (int i = 0 ; i< kdeDirs.count() ; ++i) { for (int i = 0 ; i< kdeDirs.count() ; ++i) {
@ -227,7 +227,7 @@ int QGuiPlatformPlugin::platformHint(PlatformHint hint)
case PH_ToolButtonStyle: case PH_ToolButtonStyle:
ret = Qt::ToolButtonIconOnly; ret = Qt::ToolButtonIconOnly;
#ifdef Q_WS_X11 #ifdef Q_WS_X11
if (X11->desktopEnvironment == DE_KDE && X11->desktopVersion >= 4 if (qt_x11Data->desktopEnvironment == DE_KDE && qt_x11Data->desktopVersion >= 4
&& QApplication::desktopSettingsAware()) { && QApplication::desktopSettingsAware()) {
ret = QKde::kdeToolButtonStyle(); ret = QKde::kdeToolButtonStyle();
} }
@ -235,7 +235,7 @@ int QGuiPlatformPlugin::platformHint(PlatformHint hint)
break; break;
case PH_ToolBarIconSize: case PH_ToolBarIconSize:
#ifdef Q_WS_X11 #ifdef Q_WS_X11
if (X11->desktopEnvironment == DE_KDE && X11->desktopVersion >= 4 if (qt_x11Data->desktopEnvironment == DE_KDE && qt_x11Data->desktopVersion >= 4
&& QApplication::desktopSettingsAware()) { && QApplication::desktopSettingsAware()) {
ret = QKde::kdeToolBarIconSize(); ret = QKde::kdeToolBarIconSize();
} }

View file

@ -63,7 +63,7 @@ QString QKde::kdeHome()
if (kdeHomePath.isEmpty()) { if (kdeHomePath.isEmpty()) {
QDir homeDir(QDir::homePath()); QDir homeDir(QDir::homePath());
QString kdeConfDir(QLatin1String("/.kde")); QString kdeConfDir(QLatin1String("/.kde"));
if (4 == X11->desktopVersion && homeDir.exists(QLatin1String(".kde4"))) if (4 == qt_x11Data->desktopVersion && homeDir.exists(QLatin1String(".kde4")))
kdeConfDir = QLatin1String("/.kde4"); kdeConfDir = QLatin1String("/.kde4");
kdeHomePath = QDir::homePath() + kdeConfDir; kdeHomePath = QDir::homePath() + kdeConfDir;
} }
@ -125,7 +125,7 @@ QPalette QKde::kdePalette()
*/ */
QString QKde::kdeStyle() QString QKde::kdeStyle()
{ {
if (X11->desktopVersion >= 4) { if (qt_x11Data->desktopVersion >= 4) {
QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
QString style = kdeSettings.value(QLatin1String("widgetStyle"), QLatin1String("Oxygen")).toString(); QString style = kdeSettings.value(QLatin1String("widgetStyle"), QLatin1String("Oxygen")).toString();
@ -134,7 +134,7 @@ QString QKde::kdeStyle()
return style; return style;
} }
if (X11->use_xrender) if (qt_x11Data->use_xrender)
return QLatin1String("plastique"); return QLatin1String("plastique");
else else
return QLatin1String("windows"); return QLatin1String("windows");

View file

@ -332,10 +332,10 @@ void QKeyMapperPrivate::clearMappings()
coreDesc.min_keycode = 8; coreDesc.min_keycode = 8;
coreDesc.max_keycode = 255; coreDesc.max_keycode = 255;
XDisplayKeycodes(X11->display, &coreDesc.min_keycode, &coreDesc.max_keycode); XDisplayKeycodes(qt_x11Data->display, &coreDesc.min_keycode, &coreDesc.max_keycode);
coreDesc.keysyms_per_keycode = 0; coreDesc.keysyms_per_keycode = 0;
coreDesc.keysyms = XGetKeyboardMapping(X11->display, coreDesc.keysyms = XGetKeyboardMapping(qt_x11Data->display,
coreDesc.min_keycode, coreDesc.min_keycode,
coreDesc.max_keycode - coreDesc.min_keycode + 1, coreDesc.max_keycode - coreDesc.min_keycode + 1,
&coreDesc.keysyms_per_keycode); &coreDesc.keysyms_per_keycode);
@ -360,7 +360,7 @@ void QKeyMapperPrivate::clearMappings()
coreDesc.lock_meaning = NoSymbol; coreDesc.lock_meaning = NoSymbol;
XModifierKeymap *map = XGetModifierMapping(X11->display); XModifierKeymap *map = XGetModifierMapping(qt_x11Data->display);
if (map) { if (map) {
int i, maskIndex = 0, mapIndex = 0; int i, maskIndex = 0, mapIndex = 0;
@ -370,7 +370,7 @@ void QKeyMapperPrivate::clearMappings()
KeySym sym; KeySym sym;
int x = 0; int x = 0;
do { do {
sym = XKeycodeToKeysym(X11->display, map->modifiermap[mapIndex], x++); sym = XKeycodeToKeysym(qt_x11Data->display, map->modifiermap[mapIndex], x++);
} while (sym == NoSymbol && x < coreDesc.keysyms_per_keycode); } while (sym == NoSymbol && x < coreDesc.keysyms_per_keycode);
const uchar mask = 1 << maskIndex; const uchar mask = 1 << maskIndex;
SETMASK(sym, mask); SETMASK(sym, mask);
@ -382,7 +382,7 @@ void QKeyMapperPrivate::clearMappings()
// determine the meaning of the Lock modifier // determine the meaning of the Lock modifier
for (i = 0; i < map->max_keypermod; ++i) { for (i = 0; i < map->max_keypermod; ++i) {
for (int x = 0; x < coreDesc.keysyms_per_keycode; ++x) { for (int x = 0; x < coreDesc.keysyms_per_keycode; ++x) {
KeySym sym = XKeycodeToKeysym(X11->display, map->modifiermap[LockMapIndex], x); KeySym sym = XKeycodeToKeysym(qt_x11Data->display, map->modifiermap[LockMapIndex], x);
if (sym == XK_Caps_Lock || sym == XK_ISO_Lock) { if (sym == XK_Caps_Lock || sym == XK_ISO_Lock) {
coreDesc.lock_meaning = XK_Caps_Lock; coreDesc.lock_meaning = XK_Caps_Lock;
break; break;
@ -1035,7 +1035,7 @@ static QString translateKeySym(KeySym keysym, uint xmodifiers,
} }
} }
modifiers = X11->translateModifiers(xmodifiers); modifiers = qt_x11Data->translateModifiers(xmodifiers);
// Commentary in X11/keysymdef says that X codes match ASCII, so it // Commentary in X11/keysymdef says that X codes match ASCII, so it
// is safe to use the locale functions to process X codes in ISO8859-1. // is safe to use the locale functions to process X codes in ISO8859-1.
@ -1236,7 +1236,7 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *keyWidget, const XEvent *even
if (qt_sm_blockUserInput) // block user interaction during session management if (qt_sm_blockUserInput) // block user interaction during session management
return true; return true;
Display *dpy = X11->display; Display *dpy = qt_x11Data->display;
if (!keyWidget->isEnabled()) if (!keyWidget->isEnabled())
return true; return true;

View file

@ -712,7 +712,7 @@ QByteArray QX11Data::motifdndFormat(int n)
if (target == ATOM(TEXT)) if (target == ATOM(TEXT))
return "text/plain"; return "text/plain";
return ("x-motif-dnd/" + X11->xdndAtomToString(target)); return ("x-motif-dnd/" + qt_x11Data->xdndAtomToString(target));
} }
@ -746,10 +746,10 @@ QVariant QX11Data::motifdndObtainData(const char *mimeType)
conversion_type = ATOM(TEXT); conversion_type = ATOM(TEXT);
} else if (f.startsWith("x-motif-dnd/")) { } else if (f.startsWith("x-motif-dnd/")) {
// strip off the "x-motif-dnd/" prefix // strip off the "x-motif-dnd/" prefix
conversion_type = X11->xdndStringToAtom(f.remove(0, 12)); conversion_type = qt_x11Data->xdndStringToAtom(f.remove(0, 12));
} }
if (XGetSelectionOwner(X11->display, Dnd_selection) == XNone) { if (XGetSelectionOwner(qt_x11Data->display, Dnd_selection) == XNone) {
return result; // should never happen? return result; // should never happen?
} }
@ -759,26 +759,26 @@ QVariant QX11Data::motifdndObtainData(const char *mimeType)
} }
// convert selection to the appropriate type // convert selection to the appropriate type
XConvertSelection (X11->display, Dnd_selection, conversion_type, XConvertSelection (qt_x11Data->display, Dnd_selection, conversion_type,
Dnd_selection, tw->internalWinId(), Dnd_selection_time); Dnd_selection, tw->internalWinId(), Dnd_selection_time);
XFlush(X11->display); XFlush(qt_x11Data->display);
XEvent xevent; XEvent xevent;
bool got=X11->clipboardWaitForEvent(tw->internalWinId(), SelectionNotify, &xevent, 5000); bool got=qt_x11Data->clipboardWaitForEvent(tw->internalWinId(), SelectionNotify, &xevent, 5000);
if (got) { if (got) {
Atom type; Atom type;
if (X11->clipboardReadProperty(tw->internalWinId(), Dnd_selection, true, &result, 0, &type, 0)) { if (qt_x11Data->clipboardReadProperty(tw->internalWinId(), Dnd_selection, true, &result, 0, &type, 0)) {
} }
} }
// we have to convert selection in order to indicate success to the initiator // we have to convert selection in order to indicate success to the initiator
XConvertSelection (X11->display, Dnd_selection, ATOM(XmTRANSFER_SUCCESS), XConvertSelection (qt_x11Data->display, Dnd_selection, ATOM(XmTRANSFER_SUCCESS),
Dnd_selection, tw->internalWinId(), Dnd_selection_time); Dnd_selection, tw->internalWinId(), Dnd_selection_time);
// wait again for SelectionNotify event // wait again for SelectionNotify event
X11->clipboardWaitForEvent(tw->internalWinId(), SelectionNotify, &xevent, 5000); qt_x11Data->clipboardWaitForEvent(tw->internalWinId(), SelectionNotify, &xevent, 5000);
if ((dropWidget->windowType() == Qt::Desktop)) { if ((dropWidget->windowType() == Qt::Desktop)) {
delete tw; delete tw;
@ -823,13 +823,13 @@ void QX11Data::motifdndHandle(QWidget *widget, const XEvent * xe, bool /* passiv
lastAcceptedAction = Qt::IgnoreAction; lastAcceptedAction = Qt::IgnoreAction;
dnd_data.reason = DND_DROP_SITE_LEAVE; dnd_data.reason = DND_DROP_SITE_LEAVE;
dnd_data.time = X11->time; dnd_data.time = qt_x11Data->time;
DndFillClientMessage (event.xclient.display, sourceWindow, &cm, &dnd_data, receiver); DndFillClientMessage (event.xclient.display, sourceWindow, &cm, &dnd_data, receiver);
XSendEvent(event.xbutton.display, sourceWindow, False, 0, (XEvent *)&cm) ; XSendEvent(event.xbutton.display, sourceWindow, False, 0, (XEvent *)&cm) ;
} else { } else {
dnd_data.reason = DND_DRAG_MOTION; dnd_data.reason = DND_DRAG_MOTION;
dnd_data.status = DND_NO_DROP_SITE; dnd_data.status = DND_NO_DROP_SITE;
dnd_data.time = X11->time; dnd_data.time = qt_x11Data->time;
dnd_data.operation = DND_NOOP; dnd_data.operation = DND_NOOP;
dnd_data.operations = DND_NOOP; dnd_data.operations = DND_NOOP;
DndFillClientMessage (event.xclient.display, sourceWindow, &cm, &dnd_data, receiver); DndFillClientMessage (event.xclient.display, sourceWindow, &cm, &dnd_data, receiver);
@ -855,7 +855,7 @@ void QX11Data::motifdndHandle(QWidget *widget, const XEvent * xe, bool /* passiv
QApplication::sendEvent(dropWidget, &de); QApplication::sendEvent(dropWidget, &de);
dnd_data.reason = DND_DROP_SITE_ENTER; dnd_data.reason = DND_DROP_SITE_ENTER;
dnd_data.time = X11->time; dnd_data.time = qt_x11Data->time;
if (de.isAccepted()) { if (de.isAccepted()) {
lastAcceptedAction = de.dropAction(); lastAcceptedAction = de.dropAction();
@ -880,7 +880,7 @@ void QX11Data::motifdndHandle(QWidget *widget, const XEvent * xe, bool /* passiv
QApplication::sendEvent(dropWidget, &me); QApplication::sendEvent(dropWidget, &me);
dnd_data.reason = DND_DRAG_MOTION; dnd_data.reason = DND_DRAG_MOTION;
dnd_data.time = X11->time; dnd_data.time = qt_x11Data->time;
if (me.isAccepted()) { if (me.isAccepted()) {
lastAcceptedAction = me.dropAction(); lastAcceptedAction = me.dropAction();
@ -920,9 +920,9 @@ void QX11Data::motifdndHandle(QWidget *widget, const XEvent * xe, bool /* passiv
case DND_TOP_LEVEL_LEAVE: case DND_TOP_LEVEL_LEAVE:
{ {
XEvent nextEvent; XEvent nextEvent;
if (XCheckTypedWindowEvent(X11->display, widget->winId(), ClientMessage, &nextEvent)) { if (XCheckTypedWindowEvent(qt_x11Data->display, widget->winId(), ClientMessage, &nextEvent)) {
// we just want to check, not eat (should use XPeekIfEvent) // we just want to check, not eat (should use XPeekIfEvent)
XPutBackEvent(X11->display, &nextEvent); XPutBackEvent(qt_x11Data->display, &nextEvent);
if (DndParseClientMessage (&nextEvent.xclient, &dnd_data, &receiver) if (DndParseClientMessage (&nextEvent.xclient, &dnd_data, &receiver)
&& dnd_data.reason == DND_DROP_START) { && dnd_data.reason == DND_DROP_START) {
@ -965,7 +965,7 @@ void QX11Data::motifdndHandle(QWidget *widget, const XEvent * xe, bool /* passiv
XSendEvent(event.xbutton.display, sourceWindow, False, 0, (XEvent *)&cm); XSendEvent(event.xbutton.display, sourceWindow, False, 0, (XEvent *)&cm);
// we have to convert selection in order to indicate failure to the initiator // we have to convert selection in order to indicate failure to the initiator
XConvertSelection (X11->display, dnd_data.property, ATOM(XmTRANSFER_FAILURE), XConvertSelection (qt_x11Data->display, dnd_data.property, ATOM(XmTRANSFER_FAILURE),
dnd_data.property, dnd_data.src_window, dnd_data.time); dnd_data.property, dnd_data.src_window, dnd_data.time);
if (dropWidget) { if (dropWidget) {

View file

@ -487,7 +487,6 @@ struct QX11Data
extern Q_GUI_EXPORT QX11Data *qt_x11Data; extern Q_GUI_EXPORT QX11Data *qt_x11Data;
#define ATOM(x) qt_x11Data->atoms[QX11Data::x] #define ATOM(x) qt_x11Data->atoms[QX11Data::x]
#define X11 qt_x11Data
// rename a couple of X defines to get rid of name clashes // rename a couple of X defines to get rid of name clashes
// resolve the conflict between X11's FocusIn and QEvent::FocusIn // resolve the conflict between X11's FocusIn and QEvent::FocusIn

File diff suppressed because it is too large Load diff

View file

@ -851,8 +851,8 @@ bool QX11EmbedWidget::x11Event(XEvent *event)
// Update qt_x_time if necessary // Update qt_x_time if necessary
Time msgtime = (Time) event->xclient.data.l[0]; Time msgtime = (Time) event->xclient.data.l[0];
if (msgtime > X11->time) if (msgtime > qt_x11Data->time)
X11->time = msgtime; qt_x11Data->time = msgtime;
switch (event->xclient.data.l[1]) { switch (event->xclient.data.l[1]) {
case XEMBED_WINDOW_ACTIVATE: { case XEMBED_WINDOW_ACTIVATE: {
@ -1471,8 +1471,8 @@ bool QX11EmbedContainer::x11Event(XEvent *event)
d->clientIsXEmbed = true; d->clientIsXEmbed = true;
Time msgtime = (Time) event->xclient.data.l[0]; Time msgtime = (Time) event->xclient.data.l[0];
if (msgtime > X11->time) if (msgtime > qt_x11Data->time)
X11->time = msgtime; qt_x11Data->time = msgtime;
switch (event->xclient.data.l[1]) { switch (event->xclient.data.l[1]) {
case XEMBED_REQUEST_FOCUS: { case XEMBED_REQUEST_FOCUS: {

View file

@ -208,13 +208,13 @@ QX11InfoData* QX11Info::getX11Data(bool def) const
*/ */
int QX11Info::appDpiX(int screen) int QX11Info::appDpiX(int screen)
{ {
if (!X11) if (!qt_x11Data)
return 75; return 75;
if (screen < 0) if (screen < 0)
screen = X11->defaultScreen; screen = qt_x11Data->defaultScreen;
if (screen > X11->screenCount) if (screen > qt_x11Data->screenCount)
return 0; return 0;
return X11->screens[screen].dpiX; return qt_x11Data->screens[screen].dpiX;
} }
/*! /*!
@ -231,13 +231,13 @@ int QX11Info::appDpiX(int screen)
void QX11Info::setAppDpiX(int screen, int xdpi) void QX11Info::setAppDpiX(int screen, int xdpi)
{ {
if (!X11) if (!qt_x11Data)
return; return;
if (screen < 0) if (screen < 0)
screen = X11->defaultScreen; screen = qt_x11Data->defaultScreen;
if (screen > X11->screenCount) if (screen > qt_x11Data->screenCount)
return; return;
X11->screens[screen].dpiX = xdpi; qt_x11Data->screens[screen].dpiX = xdpi;
} }
/*! /*!
@ -254,13 +254,13 @@ void QX11Info::setAppDpiX(int screen, int xdpi)
int QX11Info::appDpiY(int screen) int QX11Info::appDpiY(int screen)
{ {
if (!X11) if (!qt_x11Data)
return 75; return 75;
if (screen < 0) if (screen < 0)
screen = X11->defaultScreen; screen = qt_x11Data->defaultScreen;
if (screen > X11->screenCount) if (screen > qt_x11Data->screenCount)
return 0; return 0;
return X11->screens[screen].dpiY; return qt_x11Data->screens[screen].dpiY;
} }
/*! /*!
@ -276,13 +276,13 @@ int QX11Info::appDpiY(int screen)
*/ */
void QX11Info::setAppDpiY(int screen, int ydpi) void QX11Info::setAppDpiY(int screen, int ydpi)
{ {
if (!X11) if (!qt_x11Data)
return; return;
if (screen < 0) if (screen < 0)
screen = X11->defaultScreen; screen = qt_x11Data->defaultScreen;
if (screen > X11->screenCount) if (screen > qt_x11Data->screenCount)
return; return;
X11->screens[screen].dpiY = ydpi; qt_x11Data->screens[screen].dpiY = ydpi;
} }
/*! /*!
@ -292,7 +292,7 @@ void QX11Info::setAppDpiY(int screen, int ydpi)
*/ */
unsigned long QX11Info::appTime() unsigned long QX11Info::appTime()
{ {
return X11 ? X11->time : 0; return qt_x11Data ? qt_x11Data->time : 0;
} }
/*! /*!
@ -302,8 +302,8 @@ unsigned long QX11Info::appTime()
*/ */
void QX11Info::setAppTime(unsigned long time) void QX11Info::setAppTime(unsigned long time)
{ {
if (X11) { if (qt_x11Data) {
X11->time = time; qt_x11Data->time = time;
} }
} }
@ -314,7 +314,7 @@ void QX11Info::setAppTime(unsigned long time)
*/ */
unsigned long QX11Info::appUserTime() unsigned long QX11Info::appUserTime()
{ {
return X11 ? X11->userTime : 0; return qt_x11Data ? qt_x11Data->userTime : 0;
} }
/*! /*!
@ -324,8 +324,8 @@ unsigned long QX11Info::appUserTime()
*/ */
void QX11Info::setAppUserTime(unsigned long time) void QX11Info::setAppUserTime(unsigned long time)
{ {
if (X11) { if (qt_x11Data) {
X11->userTime = time; qt_x11Data->userTime = time;
} }
} }
@ -346,7 +346,7 @@ void QX11Info::setAppUserTime(unsigned long time)
Display *QX11Info::display() Display *QX11Info::display()
{ {
return X11 ? X11->display : 0; return qt_x11Data ? qt_x11Data->display : 0;
} }
/*! /*!
@ -357,7 +357,7 @@ Display *QX11Info::display()
*/ */
int QX11Info::appScreen() int QX11Info::appScreen()
{ {
return X11 ? X11->defaultScreen : 0; return qt_x11Data ? qt_x11Data->defaultScreen : 0;
} }
/*! /*!
@ -372,7 +372,7 @@ int QX11Info::appScreen()
*/ */
Qt::HANDLE QX11Info::appColormap(int screen) Qt::HANDLE QX11Info::appColormap(int screen)
{ {
return X11 ? X11->screens[screen == -1 ? X11->defaultScreen : screen].colormap : 0; return qt_x11Data ? qt_x11Data->screens[screen == -1 ? qt_x11Data->defaultScreen : screen].colormap : 0;
} }
/*! /*!
@ -389,7 +389,7 @@ Qt::HANDLE QX11Info::appColormap(int screen)
void *QX11Info::appVisual(int screen) void *QX11Info::appVisual(int screen)
{ {
return X11 ? X11->screens[screen == -1 ? X11->defaultScreen : screen].visual : 0; return qt_x11Data ? qt_x11Data->screens[screen == -1 ? qt_x11Data->defaultScreen : screen].visual : 0;
} }
/*! /*!
@ -404,7 +404,7 @@ void *QX11Info::appVisual(int screen)
*/ */
Qt::HANDLE QX11Info::appRootWindow(int screen) Qt::HANDLE QX11Info::appRootWindow(int screen)
{ {
return X11 ? RootWindow(X11->display, screen == -1 ? X11->defaultScreen : screen) : 0; return qt_x11Data ? RootWindow(qt_x11Data->display, screen == -1 ? qt_x11Data->defaultScreen : screen) : 0;
} }
/*! /*!
@ -421,7 +421,7 @@ Qt::HANDLE QX11Info::appRootWindow(int screen)
int QX11Info::appDepth(int screen) int QX11Info::appDepth(int screen)
{ {
return X11 ? X11->screens[screen == -1 ? X11->defaultScreen : screen].depth : 32; return qt_x11Data ? qt_x11Data->screens[screen == -1 ? qt_x11Data->defaultScreen : screen].depth : 32;
} }
/*! /*!
@ -436,7 +436,7 @@ int QX11Info::appDepth(int screen)
*/ */
int QX11Info::appCells(int screen) int QX11Info::appCells(int screen)
{ return X11 ? X11->screens[screen == -1 ? X11->defaultScreen : screen].cells : 0; } { return qt_x11Data ? qt_x11Data->screens[screen == -1 ? qt_x11Data->defaultScreen : screen].cells : 0; }
/*! /*!
Returns true if the application has a default color map on the given Returns true if the application has a default color map on the given
@ -448,7 +448,7 @@ int QX11Info::appCells(int screen)
query for information about Xinerama screens. query for information about Xinerama screens.
*/ */
bool QX11Info::appDefaultColormap(int screen) bool QX11Info::appDefaultColormap(int screen)
{ return X11 ? X11->screens[screen == -1 ? X11->defaultScreen : screen].defaultColormap : true; } { return qt_x11Data ? qt_x11Data->screens[screen == -1 ? qt_x11Data->defaultScreen : screen].defaultColormap : true; }
/*! /*!
Returns true if the application has a default visual on the given \a screen; Returns true if the application has a default visual on the given \a screen;
@ -460,7 +460,7 @@ bool QX11Info::appDefaultColormap(int screen)
query for information about Xinerama screens. query for information about Xinerama screens.
*/ */
bool QX11Info::appDefaultVisual(int screen) bool QX11Info::appDefaultVisual(int screen)
{ return X11 ? X11->screens[screen == -1 ? X11->defaultScreen : screen].defaultVisual : true; } { return qt_x11Data ? qt_x11Data->screens[screen == -1 ? qt_x11Data->defaultScreen : screen].defaultVisual : true; }
/*! /*!
Returns the number of the screen currently in use. Returns the number of the screen currently in use.
@ -537,7 +537,7 @@ bool QX11Info::defaultVisual() const
*/ */
bool QX11Info::isCompositingManagerRunning() bool QX11Info::isCompositingManagerRunning()
{ {
return X11 ? X11->compositingManagerRunning : false; return qt_x11Data ? qt_x11Data->compositingManagerRunning : false;
} }
QT_END_NAMESPACE QT_END_NAMESPACE

View file

@ -322,7 +322,7 @@ static void init_direct(QColormapPrivate *d)
++i; ++i;
} }
XStoreColors(X11->display, d->colormap, colorTable.data(), colorTable.count()); XStoreColors(qt_x11Data->display, d->colormap, colorTable.data(), colorTable.count());
} }
static QColormap **cmaps = Q_NULLPTR; static QColormap **cmaps = Q_NULLPTR;
@ -339,7 +339,7 @@ void QColormap::initialize()
QColormapPrivate * const d = cmaps[i]->d; QColormapPrivate * const d = cmaps[i]->d;
bool use_stdcmap = false; bool use_stdcmap = false;
int color_count = X11->color_count; int color_count = qt_x11Data->color_count;
// defaults // defaults
d->depth = DefaultDepth(display, i); d->depth = DefaultDepth(display, i);
@ -350,32 +350,32 @@ void QColormap::initialize()
Visual *argbVisual = Q_NULLPTR; Visual *argbVisual = Q_NULLPTR;
if (X11->visual && i == DefaultScreen(display)) { if (qt_x11Data->visual && i == DefaultScreen(display)) {
// only use the outside colormap on the default screen // only use the outside colormap on the default screen
d->visual = find_visual(display, i, X11->visual->c_class, d->visual = find_visual(display, i, qt_x11Data->visual->c_class,
XVisualIDFromVisual(X11->visual), XVisualIDFromVisual(qt_x11Data->visual),
&d->depth, &d->defaultVisual); &d->depth, &d->defaultVisual);
} else if ((X11->visual_class != -1 && X11->visual_class >= 0 && X11->visual_class < 6) } else if ((qt_x11Data->visual_class != -1 && qt_x11Data->visual_class >= 0 && qt_x11Data->visual_class < 6)
|| (X11->visual_id != -1)) { || (qt_x11Data->visual_id != -1)) {
// look for a specific visual or type of visual // look for a specific visual or type of visual
d->visual = find_visual(display, i, X11->visual_class, X11->visual_id, d->visual = find_visual(display, i, qt_x11Data->visual_class, qt_x11Data->visual_id,
&d->depth, &d->defaultVisual); &d->depth, &d->defaultVisual);
} else if (!X11->custom_cmap) { } else if (!qt_x11Data->custom_cmap) {
XStandardColormap *stdcmap = Q_NULLPTR; XStandardColormap *stdcmap = Q_NULLPTR;
int ncmaps = 0; int ncmaps = 0;
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (X11->use_xrender) { if (qt_x11Data->use_xrender) {
int nvi; int nvi;
XVisualInfo templ; XVisualInfo templ;
templ.screen = i; templ.screen = i;
templ.depth = 32; templ.depth = 32;
templ.c_class = TrueColor; templ.c_class = TrueColor;
XVisualInfo *xvi = XGetVisualInfo(X11->display, VisualScreenMask | XVisualInfo *xvi = XGetVisualInfo(qt_x11Data->display, VisualScreenMask |
VisualDepthMask | VisualDepthMask |
VisualClassMask, &templ, &nvi); VisualClassMask, &templ, &nvi);
for (int idx = 0; idx < nvi; ++idx) { for (int idx = 0; idx < nvi; ++idx) {
XRenderPictFormat *format = XRenderFindVisualFormat(X11->display, XRenderPictFormat *format = XRenderFindVisualFormat(qt_x11Data->display,
xvi[idx].visual); xvi[idx].visual);
if (format->type == PictTypeDirect && format->direct.alphaMask) { if (format->type == PictTypeDirect && format->direct.alphaMask) {
argbVisual = xvi[idx].visual; argbVisual = xvi[idx].visual;
@ -507,12 +507,12 @@ void QColormap::initialize()
} }
bool ownColormap = false; bool ownColormap = false;
if (X11->colormap && i == DefaultScreen(display)) { if (qt_x11Data->colormap && i == DefaultScreen(display)) {
// only use the outside colormap on the default screen // only use the outside colormap on the default screen
d->colormap = X11->colormap; d->colormap = qt_x11Data->colormap;
d->defaultColormap = (d->colormap == DefaultColormap(display, i)); d->defaultColormap = (d->colormap == DefaultColormap(display, i));
} else if ((!use_stdcmap } else if ((!use_stdcmap
&& (((d->visual->c_class & 1) && X11->custom_cmap) && (((d->visual->c_class & 1) && qt_x11Data->custom_cmap)
|| d->visual != DefaultVisual(display, i))) || d->visual != DefaultVisual(display, i)))
|| d->visual->c_class == DirectColor) { || d->visual->c_class == DirectColor) {
// allocate custom colormap (we always do this when using DirectColor visuals) // allocate custom colormap (we always do this when using DirectColor visuals)
@ -536,7 +536,7 @@ void QColormap::initialize()
break; break;
} }
QX11InfoData *screen = X11->screens + i; QX11InfoData *screen = qt_x11Data->screens + i;
screen->depth = d->depth; screen->depth = d->depth;
screen->visual = d->visual; screen->visual = d->visual;
screen->defaultVisual = d->defaultVisual; screen->defaultVisual = d->defaultVisual;
@ -545,8 +545,8 @@ void QColormap::initialize()
screen->cells = screen->visual->map_entries; screen->cells = screen->visual->map_entries;
if (argbVisual) { if (argbVisual) {
X11->argbVisuals[i] = argbVisual; qt_x11Data->argbVisuals[i] = argbVisual;
X11->argbColormaps[i] = XCreateColormap(display, RootWindow(display, i), argbVisual, AllocNone); qt_x11Data->argbColormaps[i] = XCreateColormap(display, RootWindow(display, i), argbVisual, AllocNone);
} }
// ### // ###

View file

@ -265,72 +265,72 @@ void QXRenderTessellator::addTrap(const Trapezoid &trap)
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
static Picture getPatternFill(int screen, const QBrush &b) static Picture getPatternFill(int screen, const QBrush &b)
{ {
if (!X11->use_xrender) if (!qt_x11Data->use_xrender)
return XNone; return XNone;
XRenderColor color = X11->preMultiply(b.color()); XRenderColor color = qt_x11Data->preMultiply(b.color());
XRenderColor bg_color; XRenderColor bg_color;
bg_color = X11->preMultiply(QColor(0, 0, 0, 0)); bg_color = qt_x11Data->preMultiply(QColor(0, 0, 0, 0));
for (int i = 0; i < X11->pattern_fill_count; ++i) { for (int i = 0; i < qt_x11Data->pattern_fill_count; ++i) {
if (X11->pattern_fills[i].screen == screen if (qt_x11Data->pattern_fills[i].screen == screen
&& X11->pattern_fills[i].opaque == false && qt_x11Data->pattern_fills[i].opaque == false
&& X11->pattern_fills[i].style == b.style() && qt_x11Data->pattern_fills[i].style == b.style()
&& X11->pattern_fills[i].color.alpha == color.alpha && qt_x11Data->pattern_fills[i].color.alpha == color.alpha
&& X11->pattern_fills[i].color.red == color.red && qt_x11Data->pattern_fills[i].color.red == color.red
&& X11->pattern_fills[i].color.green == color.green && qt_x11Data->pattern_fills[i].color.green == color.green
&& X11->pattern_fills[i].color.blue == color.blue && qt_x11Data->pattern_fills[i].color.blue == color.blue
&& X11->pattern_fills[i].bg_color.alpha == bg_color.alpha && qt_x11Data->pattern_fills[i].bg_color.alpha == bg_color.alpha
&& X11->pattern_fills[i].bg_color.red == bg_color.red && qt_x11Data->pattern_fills[i].bg_color.red == bg_color.red
&& X11->pattern_fills[i].bg_color.green == bg_color.green && qt_x11Data->pattern_fills[i].bg_color.green == bg_color.green
&& X11->pattern_fills[i].bg_color.blue == bg_color.blue) && qt_x11Data->pattern_fills[i].bg_color.blue == bg_color.blue)
return X11->pattern_fills[i].picture; return qt_x11Data->pattern_fills[i].picture;
} }
// none found, replace one // none found, replace one
int i = qrand() % 16; int i = qrand() % 16;
if (X11->pattern_fills[i].screen != screen && X11->pattern_fills[i].picture) { if (qt_x11Data->pattern_fills[i].screen != screen && qt_x11Data->pattern_fills[i].picture) {
XRenderFreePicture (X11->display, X11->pattern_fills[i].picture); XRenderFreePicture (qt_x11Data->display, qt_x11Data->pattern_fills[i].picture);
X11->pattern_fills[i].picture = 0; qt_x11Data->pattern_fills[i].picture = 0;
} }
if (!X11->pattern_fills[i].picture) { if (!qt_x11Data->pattern_fills[i].picture) {
Pixmap pixmap = XCreatePixmap (X11->display, RootWindow (X11->display, screen), 8, 8, 32); Pixmap pixmap = XCreatePixmap (qt_x11Data->display, RootWindow (qt_x11Data->display, screen), 8, 8, 32);
XRenderPictureAttributes attrs; XRenderPictureAttributes attrs;
attrs.repeat = True; attrs.repeat = True;
X11->pattern_fills[i].picture = XRenderCreatePicture (X11->display, pixmap, qt_x11Data->pattern_fills[i].picture = XRenderCreatePicture (qt_x11Data->display, pixmap,
XRenderFindStandardFormat(X11->display, PictStandardARGB32), XRenderFindStandardFormat(qt_x11Data->display, PictStandardARGB32),
CPRepeat, &attrs); CPRepeat, &attrs);
XFreePixmap (X11->display, pixmap); XFreePixmap (qt_x11Data->display, pixmap);
} }
X11->pattern_fills[i].screen = screen; qt_x11Data->pattern_fills[i].screen = screen;
X11->pattern_fills[i].color = color; qt_x11Data->pattern_fills[i].color = color;
X11->pattern_fills[i].bg_color = bg_color; qt_x11Data->pattern_fills[i].bg_color = bg_color;
X11->pattern_fills[i].opaque = false; qt_x11Data->pattern_fills[i].opaque = false;
X11->pattern_fills[i].style = b.style(); qt_x11Data->pattern_fills[i].style = b.style();
XRenderFillRectangle(X11->display, PictOpSrc, X11->pattern_fills[i].picture, &bg_color, 0, 0, 8, 8); XRenderFillRectangle(qt_x11Data->display, PictOpSrc, qt_x11Data->pattern_fills[i].picture, &bg_color, 0, 0, 8, 8);
QPixmap pattern(qt_pixmapForBrush(b.style(), true)); QPixmap pattern(qt_pixmapForBrush(b.style(), true));
XRenderPictureAttributes attrs; XRenderPictureAttributes attrs;
attrs.repeat = true; attrs.repeat = true;
XRenderChangePicture(X11->display, pattern.x11PictureHandle(), CPRepeat, &attrs); XRenderChangePicture(qt_x11Data->display, pattern.x11PictureHandle(), CPRepeat, &attrs);
Picture fill_fg = X11->getSolidFill(screen, b.color()); Picture fill_fg = qt_x11Data->getSolidFill(screen, b.color());
XRenderComposite(X11->display, PictOpOver, fill_fg, pattern.x11PictureHandle(), XRenderComposite(qt_x11Data->display, PictOpOver, fill_fg, pattern.x11PictureHandle(),
X11->pattern_fills[i].picture, qt_x11Data->pattern_fills[i].picture,
0, 0, 0, 0, 0, 0, 8, 8); 0, 0, 0, 0, 0, 0, 8, 8);
return X11->pattern_fills[i].picture; return qt_x11Data->pattern_fills[i].picture;
} }
static void qt_render_bitmap(Display *dpy, int scrn, Picture src, Picture dst, static void qt_render_bitmap(Display *dpy, int scrn, Picture src, Picture dst,
int sx, int sy, int x, int y, int sw, int sh, int sx, int sy, int x, int y, int sw, int sh,
const QPen &pen) const QPen &pen)
{ {
Picture fill_fg = X11->getSolidFill(scrn, pen.color()); Picture fill_fg = qt_x11Data->getSolidFill(scrn, pen.color());
XRenderComposite(dpy, PictOpOver, XRenderComposite(dpy, PictOpOver,
fill_fg, src, dst, sx, sy, sx, sy, x, y, sw, sh); fill_fg, src, dst, sx, sy, sx, sy, x, y, sw, sh);
} }
@ -402,12 +402,12 @@ static QPaintEngine::PaintEngineFeatures qt_decide_features()
| QPaintEngine::PainterPaths | QPaintEngine::PainterPaths
| QPaintEngine::RasterOpModes; | QPaintEngine::RasterOpModes;
if (X11->use_xrender) { if (qt_x11Data->use_xrender) {
features |= QPaintEngine::Antialiasing; features |= QPaintEngine::Antialiasing;
features |= QPaintEngine::PorterDuff; features |= QPaintEngine::PorterDuff;
features |= QPaintEngine::MaskedBrush; features |= QPaintEngine::MaskedBrush;
#if 0 #if 0
if (X11->xrender_version > 10) { if (qt_x11Data->xrender_version > 10) {
features |= QPaintEngine::LinearGradientFill; features |= QPaintEngine::LinearGradientFill;
// ### // ###
} }
@ -456,7 +456,7 @@ bool QX11PaintEngine::begin(QPaintDevice *pdev)
} else if (pdev->devType() == QInternal::Pixmap) { } else if (pdev->devType() == QInternal::Pixmap) {
const QPixmap *pm = static_cast<const QPixmap *>(pdev); const QPixmap *pm = static_cast<const QPixmap *>(pdev);
QX11PixmapData *data = static_cast<QX11PixmapData*>(pm->data.data()); QX11PixmapData *data = static_cast<QX11PixmapData*>(pm->data.data());
if (X11->use_xrender && data->depth() != 32 && data->x11_mask) if (qt_x11Data->use_xrender && data->depth() != 32 && data->x11_mask)
data->convertToARGB32(); data->convertToARGB32();
d->picture = (::Picture)static_cast<const QPixmap *>(pdev)->x11PictureHandle(); d->picture = (::Picture)static_cast<const QPixmap *>(pdev)->x11PictureHandle();
} }
@ -809,12 +809,12 @@ void QX11PaintEngine::drawRects(const QRect *rects, int rectCount)
#if !defined(QT_NO_XRENDER) #if !defined(QT_NO_XRENDER)
::Picture pict = d->picture; ::Picture pict = d->picture;
if (X11->use_xrender && pict && d->has_brush && d->pdev_depth != 1 if (qt_x11Data->use_xrender && pict && d->has_brush && d->pdev_depth != 1
&& (d->has_texture || d->has_alpha_brush || complexPictOp(d->composition_mode))) && (d->has_texture || d->has_alpha_brush || complexPictOp(d->composition_mode)))
{ {
XRenderColor xc; XRenderColor xc;
if (!d->has_texture && !d->has_pattern) if (!d->has_texture && !d->has_pattern)
xc = X11->preMultiply(d->cbrush.color()); xc = qt_x11Data->preMultiply(d->cbrush.color());
for (int i = 0; i < rectCount; ++i) { for (int i = 0; i < rectCount; ++i) {
QRect r(rects[i]); QRect r(rects[i]);
@ -909,7 +909,7 @@ static inline void setCapStyle(int cap_style, GC gc)
ulong mask = GCCapStyle; ulong mask = GCCapStyle;
XGCValues vals; XGCValues vals;
vals.cap_style = cap_style; vals.cap_style = cap_style;
XChangeGC(X11->display, gc, mask, &vals); XChangeGC(qt_x11Data->display, gc, mask, &vals);
} }
void QX11PaintEngine::drawPoints(const QPoint *points, int pointCount) void QX11PaintEngine::drawPoints(const QPoint *points, int pointCount)
@ -924,7 +924,7 @@ void QX11PaintEngine::drawPoints(const QPoint *points, int pointCount)
// use the same test here as in drawPath to ensure that we don't use the path fallback // use the same test here as in drawPath to ensure that we don't use the path fallback
// and end up in XDrawLines for pens with width <= 1 // and end up in XDrawLines for pens with width <= 1
if (d->cpen.widthF() > 1.0f if (d->cpen.widthF() > 1.0f
|| (X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing))) || (qt_x11Data->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
|| (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate)) || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate))
{ {
Qt::PenCapStyle capStyle = d->cpen.capStyle(); Qt::PenCapStyle capStyle = d->cpen.capStyle();
@ -982,7 +982,7 @@ void QX11PaintEngine::drawPoints(const QPointF *points, int pointCount)
// use the same test here as in drawPath to ensure that we don't use the path fallback // use the same test here as in drawPath to ensure that we don't use the path fallback
// and end up in XDrawLines for pens with width <= 1 // and end up in XDrawLines for pens with width <= 1
if (d->cpen.widthF() > 1.0f if (d->cpen.widthF() > 1.0f
|| (X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing))) || (qt_x11Data->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
|| (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate)) || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate))
{ {
Qt::PenCapStyle capStyle = d->cpen.capStyle(); Qt::PenCapStyle capStyle = d->cpen.capStyle();
@ -1032,7 +1032,7 @@ void QX11PaintEngine::drawPoints(const QPointF *points, int pointCount)
QPainter::RenderHints QX11PaintEngine::supportedRenderHints() const QPainter::RenderHints QX11PaintEngine::supportedRenderHints() const
{ {
#if !defined(QT_NO_XRENDER) #if !defined(QT_NO_XRENDER)
if (X11->use_xrender) if (qt_x11Data->use_xrender)
return QPainter::Antialiasing; return QPainter::Antialiasing;
#endif #endif
return QFlag(0); return QFlag(0);
@ -1123,8 +1123,8 @@ void QX11PaintEngine::updateState(const QPaintEngineState &state)
qpainterOpToXrender(state.compositionMode()); qpainterOpToXrender(state.compositionMode());
} }
#endif #endif
XSetFunction(X11->display, d->gc, function); XSetFunction(qt_x11Data->display, d->gc, function);
XSetFunction(X11->display, d->gc_brush, function); XSetFunction(qt_x11Data->display, d->gc_brush, function);
} }
d->decidePathFallback(); d->decidePathFallback();
d->decideCoordAdjust(); d->decideCoordAdjust();
@ -1136,7 +1136,7 @@ void QX11PaintEngine::updateRenderHints(QPainter::RenderHints hints)
d->render_hints = hints; d->render_hints = hints;
#if !defined(QT_NO_XRENDER) #if !defined(QT_NO_XRENDER)
if (X11->use_xrender && d->picture) { if (qt_x11Data->use_xrender && d->picture) {
XRenderPictureAttributes attrs; XRenderPictureAttributes attrs;
attrs.poly_edge = (hints & QPainter::Antialiasing) ? PolyEdgeSmooth : PolyEdgeSharp; attrs.poly_edge = (hints & QPainter::Antialiasing) ? PolyEdgeSmooth : PolyEdgeSharp;
XRenderChangePicture(d->dpy, d->picture, CPPolyEdge, &attrs); XRenderChangePicture(d->dpy, d->picture, CPPolyEdge, &attrs);
@ -1253,7 +1253,7 @@ void QX11PaintEngine::updatePen(const QPen &pen)
vals.foreground = qGray(pen.color().rgb()) > 127 ? 0 : 1; vals.foreground = qGray(pen.color().rgb()) > 127 ? 0 : 1;
vals.background = qGray(QColor(Qt::transparent).rgb()) > 127 ? 0 : 1; vals.background = qGray(QColor(Qt::transparent).rgb()) > 127 ? 0 : 1;
} else if (d->pdev->devType() == QInternal::Pixmap && d->pdev_depth == 32 } else if (d->pdev->devType() == QInternal::Pixmap && d->pdev_depth == 32
&& X11->use_xrender) { && qt_x11Data->use_xrender) {
vals.foreground = pen.color().rgba(); vals.foreground = pen.color().rgba();
vals.background = QColor(Qt::transparent).rgba(); vals.background = QColor(Qt::transparent).rgba();
} else { } else {
@ -1313,7 +1313,7 @@ void QX11PaintEngine::updateBrush(const QBrush &brush, const QPointF &origin)
if (d->pdev_depth == 1) { if (d->pdev_depth == 1) {
vals.foreground = qGray(d->cbrush.color().rgb()) > 127 ? 0 : 1; vals.foreground = qGray(d->cbrush.color().rgb()) > 127 ? 0 : 1;
vals.background = qGray(QColor(Qt::transparent).rgb()) > 127 ? 0 : 1; vals.background = qGray(QColor(Qt::transparent).rgb()) > 127 ? 0 : 1;
} else if (X11->use_xrender && d->pdev->devType() == QInternal::Pixmap } else if (qt_x11Data->use_xrender && d->pdev->devType() == QInternal::Pixmap
&& d->pdev_depth == 32) { && d->pdev_depth == 32) {
vals.foreground = d->cbrush.color().rgba(); vals.foreground = d->cbrush.color().rgba();
vals.background = QColor(Qt::transparent).rgba(); vals.background = QColor(Qt::transparent).rgba();
@ -1322,7 +1322,7 @@ void QX11PaintEngine::updateBrush(const QBrush &brush, const QPointF &origin)
vals.foreground = cmap.pixel(d->cbrush.color()); vals.foreground = cmap.pixel(d->cbrush.color());
vals.background = cmap.pixel(QColor(Qt::transparent)); vals.background = cmap.pixel(QColor(Qt::transparent));
if (!X11->use_xrender && d->has_brush && !d->has_pattern && !brush.isOpaque()) { if (!qt_x11Data->use_xrender && d->has_brush && !d->has_pattern && !brush.isOpaque()) {
QPixmap pattern = qt_patternForAlpha(brush.color().alpha(), d->scrn); QPixmap pattern = qt_patternForAlpha(brush.color().alpha(), d->scrn);
mask |= GCStipple; mask |= GCStipple;
vals.stipple = pattern.handle(); vals.stipple = pattern.handle();
@ -1338,7 +1338,7 @@ void QX11PaintEngine::updateBrush(const QBrush &brush, const QPointF &origin)
if (bs == Qt::TexturePattern) { if (bs == Qt::TexturePattern) {
d->brush_pm = qt_toX11Pixmap(d->cbrush.texture()); d->brush_pm = qt_toX11Pixmap(d->cbrush.texture());
#if !defined(QT_NO_XRENDER) #if !defined(QT_NO_XRENDER)
if (X11->use_xrender) { if (qt_x11Data->use_xrender) {
XRenderPictureAttributes attrs; XRenderPictureAttributes attrs;
attrs.repeat = true; attrs.repeat = true;
XRenderChangePicture(d->dpy, d->brush_pm.x11PictureHandle(), CPRepeat, &attrs); XRenderChangePicture(d->dpy, d->brush_pm.x11PictureHandle(), CPRepeat, &attrs);
@ -1356,13 +1356,13 @@ void QX11PaintEngine::updateBrush(const QBrush &brush, const QPointF &origin)
vals.stipple = d->brush_pm.handle(); vals.stipple = d->brush_pm.handle();
s = FillStippled; s = FillStippled;
#if !defined(QT_NO_XRENDER) #if !defined(QT_NO_XRENDER)
if (X11->use_xrender) { if (qt_x11Data->use_xrender) {
d->bitmap_texture = QPixmap(d->brush_pm.size()); d->bitmap_texture = QPixmap(d->brush_pm.size());
d->bitmap_texture.fill(Qt::transparent); d->bitmap_texture.fill(Qt::transparent);
d->bitmap_texture = qt_toX11Pixmap(d->bitmap_texture); d->bitmap_texture = qt_toX11Pixmap(d->bitmap_texture);
d->bitmap_texture.x11SetScreen(d->scrn); d->bitmap_texture.x11SetScreen(d->scrn);
::Picture src = X11->getSolidFill(d->scrn, d->cbrush.color()); ::Picture src = qt_x11Data->getSolidFill(d->scrn, d->cbrush.color());
XRenderComposite(d->dpy, PictOpSrc, src, d->brush_pm.x11PictureHandle(), XRenderComposite(d->dpy, PictOpSrc, src, d->brush_pm.x11PictureHandle(),
d->bitmap_texture.x11PictureHandle(), d->bitmap_texture.x11PictureHandle(),
0, 0, d->brush_pm.width(), d->brush_pm.height(), 0, 0, d->brush_pm.width(), d->brush_pm.height(),
@ -1399,7 +1399,7 @@ void QX11PaintEngine::updateBrush(const QBrush &brush, const QPointF &origin)
} }
#if !defined(QT_NO_XRENDER) #if !defined(QT_NO_XRENDER)
else if (d->has_alpha_brush) { else if (d->has_alpha_brush) {
d->current_brush = X11->getSolidFill(d->scrn, d->cbrush.color()); d->current_brush = qt_x11Data->getSolidFill(d->scrn, d->cbrush.color());
} }
#endif #endif
@ -1484,7 +1484,7 @@ void QX11PaintEnginePrivate::fillPolygon_translated(const QPointF *polygonPoints
QPointF offset(matrix.dx(), matrix.dy()); QPointF offset(matrix.dx(), matrix.dy());
qreal offs = adjust_coords ? aliasedCoordinateDelta : 0.0; qreal offs = adjust_coords ? aliasedCoordinateDelta : 0.0;
if (!X11->use_xrender || !(render_hints & QPainter::Antialiasing)) if (!qt_x11Data->use_xrender || !(render_hints & QPainter::Antialiasing))
offset += QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta); offset += QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta);
for (int i = 0; i < pointCount; ++i) { for (int i = 0; i < pointCount; ++i) {
@ -1546,7 +1546,7 @@ void QX11PaintEnginePrivate::fillPolygon_dev(const QPointF *polygonPoints, int p
if (current_brush) if (current_brush)
src = current_brush; src = current_brush;
else else
src = X11->getSolidFill(scrn, fill.color()); src = qt_x11Data->getSolidFill(scrn, fill.color());
#endif #endif
} else { } else {
fill = QBrush(cpen.brush()); fill = QBrush(cpen.brush());
@ -1560,7 +1560,7 @@ void QX11PaintEnginePrivate::fillPolygon_dev(const QPointF *polygonPoints, int p
else if (has_fill_pattern) else if (has_fill_pattern)
src = getPatternFill(scrn, fill); src = getPatternFill(scrn, fill);
else else
src = X11->getSolidFill(scrn, fill.color()); src = qt_x11Data->getSolidFill(scrn, fill.color());
#endif #endif
} }
@ -1576,7 +1576,7 @@ void QX11PaintEnginePrivate::fillPolygon_dev(const QPointF *polygonPoints, int p
bool antialias = render_hints & QPainter::Antialiasing; bool antialias = render_hints & QPainter::Antialiasing;
if (X11->use_xrender if (qt_x11Data->use_xrender
&& picture && picture
&& !has_fill_pattern && !has_fill_pattern
&& (clippedCount > 0) && (clippedCount > 0)
@ -1727,7 +1727,7 @@ void QX11PaintEnginePrivate::fillPath(const QPainterPath &path, QX11PaintEngineP
for (int j = 0; j < polys.at(i).size(); ++j) { for (int j = 0; j < polys.at(i).size(); ++j) {
translated_points[j] = polys.at(i).at(j); translated_points[j] = polys.at(i).at(j);
if (!X11->use_xrender || !(render_hints & QPainter::Antialiasing)) { if (!qt_x11Data->use_xrender || !(render_hints & QPainter::Antialiasing)) {
translated_points[j].rx() = qRound(translated_points[j].rx() + aliasedCoordinateDelta) + offs; translated_points[j].rx() = qRound(translated_points[j].rx() + aliasedCoordinateDelta) + offs;
translated_points[j].ry() = qRound(translated_points[j].ry() + aliasedCoordinateDelta) + offs; translated_points[j].ry() = qRound(translated_points[j].ry() + aliasedCoordinateDelta) + offs;
} }
@ -1747,7 +1747,7 @@ void QX11PaintEngine::drawPath(const QPainterPath &path)
if (d->has_brush) if (d->has_brush)
d->fillPath(path, QX11PaintEnginePrivate::BrushGC, true); d->fillPath(path, QX11PaintEnginePrivate::BrushGC, true);
if (d->has_pen if (d->has_pen
&& ((X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing))) && ((qt_x11Data->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
|| (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate
&& !d->has_non_scaling_xform) && !d->has_non_scaling_xform)
|| (d->cpen.style() == Qt::CustomDashLine))) { || (d->cpen.style() == Qt::CustomDashLine))) {
@ -1808,7 +1808,7 @@ Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const Q
const int h = rect.height(); const int h = rect.height();
QImage im; QImage im;
int image_byte_order = ImageByteOrder(X11->display); int image_byte_order = ImageByteOrder(qt_x11Data->display);
if ((QSysInfo::ByteOrder == QSysInfo::BigEndian && ((image_byte_order == LSBFirst) || bgr_layout)) if ((QSysInfo::ByteOrder == QSysInfo::BigEndian && ((image_byte_order == LSBFirst) || bgr_layout))
|| (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)
|| (image_byte_order == LSBFirst && bgr_layout)) || (image_byte_order == LSBFirst && bgr_layout))
@ -1891,9 +1891,9 @@ void QX11PaintEngine::drawPixmap(const QRectF &r, const QPixmap &px, const QRect
return; return;
if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen()) if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen())
|| (pixmap.x11Info().screen() != DefaultScreen(X11->display))) { || (pixmap.x11Info().screen() != DefaultScreen(qt_x11Data->display))) {
QPixmap* p = const_cast<QPixmap *>(&pixmap); QPixmap* p = const_cast<QPixmap *>(&pixmap);
p->x11SetScreen(d->xinfo ? d->xinfo->screen() : DefaultScreen(X11->display)); p->x11SetScreen(d->xinfo ? d->xinfo->screen() : DefaultScreen(qt_x11Data->display));
} }
QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen()); QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen());
@ -2092,15 +2092,15 @@ void QX11PaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, co
Q_D(QX11PaintEngine); Q_D(QX11PaintEngine);
if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen()) if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen())
|| (pixmap.x11Info().screen() != DefaultScreen(X11->display))) { || (pixmap.x11Info().screen() != DefaultScreen(qt_x11Data->display))) {
QPixmap* p = const_cast<QPixmap *>(&pixmap); QPixmap* p = const_cast<QPixmap *>(&pixmap);
p->x11SetScreen(d->xinfo ? d->xinfo->screen() : DefaultScreen(X11->display)); p->x11SetScreen(d->xinfo ? d->xinfo->screen() : DefaultScreen(qt_x11Data->display));
} }
QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen()); QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen());
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (X11->use_xrender && d->picture && pixmap.x11PictureHandle()) { if (qt_x11Data->use_xrender && d->picture && pixmap.x11PictureHandle()) {
#if 0 #if 0
// ### Qt 5: enable this // ### Qt 5: enable this
XRenderPictureAttributes attrs; XRenderPictureAttributes attrs;
@ -2335,7 +2335,7 @@ void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti)
return; return;
} }
const bool xrenderPath = (X11->use_xrender const bool xrenderPath = (qt_x11Data->use_xrender
&& !(d->pdev->devType() == QInternal::Pixmap && !(d->pdev->devType() == QInternal::Pixmap
&& static_cast<const QPixmap *>(d->pdev)->data->pixelType() == QPixmapData::BitmapType)); && static_cast<const QPixmap *>(d->pdev)->data->pixelType() == QPixmapData::BitmapType));
@ -2365,10 +2365,10 @@ void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti)
if (xrenderPath) { if (xrenderPath) {
GlyphSet glyphSet = set->id; GlyphSet glyphSet = set->id;
const QColor &pen = d->cpen.color(); const QColor &pen = d->cpen.color();
::Picture src = X11->getSolidFill(d->scrn, pen); ::Picture src = qt_x11Data->getSolidFill(d->scrn, pen);
XRenderPictFormat *maskFormat = 0; XRenderPictFormat *maskFormat = 0;
if (ft->xglyph_format != PictStandardA1) if (ft->xglyph_format != PictStandardA1)
maskFormat = XRenderFindStandardFormat(X11->display, ft->xglyph_format); maskFormat = XRenderFindStandardFormat(qt_x11Data->display, ft->xglyph_format);
enum { t_min = SHRT_MIN, t_max = SHRT_MAX }; enum { t_min = SHRT_MIN, t_max = SHRT_MAX };
@ -2411,7 +2411,7 @@ void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti)
xp = positions[i].x; xp = positions[i].x;
yp = positions[i].y; yp = positions[i].y;
XRenderCompositeText32(X11->display, PictOpOver, src, d->picture, XRenderCompositeText32(qt_x11Data->display, PictOpOver, src, d->picture,
maskFormat, 0, 0, 0, 0, maskFormat, 0, 0, 0, 0,
&elt, 1); &elt, 1);
elt.chars = &glyphs[i]; elt.chars = &glyphs[i];
@ -2420,7 +2420,7 @@ void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti)
elt.yOff = qRound(yp + offs); elt.yOff = qRound(yp + offs);
} }
} }
XRenderCompositeText32(X11->display, PictOpOver, src, d->picture, XRenderCompositeText32(qt_x11Data->display, PictOpOver, src, d->picture,
maskFormat, 0, 0, 0, 0, maskFormat, 0, 0, 0, 0,
&elt, 1); &elt, 1);

View file

@ -598,7 +598,7 @@ void QPrinter::init(PrinterMode mode)
#if !defined(Q_WS_X11) #if !defined(Q_WS_X11)
if (!qApp) { if (!qApp) {
#else #else
if (!qApp || !X11) { if (!qApp || !qt_x11Data) {
#endif #endif
qFatal("QPrinter: Must construct a QApplication before a QPaintDevice"); qFatal("QPrinter: Must construct a QApplication before a QPaintDevice");
return; return;
@ -817,7 +817,7 @@ bool QPrinter::isValid() const
{ {
Q_D(const QPrinter); Q_D(const QPrinter);
#if defined(Q_WS_X11) #if defined(Q_WS_X11)
if (!qApp || !X11) { if (!qApp || !qt_x11Data) {
return false; return false;
} }
#endif #endif

View file

@ -78,9 +78,9 @@ QRasterWindowSurface::QRasterWindowSurface(QWidget *window, bool setDefaultSurfa
: QWindowSurface(window, setDefaultSurface), d_ptr(new QRasterWindowSurfacePrivate) : QWindowSurface(window, setDefaultSurface), d_ptr(new QRasterWindowSurfacePrivate)
{ {
#ifdef Q_WS_X11 #ifdef Q_WS_X11
d_ptr->gc = XCreateGC(X11->display, window->handle(), 0, 0); d_ptr->gc = XCreateGC(qt_x11Data->display, window->handle(), 0, 0);
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
d_ptr->translucentBackground = X11->use_xrender d_ptr->translucentBackground = qt_x11Data->use_xrender
&& window->x11Info().depth() == 32; && window->x11Info().depth() == 32;
#endif #endif
#ifndef QT_NO_XSHM #ifndef QT_NO_XSHM
@ -95,7 +95,7 @@ QRasterWindowSurface::QRasterWindowSurface(QWidget *window, bool setDefaultSurfa
QRasterWindowSurface::~QRasterWindowSurface() QRasterWindowSurface::~QRasterWindowSurface()
{ {
#ifdef Q_WS_X11 #ifdef Q_WS_X11
XFreeGC(X11->display, d_ptr->gc); XFreeGC(qt_x11Data->display, d_ptr->gc);
#endif #endif
if (d_ptr->image) if (d_ptr->image)
delete d_ptr->image; delete d_ptr->image;
@ -111,7 +111,7 @@ void QRasterWindowSurface::syncX()
{ {
// delay writing to the backbuffer until we know for sure X is done reading from it // delay writing to the backbuffer until we know for sure X is done reading from it
if (d_ptr->needsSync) { if (d_ptr->needsSync) {
XSync(X11->display, false); XSync(qt_x11Data->display, false);
d_ptr->needsSync = false; d_ptr->needsSync = false;
} }
} }
@ -151,8 +151,8 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft(); QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
if (widget->window() != window()) { if (widget->window() != window()) {
XFreeGC(X11->display, d_ptr->gc); XFreeGC(qt_x11Data->display, d_ptr->gc);
d_ptr->gc = XCreateGC(X11->display, widget->handle(), 0, 0); d_ptr->gc = XCreateGC(qt_x11Data->display, widget->handle(), 0, 0);
} }
QRegion wrgn(rgn); QRegion wrgn(rgn);
@ -162,7 +162,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
if (wrgn.rectCount() != 1) { if (wrgn.rectCount() != 1) {
int num; int num;
XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num); XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num);
XSetClipRectangles(X11->display, d_ptr->gc, 0, 0, rects, num, YXBanded); XSetClipRectangles(qt_x11Data->display, d_ptr->gc, 0, 0, rects, num, YXBanded);
} }
QPoint widgetOffset = offset + wOffset; QPoint widgetOffset = offset + wOffset;
@ -173,7 +173,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
int depth = widget->x11Info().depth(); int depth = widget->x11Info().depth();
const QImage *src = d->image; const QImage *src = d->image;
if (src->format() != QImage::Format_RGB32 || (depth != 24 && depth != 32) || X11->bppForDepth.value(depth) != 32) { if (src->format() != QImage::Format_RGB32 || (depth != 24 && depth != 32) || qt_x11Data->bppForDepth.value(depth) != 32) {
Q_ASSERT(src->depth() >= 16); Q_ASSERT(src->depth() >= 16);
const QImage sub_src(src->scanLine(br.y()) + br.x() * (uint(src->depth()) / 8), const QImage sub_src(src->scanLine(br.y()) + br.x() * (uint(src->depth()) / 8),
br.width(), br.height(), src->bytesPerLine(), src->format()); br.width(), br.height(), src->bytesPerLine(), src->format());
@ -181,15 +181,15 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
data->xinfo = widget->x11Info(); data->xinfo = widget->x11Info();
data->fromImage(sub_src, Qt::NoOpaqueDetection); data->fromImage(sub_src, Qt::NoOpaqueDetection);
QPixmap pm = QPixmap(data); QPixmap pm = QPixmap(data);
XCopyArea(X11->display, pm.handle(), widget->handle(), d_ptr->gc, 0 , 0 , br.width(), br.height(), wpos.x(), wpos.y()); XCopyArea(qt_x11Data->display, pm.handle(), widget->handle(), d_ptr->gc, 0 , 0 , br.width(), br.height(), wpos.x(), wpos.y());
} else { } else {
// qpaintengine_x11.cpp // qpaintengine_x11.cpp
extern void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage *image, Drawable hd, GC gc, Display *dpy, Visual *visual, int depth); extern void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage *image, Drawable hd, GC gc, Display *dpy, Visual *visual, int depth);
qt_x11_drawImage(br, wpos, src, widget->handle(), d_ptr->gc, X11->display, (Visual *)widget->x11Info().visual(), depth); qt_x11_drawImage(br, wpos, src, widget->handle(), d_ptr->gc, qt_x11Data->display, (Visual *)widget->x11Info().visual(), depth);
} }
if (wrgn.rectCount() != 1) if (wrgn.rectCount() != 1)
XSetClipMask(X11->display, d_ptr->gc, XNone); XSetClipMask(qt_x11Data->display, d_ptr->gc, XNone);
#endif // Q_WS_X11 #endif // Q_WS_X11
} }

View file

@ -68,7 +68,7 @@ QX11WindowSurface::QX11WindowSurface(QWidget *widget)
{ {
d_ptr->widget = widget; d_ptr->widget = widget;
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
d_ptr->translucentBackground = X11->use_xrender d_ptr->translucentBackground = qt_x11Data->use_xrender
&& widget->x11Info().depth() == 32; && widget->x11Info().depth() == 32;
#endif #endif
} }
@ -78,7 +78,7 @@ QX11WindowSurface::~QX11WindowSurface()
{ {
delete d_ptr; delete d_ptr;
if (gc) { if (gc) {
XFreeGC(X11->display, gc); XFreeGC(qt_x11Data->display, gc);
gc = 0; gc = 0;
} }
} }
@ -96,13 +96,13 @@ void QX11WindowSurface::beginPaint(const QRegion &rgn)
if (d_ptr->translucentBackground) { if (d_ptr->translucentBackground) {
if (d_ptr->device.depth() != 32) if (d_ptr->device.depth() != 32)
static_cast<QX11PixmapData *>(d_ptr->device.data_ptr().data())->convertToARGB32(); static_cast<QX11PixmapData *>(d_ptr->device.data_ptr().data())->convertToARGB32();
::Picture src = X11->getSolidFill(d_ptr->device.x11Info().screen(), Qt::transparent); ::Picture src = qt_x11Data->getSolidFill(d_ptr->device.x11Info().screen(), Qt::transparent);
::Picture dst = d_ptr->device.x11PictureHandle(); ::Picture dst = d_ptr->device.x11PictureHandle();
const QVector<QRect> rects = rgn.rects(); const QVector<QRect> rects = rgn.rects();
const int w = d_ptr->device.width(); const int w = d_ptr->device.width();
const int h = d_ptr->device.height(); const int h = d_ptr->device.height();
for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it)
XRenderComposite(X11->display, PictOpSrc, src, 0, dst, XRenderComposite(qt_x11Data->display, PictOpSrc, src, 0, dst,
0, 0, w, h, it->x(), it->y(), 0, 0, w, h, it->x(), it->y(),
it->width(), it->height()); it->width(), it->height());
} }
@ -129,11 +129,11 @@ void QX11WindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint
// for (int i = 0; i < num; ++i) // for (int i = 0; i < num; ++i)
// qDebug() << ' ' << i << rects[i].x << rects[i].x << rects[i].y << rects[i].width << rects[i].height; // qDebug() << ' ' << i << rects[i].x << rects[i].x << rects[i].y << rects[i].width << rects[i].height;
if (num != 1) if (num != 1)
XSetClipRectangles(X11->display, gc, 0, 0, rects, num, YXBanded); XSetClipRectangles(qt_x11Data->display, gc, 0, 0, rects, num, YXBanded);
XCopyArea(X11->display, d_ptr->device.handle(), widget->handle(), gc, XCopyArea(qt_x11Data->display, d_ptr->device.handle(), widget->handle(), gc,
br.x() + offset.x(), br.y() + offset.y(), br.width(), br.height(), wbr.x(), wbr.y()); br.x() + offset.x(), br.y() + offset.y(), br.width(), br.height(), wbr.x(), wbr.y());
if (num != 1) if (num != 1)
XSetClipMask(X11->display, gc, XNone); XSetClipMask(qt_x11Data->display, gc, XNone);
} }
void QX11WindowSurface::setGeometry(const QRect &rect) void QX11WindowSurface::setGeometry(const QRect &rect)
@ -174,12 +174,12 @@ void QX11WindowSurface::setGeometry(const QRect &rect)
int num; int num;
XRectangle *rects = (XRectangle *)qt_getClipRects(staticRegion, num); XRectangle *rects = (XRectangle *)qt_getClipRects(staticRegion, num);
GC tmpGc = XCreateGC(X11->display, oldData->hd, 0, 0); GC tmpGc = XCreateGC(qt_x11Data->display, oldData->hd, 0, 0);
XSetClipRectangles(X11->display, tmpGc, 0, 0, rects, num, YXBanded); XSetClipRectangles(qt_x11Data->display, tmpGc, 0, 0, rects, num, YXBanded);
XCopyArea(X11->display, oldData->hd, newData->hd, tmpGc, XCopyArea(qt_x11Data->display, oldData->hd, newData->hd, tmpGc,
dx, dy, qMin(boundingRect.width(), size.width()), dx, dy, qMin(boundingRect.width(), size.width()),
qMin(boundingRect.height(), size.height()), dx, dy); qMin(boundingRect.height(), size.height()), dx, dy);
XFreeGC(X11->display, tmpGc); XFreeGC(qt_x11Data->display, tmpGc);
newData->flags &= ~QX11PixmapData::Uninitialized; newData->flags &= ~QX11PixmapData::Uninitialized;
d_ptr->device = QPixmap(newData); d_ptr->device = QPixmap(newData);
@ -189,12 +189,12 @@ void QX11WindowSurface::setGeometry(const QRect &rect)
} }
if (gc) { if (gc) {
XFreeGC(X11->display, gc); XFreeGC(qt_x11Data->display, gc);
gc = 0; gc = 0;
} }
if (!d_ptr->device.isNull()) { if (!d_ptr->device.isNull()) {
gc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0); gc = XCreateGC(qt_x11Data->display, d_ptr->device.handle(), 0, 0);
XSetGraphicsExposures(X11->display, gc, False); XSetGraphicsExposures(qt_x11Data->display, gc, False);
} }
} }
@ -205,11 +205,11 @@ bool QX11WindowSurface::scroll(const QRegion &area, int dx, int dy)
if (d_ptr->device.isNull()) if (d_ptr->device.isNull())
return false; return false;
GC gc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0); GC gc = XCreateGC(qt_x11Data->display, d_ptr->device.handle(), 0, 0);
XCopyArea(X11->display, d_ptr->device.handle(), d_ptr->device.handle(), gc, XCopyArea(qt_x11Data->display, d_ptr->device.handle(), d_ptr->device.handle(), gc,
rect.x(), rect.y(), rect.width(), rect.height(), rect.x(), rect.y(), rect.width(), rect.height(),
rect.x()+dx, rect.y()+dy); rect.x()+dx, rect.y()+dy);
XFreeGC(X11->display, gc); XFreeGC(qt_x11Data->display, gc);
return true; return true;
} }
@ -238,14 +238,14 @@ QPixmap QX11WindowSurface::grabWidget(const QWidget *widget,
QPixmap::x11SetDefaultScreen(widget->x11Info().screen()); QPixmap::x11SetDefaultScreen(widget->x11Info().screen());
QPixmap px(srcRect.width(), srcRect.height()); QPixmap px(srcRect.width(), srcRect.height());
GC tmpGc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0); GC tmpGc = XCreateGC(qt_x11Data->display, d_ptr->device.handle(), 0, 0);
// Copy srcRect from the backing store to the new pixmap // Copy srcRect from the backing store to the new pixmap
XSetGraphicsExposures(X11->display, tmpGc, False); XSetGraphicsExposures(qt_x11Data->display, tmpGc, False);
XCopyArea(X11->display, d_ptr->device.handle(), px.handle(), tmpGc, XCopyArea(qt_x11Data->display, d_ptr->device.handle(), px.handle(), tmpGc,
srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height(), 0, 0); srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height(), 0, 0);
XFreeGC(X11->display, tmpGc); XFreeGC(qt_x11Data->display, tmpGc);
return px; return px;
} }

View file

@ -4866,9 +4866,9 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
case SH_DialogButtonLayout: case SH_DialogButtonLayout:
ret = QDialogButtonBox::WinLayout; ret = QDialogButtonBox::WinLayout;
#ifdef Q_WS_X11 #ifdef Q_WS_X11
if (X11->desktopEnvironment == DE_KDE) if (qt_x11Data->desktopEnvironment == DE_KDE)
ret = QDialogButtonBox::KdeLayout; ret = QDialogButtonBox::KdeLayout;
else if (X11->desktopEnvironment == DE_GNOME) else if (qt_x11Data->desktopEnvironment == DE_GNOME)
ret = QDialogButtonBox::GnomeLayout; ret = QDialogButtonBox::GnomeLayout;
#endif #endif
break; break;

View file

@ -1801,7 +1801,7 @@ static void initFontSubst()
if (!fontSubst->isEmpty()) if (!fontSubst->isEmpty())
return; return;
#if defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG) #if defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)
if (X11->has_fontconfig) if (qt_x11Data->has_fontconfig)
return; return;
#endif #endif

View file

@ -755,7 +755,7 @@ QFontDef qt_FcPatternToQFontDef(FcPattern *pattern, const QFontDef &request)
double dpi; double dpi;
if (FcPatternGetDouble(pattern, FC_DPI, 0, &dpi) != FcResultMatch) { if (FcPatternGetDouble(pattern, FC_DPI, 0, &dpi) != FcResultMatch) {
if (X11->display) if (qt_x11Data->display)
dpi = QX11Info::appDpiY(); dpi = QX11Info::appDpiY();
else else
dpi = qt_defaultDpiY(); dpi = qt_defaultDpiY();
@ -1003,7 +1003,7 @@ static void loadFontConfig()
{ {
Q_ASSERT_X(X11, "QFontDatabase", Q_ASSERT_X(X11, "QFontDatabase",
"A QApplication object needs to be constructed before FontConfig is used."); "A QApplication object needs to be constructed before FontConfig is used.");
if (!X11->has_fontconfig) if (!qt_x11Data->has_fontconfig)
return; return;
Q_ASSERT_X(int(QUnicodeTables::ScriptCount) == SpecialLanguageCount, Q_ASSERT_X(int(QUnicodeTables::ScriptCount) == SpecialLanguageCount,
@ -1228,7 +1228,7 @@ static void initializeDb();
static void load(const QString &family = QString(), int script = -1, bool forceXLFD = false) static void load(const QString &family = QString(), int script = -1, bool forceXLFD = false)
{ {
if (X11->has_fontconfig && !forceXLFD) { if (qt_x11Data->has_fontconfig && !forceXLFD) {
initializeDb(); initializeDb();
return; return;
} }
@ -1384,7 +1384,7 @@ static void initializeDb()
#ifdef QFONTDATABASE_DEBUG #ifdef QFONTDATABASE_DEBUG
#ifndef QT_NO_FONTCONFIG #ifndef QT_NO_FONTCONFIG
if (!X11->has_fontconfig) if (!qt_x11Data->has_fontconfig)
#endif #endif
// load everything at startup in debug mode. // load everything at startup in debug mode.
loadXlfds(0, -1); loadXlfds(0, -1);
@ -1468,7 +1468,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD
FcPatternDel(pattern, FC_PIXEL_SIZE); FcPatternDel(pattern, FC_PIXEL_SIZE);
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value); FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value);
if (X11->display && QX11Info::appDepth(screen) <= 8) { if (qt_x11Data->display && QX11Info::appDepth(screen) <= 8) {
FcPatternDel(pattern, FC_ANTIALIAS); FcPatternDel(pattern, FC_ANTIALIAS);
// can't do antialiasing on 8bpp // can't do antialiasing on 8bpp
FcPatternAddBool(pattern, FC_ANTIALIAS, false); FcPatternAddBool(pattern, FC_ANTIALIAS, false);
@ -1530,7 +1530,7 @@ static bool preferScalable(const QFontDef &request)
static FcPattern *getFcPattern(const QFontPrivate *fp, int script, const QFontDef &request) static FcPattern *getFcPattern(const QFontPrivate *fp, int script, const QFontDef &request)
{ {
if (!X11->has_fontconfig) if (!qt_x11Data->has_fontconfig)
return 0; return 0;
FcPattern *pattern = FcPatternCreate(); FcPattern *pattern = FcPatternCreate();
@ -1966,7 +1966,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
if (mainThread) if (mainThread)
fe = loadRaw(d, req); fe = loadRaw(d, req);
#ifndef QT_NO_FONTCONFIG #ifndef QT_NO_FONTCONFIG
} else if (X11->has_fontconfig) { } else if (qt_x11Data->has_fontconfig) {
fe = loadFc(d, script, req); fe = loadFc(d, script, req);
#endif #endif
} else if (mainThread && qt_is_gui_used) { } else if (mainThread && qt_is_gui_used) {
@ -2001,7 +2001,7 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
#if defined(QT_NO_FONTCONFIG) #if defined(QT_NO_FONTCONFIG)
return; return;
#else #else
if (!X11->has_fontconfig) if (!qt_x11Data->has_fontconfig)
return; return;
FcConfig *config = FcConfigGetCurrent(); FcConfig *config = FcConfigGetCurrent();
@ -2118,7 +2118,7 @@ bool QFontDatabase::supportsThreadedFontRendering()
#if defined(QT_NO_FONTCONFIG) #if defined(QT_NO_FONTCONFIG)
return false; return false;
#else #else
return X11->has_fontconfig; return qt_x11Data->has_fontconfig;
#endif #endif
} }

View file

@ -147,7 +147,7 @@ static QStringList fontPath()
int npaths; int npaths;
char** font_path; char** font_path;
font_path = XGetFontPath(X11->display, &npaths); font_path = XGetFontPath(qt_x11Data->display, &npaths);
bool xfsconfig_read = false; bool xfsconfig_read = false;
for (int i=0; i<npaths; i++) { for (int i=0; i<npaths; i++) {
// If we're using xfs, append font paths from /etc/X11/fs/config // If we're using xfs, append font paths from /etc/X11/fs/config
@ -973,7 +973,7 @@ QFontEngineX11FT::QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int s
{ {
// FcPatternPrint(pattern); // FcPatternPrint(pattern);
bool antialias = X11->fc_antialias; bool antialias = qt_x11Data->fc_antialias;
QByteArray file_name; QByteArray file_name;
int face_index; int face_index;
qt_x11ft_convert_pattern(pattern, &file_name, &face_index, &antialias); qt_x11ft_convert_pattern(pattern, &file_name, &face_index, &antialias);
@ -985,7 +985,7 @@ QFontEngineX11FT::QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int s
subpixelType = Subpixel_None; subpixelType = Subpixel_None;
if (antialias) { if (antialias) {
int subpixel = X11->display ? X11->screens[screen].subpixel : FC_RGBA_UNKNOWN; int subpixel = qt_x11Data->display ? qt_x11Data->screens[screen].subpixel : FC_RGBA_UNKNOWN;
if (subpixel == FC_RGBA_UNKNOWN) if (subpixel == FC_RGBA_UNKNOWN)
(void) FcPatternGetInteger(pattern, FC_RGBA, 0, &subpixel); (void) FcPatternGetInteger(pattern, FC_RGBA, 0, &subpixel);
if (!antialias || subpixel == FC_RGBA_UNKNOWN) if (!antialias || subpixel == FC_RGBA_UNKNOWN)
@ -1020,11 +1020,11 @@ QFontEngineX11FT::QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int s
int hint_style = 0; int hint_style = 0;
// Try to use Xft.hintstyle from XDefaults first if running in GNOME, to match // Try to use Xft.hintstyle from XDefaults first if running in GNOME, to match
// the behavior of cairo // the behavior of cairo
if (X11->fc_hint_style > -1 && X11->desktopEnvironment == DE_GNOME) if (qt_x11Data->fc_hint_style > -1 && qt_x11Data->desktopEnvironment == DE_GNOME)
hint_style = X11->fc_hint_style; hint_style = qt_x11Data->fc_hint_style;
else if (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch else if (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch
&& X11->fc_hint_style > -1) && qt_x11Data->fc_hint_style > -1)
hint_style = X11->fc_hint_style; hint_style = qt_x11Data->fc_hint_style;
switch (hint_style) { switch (hint_style) {
case FC_HINT_NONE: case FC_HINT_NONE:
@ -1092,7 +1092,7 @@ QFontEngineX11FT::QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int s
GlyphFormat defaultFormat = Format_None; GlyphFormat defaultFormat = Format_None;
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (X11->use_xrender) { if (qt_x11Data->use_xrender) {
int format = PictStandardA8; int format = PictStandardA8;
if (!antialias) if (!antialias)
format = PictStandardA1; format = PictStandardA1;
@ -1130,9 +1130,9 @@ QFontEngineX11FT::~QFontEngineX11FT()
unsigned long QFontEngineX11FT::allocateServerGlyphSet() unsigned long QFontEngineX11FT::allocateServerGlyphSet()
{ {
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (!canUploadGlyphsToServer || !X11->use_xrender) if (!canUploadGlyphsToServer || !qt_x11Data->use_xrender)
return 0; return 0;
return XRenderCreateGlyphSet(X11->display, XRenderFindStandardFormat(X11->display, xglyph_format)); return XRenderCreateGlyphSet(qt_x11Data->display, XRenderFindStandardFormat(qt_x11Data->display, xglyph_format));
#else #else
return 0; return 0;
#endif #endif
@ -1143,7 +1143,7 @@ void QFontEngineX11FT::freeServerGlyphSet(unsigned long id)
#ifndef QT_NO_XRENDER #ifndef QT_NO_XRENDER
if (!id) if (!id)
return; return;
XRenderFreeGlyphSet(X11->display, id); XRenderFreeGlyphSet(qt_x11Data->display, id);
#endif #endif
} }
@ -1156,7 +1156,7 @@ bool QFontEngineX11FT::uploadGlyphToServer(QGlyphSet *set, uint glyphid, Glyph *
/* /*
* swap bit order around; FreeType is always MSBFirst * swap bit order around; FreeType is always MSBFirst
*/ */
if (BitmapBitOrder(X11->display) != MSBFirst) { if (BitmapBitOrder(qt_x11Data->display) != MSBFirst) {
unsigned char *line = g->data; unsigned char *line = g->data;
int i = glyphDataSize; int i = glyphDataSize;
while (i--) { while (i--) {
@ -1171,7 +1171,7 @@ bool QFontEngineX11FT::uploadGlyphToServer(QGlyphSet *set, uint glyphid, Glyph *
} }
::Glyph xglyph = glyphid; ::Glyph xglyph = glyphid;
XRenderAddGlyphs (X11->display, set->id, &xglyph, info, 1, (const char *)g->data, glyphDataSize); XRenderAddGlyphs (qt_x11Data->display, set->id, &xglyph, info, 1, (const char *)g->data, glyphDataSize);
delete [] g->data; delete [] g->data;
g->data = 0; g->data = 0;
g->format = Format_None; g->format = Format_None;

View file

@ -212,7 +212,7 @@ void QComboBoxPrivate::_q_modelDestroyed()
QRect QComboBoxPrivate::popupGeometry(int screen) const QRect QComboBoxPrivate::popupGeometry(int screen) const
{ {
#if defined Q_WS_X11 #if defined Q_WS_X11
if (X11->desktopEnvironment == DE_KDE) if (qt_x11Data->desktopEnvironment == DE_KDE)
return QApplication::desktop()->screenGeometry(screen); return QApplication::desktop()->screenGeometry(screen);
#endif #endif
return QApplication::desktop()->availableGeometry(screen); return QApplication::desktop()->availableGeometry(screen);

View file

@ -165,7 +165,7 @@ int QMenuPrivate::scrollerHeight() const
QRect QMenuPrivate::popupGeometry(const QWidget *widget) const QRect QMenuPrivate::popupGeometry(const QWidget *widget) const
{ {
#if defined Q_WS_X11 #if defined Q_WS_X11
if (X11->desktopEnvironment == DE_KDE) if (qt_x11Data->desktopEnvironment == DE_KDE)
return QApplication::desktop()->screenGeometry(widget); return QApplication::desktop()->screenGeometry(widget);
#endif #endif
return QApplication::desktop()->availableGeometry(widget); return QApplication::desktop()->availableGeometry(widget);
@ -175,7 +175,7 @@ QRect QMenuPrivate::popupGeometry(const QWidget *widget) const
QRect QMenuPrivate::popupGeometry(int screen) const QRect QMenuPrivate::popupGeometry(int screen) const
{ {
#if defined Q_WS_X11 #if defined Q_WS_X11
if (X11->desktopEnvironment == DE_KDE) if (qt_x11Data->desktopEnvironment == DE_KDE)
return QApplication::desktop()->screenGeometry(screen); return QApplication::desktop()->screenGeometry(screen);
#endif #endif
return QApplication::desktop()->availableGeometry(screen); return QApplication::desktop()->availableGeometry(screen);

View file

@ -270,13 +270,13 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
#ifdef Q_WS_X11 #ifdef Q_WS_X11
// Use a native X11 sizegrip for "real" top-level windows if supported. // Use a native X11 sizegrip for "real" top-level windows if supported.
if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE)) if (tlw->isWindow() && qt_x11Data->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE))
&& !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint) && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
&& !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) { && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
XEvent xev; XEvent xev;
xev.xclient.type = ClientMessage; xev.xclient.type = ClientMessage;
xev.xclient.message_type = ATOM(_NET_WM_MOVERESIZE); xev.xclient.message_type = ATOM(_NET_WM_MOVERESIZE);
xev.xclient.display = X11->display; xev.xclient.display = qt_x11Data->display;
xev.xclient.window = tlw->winId(); xev.xclient.window = tlw->winId();
xev.xclient.format = 32; xev.xclient.format = 32;
xev.xclient.data.l[0] = e->globalPos().x(); xev.xclient.data.l[0] = e->globalPos().x();
@ -287,8 +287,8 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
xev.xclient.data.l[2] = d->atLeft() ? 0 : 2; // topleft/topright xev.xclient.data.l[2] = d->atLeft() ? 0 : 2; // topleft/topright
xev.xclient.data.l[3] = Button1; xev.xclient.data.l[3] = Button1;
xev.xclient.data.l[4] = 0; xev.xclient.data.l[4] = 0;
XUngrabPointer(X11->display, X11->time); XUngrabPointer(qt_x11Data->display, qt_x11Data->time);
XSendEvent(X11->display, QX11Info::appRootWindow(x11Info().screen()), False, XSendEvent(qt_x11Data->display, QX11Info::appRootWindow(x11Info().screen()), False,
SubstructureRedirectMask | SubstructureNotifyMask, &xev); SubstructureRedirectMask | SubstructureNotifyMask, &xev);
return; return;
} }
@ -369,7 +369,7 @@ void QSizeGrip::mouseMoveEvent(QMouseEvent * e)
return; return;
#ifdef Q_WS_X11 #ifdef Q_WS_X11
if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE)) if (tlw->isWindow() && qt_x11Data->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE))
&& tlw->isTopLevel() && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint) && tlw->isTopLevel() && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
&& !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth())
return; return;

View file

@ -361,7 +361,7 @@ QDataStream &operator>>(QDataStream &in, QNetworkCacheMetaData &metaData)
static inline QDataStream &operator>>(QDataStream &in, QNetworkCacheMetaData::AttributesMap &hash) static inline QDataStream &operator>>(QDataStream &in, QNetworkCacheMetaData::AttributesMap &hash)
{ {
hash.clear(); hash.clear();
QDataStream::StreamStatus oldStatus = in.status(); QDataStream::DataStatus oldStatus = in.status();
in.resetStatus(); in.resetStatus();
hash.clear(); hash.clear();

View file

@ -242,7 +242,7 @@ MainWindow::MainWindow()
connect(ui->buttonWindowColor, SIGNAL(colorChanged(QColor)), SLOT(buildPalette())); connect(ui->buttonWindowColor, SIGNAL(colorChanged(QColor)), SLOT(buildPalette()));
#ifdef Q_WS_X11 #ifdef Q_WS_X11
if (X11->desktopEnvironment == DE_KDE) if (qt_x11Data->desktopEnvironment == DE_KDE)
ui->colorConfig->hide(); ui->colorConfig->hide();
else else
ui->kdeNoteLabel->hide(); ui->kdeNoteLabel->hide();