summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2011-02-24 11:27:20 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2011-03-01 07:59:40 (GMT)
commit463cee77f75d20760f9f74f52e1dfccb44fcb862 (patch)
tree9dbc0c62bfc33730283c609b3fd77e5744ec4834 /src/plugins
parent2a9680ffcaf85f233323a0d41bea776a519e747a (diff)
downloadQt-463cee77f75d20760f9f74f52e1dfccb44fcb862.zip
Qt-463cee77f75d20760f9f74f52e1dfccb44fcb862.tar.gz
Qt-463cee77f75d20760f9f74f52e1dfccb44fcb862.tar.bz2
Lighthouse: Xlib added QXlibDisplay type
We still use the nativeDisplay all over the place. Maybe we should?
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/xlib/qxlibclipboard.cpp77
-rw-r--r--src/plugins/platforms/xlib/qxlibcursor.cpp39
-rw-r--r--src/plugins/platforms/xlib/qxlibdisplay.cpp37
-rw-r--r--src/plugins/platforms/xlib/qxlibdisplay.h22
-rw-r--r--src/plugins/platforms/xlib/qxlibintegration.cpp3
-rw-r--r--src/plugins/platforms/xlib/qxlibkeyboard.cpp3
-rw-r--r--src/plugins/platforms/xlib/qxlibscreen.cpp73
-rw-r--r--src/plugins/platforms/xlib/qxlibscreen.h16
-rw-r--r--src/plugins/platforms/xlib/qxlibstatic.cpp15
-rw-r--r--src/plugins/platforms/xlib/qxlibwindow.cpp67
-rw-r--r--src/plugins/platforms/xlib/qxlibwindowsurface.cpp14
-rw-r--r--src/plugins/platforms/xlib/xlib.pro6
12 files changed, 228 insertions, 144 deletions
diff --git a/src/plugins/platforms/xlib/qxlibclipboard.cpp b/src/plugins/platforms/xlib/qxlibclipboard.cpp
index 7930fcb..49b2dc7 100644
--- a/src/plugins/platforms/xlib/qxlibclipboard.cpp
+++ b/src/plugins/platforms/xlib/qxlibclipboard.cpp
@@ -43,6 +43,7 @@
#include "qxlibscreen.h"
#include "qxlibmime.h"
+#include "qxlibdisplay.h"
#include <private/qapplication_p.h>
@@ -92,7 +93,7 @@ protected:
if (targets[i] == 0)
continue;
- QStringList formatsForAtom = mimeFormatsForAtom(m_clipboard->screen()->display(),targets[i]);
+ QStringList formatsForAtom = mimeFormatsForAtom(m_clipboard->screen()->display()->nativeDisplay(),targets[i]);
for (int j = 0; j < formatsForAtom.size(); ++j) {
if (!formatList.contains(formatsForAtom.at(j)))
that->formatList.append(formatsForAtom.at(j));
@@ -124,17 +125,17 @@ protected:
atoms.append(targets[i]);
QByteArray encoding;
- Atom fmtatom = mimeAtomForFormat(m_clipboard->screen()->display(),fmt, requestedType, atoms, &encoding);
+ Atom fmtatom = mimeAtomForFormat(m_clipboard->screen()->display()->nativeDisplay(),fmt, requestedType, atoms, &encoding);
if (fmtatom == 0)
return QVariant();
- return mimeConvertToFormat(m_clipboard->screen()->display(),fmtatom, m_clipboard->getDataInFormat(modeAtom,fmtatom), fmt, requestedType, encoding);
+ return mimeConvertToFormat(m_clipboard->screen()->display()->nativeDisplay(),fmtatom, m_clipboard->getDataInFormat(modeAtom,fmtatom), fmt, requestedType, encoding);
}
private:
bool empty() const
{
- Window win = XGetSelectionOwner(m_clipboard->screen()->display(), modeAtom);
+ Window win = XGetSelectionOwner(m_clipboard->screen()->display()->nativeDisplay(), modeAtom);
return win == XNone;
}
@@ -167,7 +168,7 @@ const QMimeData * QXlibClipboard::mimeData(QClipboard::Mode mode) const
QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
that->m_xClipboard = new QXlibClipboardMime(mode,that);
}
- Window clipboardOwner = XGetSelectionOwner(screen()->display(),QXlibStatic::atom(QXlibStatic::CLIPBOARD));
+ Window clipboardOwner = XGetSelectionOwner(screen()->display()->nativeDisplay(),QXlibStatic::atom(QXlibStatic::CLIPBOARD));
if (clipboardOwner == owner()) {
return m_clientClipboard;
} else {
@@ -178,7 +179,7 @@ const QMimeData * QXlibClipboard::mimeData(QClipboard::Mode mode) const
QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
that->m_xSelection = new QXlibClipboardMime(mode,that);
}
- Window clipboardOwner = XGetSelectionOwner(screen()->display(),XA_PRIMARY);
+ Window clipboardOwner = XGetSelectionOwner(screen()->display()->nativeDisplay(),XA_PRIMARY);
if (clipboardOwner == owner()) {
return m_clientSelection;
} else {
@@ -218,9 +219,9 @@ void QXlibClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
*d = data;
}
- XSetSelectionOwner(m_screen->display(), modeAtom, newOwner, CurrentTime);
+ XSetSelectionOwner(m_screen->display()->nativeDisplay(), modeAtom, newOwner, CurrentTime);
- if (XGetSelectionOwner(m_screen->display(), modeAtom) != newOwner) {
+ if (XGetSelectionOwner(m_screen->display()->nativeDisplay(), modeAtom) != newOwner) {
qWarning("QClipboard::setData: Cannot set X11 selection owner");
}
@@ -244,7 +245,7 @@ Window QXlibClipboard::requestor() const
if (!m_requestor) {
int x = 0, y = 0, w = 3, h = 3;
QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
- Window window = XCreateSimpleWindow(m_screen->display(), m_screen->rootWindow(),
+ Window window = XCreateSimpleWindow(m_screen->display()->nativeDisplay(), m_screen->rootWindow(),
x, y, w, h, 0 /*border_width*/,
m_screen->blackPixel(), m_screen->whitePixel());
that->setRequestor(window);
@@ -255,7 +256,7 @@ Window QXlibClipboard::requestor() const
void QXlibClipboard::setRequestor(Window window)
{
if (m_requestor != XNone) {
- XDestroyWindow(m_screen->display(),m_requestor);
+ XDestroyWindow(m_screen->display()->nativeDisplay(),m_requestor);
}
m_requestor = window;
}
@@ -265,7 +266,7 @@ Window QXlibClipboard::owner() const
if (!m_owner) {
int x = 0, y = 0, w = 3, h = 3;
QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
- Window window = XCreateSimpleWindow(m_screen->display(), m_screen->rootWindow(),
+ Window window = XCreateSimpleWindow(m_screen->display()->nativeDisplay(), m_screen->rootWindow(),
x, y, w, h, 0 /*border_width*/,
m_screen->blackPixel(), m_screen->whitePixel());
that->setOwner(window);
@@ -276,7 +277,7 @@ Window QXlibClipboard::owner() const
void QXlibClipboard::setOwner(Window window)
{
if (m_owner != XNone){
- XDestroyWindow(m_screen->display(),m_owner);
+ XDestroyWindow(m_screen->display()->nativeDisplay(),m_owner);
}
m_owner = window;
}
@@ -286,7 +287,7 @@ Atom QXlibClipboard::sendTargetsSelection(QMimeData *d, Window window, Atom prop
QVector<Atom> types;
QStringList formats = QInternalMimeData::formatsHelper(d);
for (int i = 0; i < formats.size(); ++i) {
- QList<Atom> atoms = QXlibMime::mimeAtomsForFormat(screen()->display(),formats.at(i));
+ QList<Atom> atoms = QXlibMime::mimeAtomsForFormat(screen()->display()->nativeDisplay(),formats.at(i));
for (int j = 0; j < atoms.size(); ++j) {
if (!types.contains(atoms.at(j)))
types.append(atoms.at(j));
@@ -297,7 +298,7 @@ Atom QXlibClipboard::sendTargetsSelection(QMimeData *d, Window window, Atom prop
types.append(QXlibStatic::atom(QXlibStatic::TIMESTAMP));
types.append(QXlibStatic::atom(QXlibStatic::SAVE_TARGETS));
- XChangeProperty(screen()->display(), window, property, XA_ATOM, 32,
+ XChangeProperty(screen()->display()->nativeDisplay(), window, property, XA_ATOM, 32,
PropModeReplace, (uchar *) types.data(), types.size());
return property;
}
@@ -308,14 +309,14 @@ Atom QXlibClipboard::sendSelection(QMimeData *d, Atom target, Window window, Ato
int dataFormat = 0;
QByteArray data;
- QString fmt = QXlibMime::mimeAtomToString(screen()->display(), target);
+ QString fmt = QXlibMime::mimeAtomToString(screen()->display()->nativeDisplay(), target);
if (fmt.isEmpty()) { // Not a MIME type we have
qDebug() << "QClipboard: send_selection(): converting to type '%s' is not supported" << fmt.data();
return XNone;
}
qDebug() << "QClipboard: send_selection(): converting to type '%s'" << fmt.data();
- if (QXlibMime::mimeDataForAtom(screen()->display(),target, d, &data, &atomFormat, &dataFormat)) {
+ if (QXlibMime::mimeDataForAtom(screen()->display()->nativeDisplay(),target, d, &data, &atomFormat, &dataFormat)) {
// don't allow INCR transfers when using MULTIPLE or to
// Motif clients (since Motif doesn't support INCR)
@@ -323,10 +324,10 @@ Atom QXlibClipboard::sendSelection(QMimeData *d, Atom target, Window window, Ato
bool allow_incr = property != motif_clip_temporary;
// X_ChangeProperty protocol request is 24 bytes
- const int increment = (XMaxRequestSize(screen()->display()) * 4) - 24;
+ const int increment = (XMaxRequestSize(screen()->display()->nativeDisplay()) * 4) - 24;
if (data.size() > increment && allow_incr) {
long bytes = data.size();
- XChangeProperty(screen()->display(), window, property,
+ XChangeProperty(screen()->display()->nativeDisplay(), window, property,
QXlibStatic::atom(QXlibStatic::INCR), 32, PropModeReplace, (uchar *) &bytes, 1);
// (void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment);
@@ -339,7 +340,7 @@ Atom QXlibClipboard::sendSelection(QMimeData *d, Atom target, Window window, Ato
return XNone; // ### perhaps use several XChangeProperty calls w/ PropModeAppend?
int dataSize = data.size() / (dataFormat / 8);
// use a single request to transfer data
- XChangeProperty(screen()->display(), window, property, atomFormat,
+ XChangeProperty(screen()->display()->nativeDisplay(), window, property, atomFormat,
dataFormat, PropModeReplace, (uchar *) data.data(),
dataSize);
}
@@ -371,13 +372,13 @@ void QXlibClipboard::handleSelectionRequest(XEvent *xevent)
d = m_clientClipboard;
} else {
qWarning("QClipboard: Unknown selection '%lx'", req->selection);
- XSendEvent(screen()->display(), req->requestor, False, NoEventMask, &event);
+ XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
return;
}
if (!d) {
qWarning("QClipboard: Cannot transfer data, no data available");
- XSendEvent(screen()->display(), req->requestor, False, NoEventMask, &event);
+ XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
return;
}
@@ -399,7 +400,7 @@ void QXlibClipboard::handleSelectionRequest(XEvent *xevent)
0, &multi_type, &multi_format)
|| multi_format != 32) {
// MULTIPLE property not formatted correctly
- XSendEvent(screen()->display(), req->requestor, False, NoEventMask, &event);
+ XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
return;
}
nmulti = multi_data.size()/sizeof(*multi);
@@ -427,7 +428,7 @@ void QXlibClipboard::handleSelectionRequest(XEvent *xevent)
;
} else if (target == xa_timestamp) {
// if (d->timestamp != CurrentTime) {
-// XChangeProperty(screen()->display(), req->requestor, property, XA_INTEGER, 32,
+// XChangeProperty(screen()->display()->nativeDisplay(), req->requestor, property, XA_INTEGER, 32,
// PropModeReplace, CurrentTime, 1);
// ret = property;
// } else {
@@ -454,7 +455,7 @@ void QXlibClipboard::handleSelectionRequest(XEvent *xevent)
if (multi_writeback) {
// according to ICCCM 2.6.2 says to put None back
// into the original property on the requestor window
- XChangeProperty(screen()->display(), req->requestor, req->property, multi_type, 32,
+ XChangeProperty(screen()->display()->nativeDisplay(), req->requestor, req->property, multi_type, 32,
PropModeReplace, (uchar *) multi, nmulti * 2);
}
@@ -463,7 +464,7 @@ void QXlibClipboard::handleSelectionRequest(XEvent *xevent)
}
// send selection notify to requestor
- XSendEvent(screen()->display(), req->requestor, False, NoEventMask, &event);
+ XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
}
static inline int maxSelectionIncr(Display *dpy)
@@ -471,7 +472,7 @@ static inline int maxSelectionIncr(Display *dpy)
bool QXlibClipboard::clipboardReadProperty(Window win, Atom property, bool deleteProperty, QByteArray *buffer, int *size, Atom *type, int *format) const
{
- int maxsize = maxSelectionIncr(screen()->display());
+ int maxsize = maxSelectionIncr(screen()->display()->nativeDisplay());
ulong bytes_left; // bytes_after
ulong length; // nitems
uchar *data;
@@ -485,7 +486,7 @@ bool QXlibClipboard::clipboardReadProperty(Window win, Atom property, bool delet
format = &dummy_format;
// Don't read anything, just get the size of the property data
- r = XGetWindowProperty(screen()->display(), win, property, 0, 0, False,
+ r = XGetWindowProperty(screen()->display()->nativeDisplay(), win, property, 0, 0, False,
AnyPropertyType, type, format,
&length, &bytes_left, &data);
if (r != Success || (type && *type == XNone)) {
@@ -524,7 +525,7 @@ bool QXlibClipboard::clipboardReadProperty(Window win, Atom property, bool delet
while (bytes_left) {
// more to read...
- r = XGetWindowProperty(screen()->display(), win, property, offset, maxsize/4,
+ r = XGetWindowProperty(screen()->display()->nativeDisplay(), win, property, offset, maxsize/4,
False, AnyPropertyType, type, format,
&length, &bytes_left, &data);
if (r != Success || (type && *type == XNone))
@@ -559,7 +560,7 @@ bool QXlibClipboard::clipboardReadProperty(Window win, Atom property, bool delet
char **list_ret = 0;
int count;
- if (XmbTextPropertyToTextList(screen()->display(), &textprop, &list_ret,
+ if (XmbTextPropertyToTextList(screen()->display()->nativeDisplay(), &textprop, &list_ret,
&count) == Success && count && list_ret) {
offset = buffer_offset = strlen(list_ret[0]);
buffer->resize(offset);
@@ -574,9 +575,9 @@ bool QXlibClipboard::clipboardReadProperty(Window win, Atom property, bool delet
*size = buffer_offset;
if (deleteProperty)
- XDeleteProperty(screen()->display(), win, property);
+ XDeleteProperty(screen()->display()->nativeDisplay(), win, property);
- XFlush(screen()->display());
+ screen()->display()->flush();
return ok;
}
@@ -600,7 +601,7 @@ QByteArray QXlibClipboard::clipboardReadIncrementalProperty(Window win, Atom pro
}
for (;;) {
- XFlush(screen()->display());
+ screen()->display()->flush();
if (!screen()->waitForClipboardEvent(win,PropertyNotify,&event,clipboard_timeout))
break;
if (event.xproperty.atom != property ||
@@ -645,11 +646,11 @@ QByteArray QXlibClipboard::getDataInFormat(Atom modeAtom, Atom fmtatom)
Window win = requestor();
- XSelectInput(screen()->display(), win, NoEventMask); // don't listen for any events
+ XSelectInput(screen()->display()->nativeDisplay(), win, NoEventMask); // don't listen for any events
- XDeleteProperty(screen()->display(), win, QXlibStatic::atom(QXlibStatic::_QT_SELECTION));
- XConvertSelection(screen()->display(), modeAtom, fmtatom, QXlibStatic::atom(QXlibStatic::_QT_SELECTION), win, CurrentTime);
- XSync(screen()->display(), false);
+ XDeleteProperty(screen()->display()->nativeDisplay(), win, QXlibStatic::atom(QXlibStatic::_QT_SELECTION));
+ XConvertSelection(screen()->display()->nativeDisplay(), modeAtom, fmtatom, QXlibStatic::atom(QXlibStatic::_QT_SELECTION), win, CurrentTime);
+ screen()->display()->sync();
XEvent xevent;
if (!screen()->waitForClipboardEvent(win,SelectionNotify,&xevent,clipboard_timeout) ||
@@ -658,7 +659,7 @@ QByteArray QXlibClipboard::getDataInFormat(Atom modeAtom, Atom fmtatom)
}
Atom type;
- XSelectInput(screen()->display(), win, PropertyChangeMask);
+ XSelectInput(screen()->display()->nativeDisplay(), win, PropertyChangeMask);
if (clipboardReadProperty(win, QXlibStatic::atom(QXlibStatic::_QT_SELECTION), true, &buf, 0, &type, 0)) {
if (type == QXlibStatic::atom(QXlibStatic::INCR)) {
@@ -667,7 +668,7 @@ QByteArray QXlibClipboard::getDataInFormat(Atom modeAtom, Atom fmtatom)
}
}
- XSelectInput(screen()->display(), win, NoEventMask);
+ XSelectInput(screen()->display()->nativeDisplay(), win, NoEventMask);
return buf;
diff --git a/src/plugins/platforms/xlib/qxlibcursor.cpp b/src/plugins/platforms/xlib/qxlibcursor.cpp
index e4d248c..074d2f7 100644
--- a/src/plugins/platforms/xlib/qxlibcursor.cpp
+++ b/src/plugins/platforms/xlib/qxlibcursor.cpp
@@ -44,6 +44,7 @@
#include "qxlibintegration.h"
#include "qxlibscreen.h"
#include "qxlibwindow.h"
+#include "qxlibdisplay.h"
#include <QtGui/QBitmap>
@@ -121,11 +122,11 @@ Cursor QXlibCursor::createCursorBitmap(QCursor * cursor)
memcpy(maskBits + (destLineSize * i),mask + (bytesPerLine * i), destLineSize);
}
- Pixmap cp = XCreateBitmapFromData(testLiteScreen()->display(), rootwin, mapBits, width, height);
- Pixmap mp = XCreateBitmapFromData(testLiteScreen()->display(), rootwin, maskBits, width, height);
- Cursor c = XCreatePixmapCursor(testLiteScreen()->display(), cp, mp, &fg, &bg, spot.x(), spot.y());
- XFreePixmap(testLiteScreen()->display(), cp);
- XFreePixmap(testLiteScreen()->display(), mp);
+ Pixmap cp = XCreateBitmapFromData(testLiteScreen()->display()->nativeDisplay(), rootwin, mapBits, width, height);
+ Pixmap mp = XCreateBitmapFromData(testLiteScreen()->display()->nativeDisplay(), rootwin, maskBits, width, height);
+ Cursor c = XCreatePixmapCursor(testLiteScreen()->display()->nativeDisplay(), cp, mp, &fg, &bg, spot.x(), spot.y());
+ XFreePixmap(testLiteScreen()->display()->nativeDisplay(), cp);
+ XFreePixmap(testLiteScreen()->display()->nativeDisplay(), mp);
delete[] mapBits;
delete[] maskBits;
@@ -141,48 +142,48 @@ Cursor QXlibCursor::createCursorShape(int cshape)
switch (cshape) {
case Qt::ArrowCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_left_ptr);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_left_ptr);
break;
case Qt::UpArrowCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_center_ptr);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_center_ptr);
break;
case Qt::CrossCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_crosshair);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_crosshair);
break;
case Qt::WaitCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_watch);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_watch);
break;
case Qt::IBeamCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_xterm);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_xterm);
break;
case Qt::SizeAllCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_fleur);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_fleur);
break;
case Qt::PointingHandCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_hand2);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_hand2);
break;
case Qt::SizeBDiagCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_top_right_corner);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_top_right_corner);
break;
case Qt::SizeFDiagCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_bottom_right_corner);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_bottom_right_corner);
break;
case Qt::SizeVerCursor:
case Qt::SplitVCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_sb_v_double_arrow);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_sb_v_double_arrow);
break;
case Qt::SizeHorCursor:
case Qt::SplitHCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_sb_h_double_arrow);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_sb_h_double_arrow);
break;
case Qt::WhatsThisCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_question_arrow);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_question_arrow);
break;
case Qt::ForbiddenCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_circle);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_circle);
break;
case Qt::BusyCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_watch);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_watch);
break;
default: //default cursor for all the rest
diff --git a/src/plugins/platforms/xlib/qxlibdisplay.cpp b/src/plugins/platforms/xlib/qxlibdisplay.cpp
new file mode 100644
index 0000000..3b60af2
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibdisplay.cpp
@@ -0,0 +1,37 @@
+#include "qxlibdisplay.h"
+
+QXlibDisplay::QXlibDisplay(Display *display)
+ : mDisplay(display)
+{
+ if (!mDisplay) {
+ qFatal("Cannot connect to X server");
+ }
+ mDisplayName = QString::fromLocal8Bit(DisplayString(mDisplay));
+}
+
+QXlibDisplay::~QXlibDisplay()
+{
+ XCloseDisplay(mDisplay);
+}
+
+QString QXlibDisplay::displayName() const
+{
+ { return mDisplayName; }
+}
+
+
+
+Display * QXlibDisplay::nativeDisplay() const
+{
+ return mDisplay;
+}
+
+void QXlibDisplay::sync() const
+{
+ XSync(mDisplay, False);
+}
+
+void QXlibDisplay::flush() const
+{
+ XFlush(mDisplay);
+}
diff --git a/src/plugins/platforms/xlib/qxlibdisplay.h b/src/plugins/platforms/xlib/qxlibdisplay.h
new file mode 100644
index 0000000..f2cca9e
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibdisplay.h
@@ -0,0 +1,22 @@
+#ifndef QXLIBDISPLAY_H
+#define QXLIBDISPLAY_H
+
+#include "qxlibintegration.h"
+
+class QXlibDisplay
+{
+public:
+ QXlibDisplay(Display *display);
+ ~QXlibDisplay();
+ QString displayName() const;
+
+ Display *nativeDisplay() const;
+
+ void sync() const;
+ void flush() const;
+private:
+ Display *mDisplay;
+ QString mDisplayName;
+};
+
+#endif // QXLIBDISPLAY_H
diff --git a/src/plugins/platforms/xlib/qxlibintegration.cpp b/src/plugins/platforms/xlib/qxlibintegration.cpp
index 46eabbf..e3ebb13 100644
--- a/src/plugins/platforms/xlib/qxlibintegration.cpp
+++ b/src/plugins/platforms/xlib/qxlibintegration.cpp
@@ -48,6 +48,7 @@
#include "qgenericunixfontdatabase.h"
#include "qxlibscreen.h"
#include "qxlibclipboard.h"
+#include "qxlibdisplay.h"
#if !defined(QT_NO_OPENGL)
#if !defined(QT_OPENGL_ES_2)
@@ -143,7 +144,7 @@ bool QXlibIntegration::hasOpenGL() const
const QXlibScreen *screen = static_cast<const QXlibScreen *>(mScreens.at(0));
EGLint major, minor;
eglBindAPI(EGL_OPENGL_ES_API);
- EGLDisplay disp = eglGetDisplay(screen->display());
+ EGLDisplay disp = eglGetDisplay(screen->display()->nativeDisplay());
wasEglInitialized = eglInitialize(disp,&major,&minor);
}
return wasEglInitialized;
diff --git a/src/plugins/platforms/xlib/qxlibkeyboard.cpp b/src/plugins/platforms/xlib/qxlibkeyboard.cpp
index a1e38b0..690d273 100644
--- a/src/plugins/platforms/xlib/qxlibkeyboard.cpp
+++ b/src/plugins/platforms/xlib/qxlibkeyboard.cpp
@@ -42,6 +42,7 @@
#include "qxlibkeyboard.h"
#include "qxlibscreen.h"
+#include "qxlibdisplay.h"
#include <QtGui/QWindowSystemInterface>
@@ -951,7 +952,7 @@ QXlibKeyboard::QXlibKeyboard(QXlibScreen *screen)
void QXlibKeyboard::changeLayout()
{
- XkbDescPtr xkbDesc = XkbGetMap(m_screen->display(), XkbAllClientInfoMask, XkbUseCoreKbd);
+ XkbDescPtr xkbDesc = XkbGetMap(m_screen->display()->nativeDisplay(), XkbAllClientInfoMask, XkbUseCoreKbd);
for (int i = xkbDesc->min_key_code; i < xkbDesc->max_key_code; ++i) {
const uint mask = xkbDesc->map->modmap ? xkbDesc->map->modmap[i] : 0;
if (mask == 0) {
diff --git a/src/plugins/platforms/xlib/qxlibscreen.cpp b/src/plugins/platforms/xlib/qxlibscreen.cpp
index ef04fb2..5a9aca9 100644
--- a/src/plugins/platforms/xlib/qxlibscreen.cpp
+++ b/src/plugins/platforms/xlib/qxlibscreen.cpp
@@ -46,6 +46,7 @@
#include "qxlibkeyboard.h"
#include "qxlibstatic.h"
#include "qxlibclipboard.h"
+#include "qxlibdisplay.h"
#include <QtCore/QDebug>
#include <QtCore/QSocketNotifier>
@@ -192,36 +193,32 @@ QXlibScreen::QXlibScreen()
: mFormat(QImage::Format_RGB32)
{
char *display_name = getenv("DISPLAY");
- mDisplay = XOpenDisplay(display_name);
- mDisplayName = QString::fromLocal8Bit(display_name);
- if (!mDisplay) {
- fprintf(stderr, "Cannot connect to X server: %s\n",
- display_name);
- exit(1);
- }
+ Display *display = XOpenDisplay(display_name);
+ mDisplay = new QXlibDisplay(display);
+
#ifndef DONT_USE_MIT_SHM
- Status MIT_SHM_extension_supported = XShmQueryExtension (mDisplay);
+ Status MIT_SHM_extension_supported = XShmQueryExtension (mDisplay->nativeDisplay());
Q_ASSERT(MIT_SHM_extension_supported == True);
#endif
original_x_errhandler = XSetErrorHandler(qt_x_errhandler);
if (qgetenv("DO_X_SYNCHRONIZE").toInt())
- XSynchronize(mDisplay, true);
+ XSynchronize(mDisplay->nativeDisplay(), true);
- mScreen = DefaultScreen(mDisplay);
- XSelectInput(mDisplay,rootWindow(), KeymapStateMask | EnterWindowMask | LeaveWindowMask | PropertyChangeMask);
- int width = DisplayWidth(mDisplay, mScreen);
- int height = DisplayHeight(mDisplay, mScreen);
+ mScreen = DefaultScreen(mDisplay->nativeDisplay());
+ XSelectInput(mDisplay->nativeDisplay(),rootWindow(), KeymapStateMask | EnterWindowMask | LeaveWindowMask | PropertyChangeMask);
+ int width = DisplayWidth(mDisplay->nativeDisplay(), mScreen);
+ int height = DisplayHeight(mDisplay->nativeDisplay(), mScreen);
mGeometry = QRect(0,0,width,height);
- int physicalWidth = DisplayWidthMM(mDisplay, mScreen);
- int physicalHeight = DisplayHeightMM(mDisplay, mScreen);
+ int physicalWidth = DisplayWidthMM(mDisplay->nativeDisplay(), mScreen);
+ int physicalHeight = DisplayHeightMM(mDisplay->nativeDisplay(), mScreen);
mPhysicalSize = QSize(physicalWidth,physicalHeight);
- int xSocketNumber = XConnectionNumber(mDisplay);
+ int xSocketNumber = XConnectionNumber(mDisplay->nativeDisplay());
- mDepth = DefaultDepth(mDisplay,mScreen);
+ mDepth = DefaultDepth(mDisplay->nativeDisplay(),mScreen);
#ifdef MYX11_DEBUG
qDebug() << "X socket:"<< xSocketNumber;
#endif
@@ -235,7 +232,22 @@ QXlibScreen::QXlibScreen()
QXlibScreen::~QXlibScreen()
{
delete mCursor;
- XCloseDisplay(mDisplay);
+ delete mDisplay;
+}
+
+Window QXlibScreen::rootWindow()
+{
+ return RootWindow(mDisplay->nativeDisplay(), mScreen);
+}
+
+unsigned long QXlibScreen::blackPixel()
+{
+ return BlackPixel(mDisplay->nativeDisplay(), mScreen);
+}
+
+unsigned long QXlibScreen::whitePixel()
+{
+ return WhitePixel(mDisplay->nativeDisplay(), mScreen);
}
#ifdef KeyPress
@@ -358,15 +370,15 @@ bool QXlibScreen::waitForClipboardEvent(Window win, int type, XEvent *event, int
QElapsedTimer timer;
timer.start();
do {
- if (XCheckTypedWindowEvent(mDisplay,win,type,event))
+ if (XCheckTypedWindowEvent(mDisplay->nativeDisplay(),win,type,event))
return true;
// process other clipboard events, since someone is probably requesting data from us
XEvent e;
- if (XCheckIfEvent(mDisplay, &e, checkForClipboardEvents, 0))
+ if (XCheckIfEvent(mDisplay->nativeDisplay(), &e, checkForClipboardEvents, 0))
handleEvent(&e);
- XFlush(mDisplay);
+ mDisplay->flush();
// sleep 50 ms, so we don't use up CPU cycles all the time.
struct timeval usleep_tv;
@@ -379,11 +391,11 @@ bool QXlibScreen::waitForClipboardEvent(Window win, int type, XEvent *event, int
void QXlibScreen::eventDispatcher()
{
- ulong marker = XNextRequest(mDisplay);
+ ulong marker = XNextRequest(mDisplay->nativeDisplay());
// int i = 0;
- while (XPending(mDisplay)) {
+ while (XPending(mDisplay->nativeDisplay())) {
XEvent event;
- XNextEvent(mDisplay, &event);
+ XNextEvent(mDisplay->nativeDisplay(), &event);
/* done = */
handleEvent(&event);
@@ -392,7 +404,7 @@ void QXlibScreen::eventDispatcher()
qDebug() << "potential livelock averted";
#endif
#if 0
- if (XEventsQueued(mDisplay, QueuedAfterFlush)) {
+ if (XEventsQueued(mDisplay->nativeDisplay(), QueuedAfterFlush)) {
qDebug() << " with events queued";
QTimer::singleShot(0, this, SLOT(eventDispatcher()));
}
@@ -412,7 +424,7 @@ QImage QXlibScreen::grabWindow(Window window, int x, int y, int w, int h)
window = rootWindow();
XWindowAttributes window_attr;
- if (!XGetWindowAttributes(mDisplay, window, &window_attr))
+ if (!XGetWindowAttributes(mDisplay->nativeDisplay(), window, &window_attr))
return QImage();
if (w < 0)
@@ -424,7 +436,7 @@ QImage QXlibScreen::grabWindow(Window window, int x, int y, int w, int h)
// that it's "unsafe" to go outside the screen, so we can ignore that problem.
//We're definitely not optimizing for speed...
- XImage *xi = XGetImage(mDisplay, window, x, y, w, h, AllPlanes, ZPixmap);
+ XImage *xi = XGetImage(mDisplay->nativeDisplay(), window, x, y, w, h, AllPlanes, ZPixmap);
if (!xi)
return QImage();
@@ -443,7 +455,7 @@ QXlibScreen * QXlibScreen::testLiteScreenForWidget(QWidget *widget)
return static_cast<QXlibScreen *>(platformScreen);
}
-Display * QXlibScreen::display() const
+QXlibDisplay * QXlibScreen::display() const
{
return mDisplay;
}
@@ -453,6 +465,11 @@ int QXlibScreen::xScreenNumber() const
return mScreen;
}
+Visual * QXlibScreen::defaultVisual() const
+{
+ DefaultVisual(display()->nativeDisplay(), xScreenNumber());
+}
+
QXlibKeyboard * QXlibScreen::keyboard() const
{
return mKeyboard;
diff --git a/src/plugins/platforms/xlib/qxlibscreen.h b/src/plugins/platforms/xlib/qxlibscreen.h
index c8043fb..8dac41d 100644
--- a/src/plugins/platforms/xlib/qxlibscreen.h
+++ b/src/plugins/platforms/xlib/qxlibscreen.h
@@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE
class QXlibCursor;
class QXlibKeyboard;
+class QXlibDisplay;
class QXlibScreen : public QPlatformScreen
{
@@ -58,16 +59,14 @@ public:
~QXlibScreen();
- QString displayName() const { return mDisplayName; }
-
QRect geometry() const { return mGeometry; }
int depth() const { return mDepth; }
QImage::Format format() const { return mFormat; }
QSize physicalSize() const { return mPhysicalSize; }
- Window rootWindow() { return RootWindow(mDisplay, mScreen); }
- unsigned long blackPixel() { return BlackPixel(mDisplay, mScreen); }
- unsigned long whitePixel() { return WhitePixel(mDisplay, mScreen); }
+ Window rootWindow();
+ unsigned long blackPixel();
+ unsigned long whitePixel();
bool handleEvent(XEvent *xe);
bool waitForClipboardEvent(Window win, int type, XEvent *event, int timeout);
@@ -76,9 +75,11 @@ public:
static QXlibScreen *testLiteScreenForWidget(QWidget *widget);
- Display *display() const;
+ QXlibDisplay *display() const;
int xScreenNumber() const;
+ Visual *defaultVisual() const;
+
QXlibKeyboard *keyboard() const;
public slots:
@@ -87,7 +88,6 @@ public slots:
private:
void handleSelectionRequest(XEvent *event);
- QString mDisplayName;
QRect mGeometry;
QSize mPhysicalSize;
int mDepth;
@@ -95,7 +95,7 @@ private:
QXlibCursor *mCursor;
QXlibKeyboard *mKeyboard;
- Display * mDisplay;
+ QXlibDisplay * mDisplay;
int mScreen;
};
diff --git a/src/plugins/platforms/xlib/qxlibstatic.cpp b/src/plugins/platforms/xlib/qxlibstatic.cpp
index 3ce5768..f67fbdc 100644
--- a/src/plugins/platforms/xlib/qxlibstatic.cpp
+++ b/src/plugins/platforms/xlib/qxlibstatic.cpp
@@ -41,6 +41,7 @@
#include "qxlibstatic.h"
#include "qxlibscreen.h"
+#include "qxlibdisplay.h"
#include <qplatformdefs.h>
@@ -366,7 +367,7 @@ private:
Q_ASSERT(i == QXlibStatic::NPredefinedAtoms);
QByteArray settings_atom_name("_QT_SETTINGS_TIMESTAMP_");
- settings_atom_name += XDisplayName(qPrintable(screen->displayName()));
+ settings_atom_name += XDisplayName(qPrintable(screen->display()->displayName()));
names[i++] = settings_atom_name;
Q_ASSERT(i == QXlibStatic::NAtoms);
@@ -374,7 +375,7 @@ private:
XInternAtoms(screen->display(), (char **)names, i, False, m_allAtoms);
#else
for (i = 0; i < QXlibStatic::NAtoms; ++i)
- m_allAtoms[i] = XInternAtom(screen->display(), (char *)names[i], False);
+ m_allAtoms[i] = XInternAtom(screen->display()->nativeDisplay(), (char *)names[i], False);
#endif
}
@@ -386,7 +387,7 @@ private:
unsigned long nitems, after;
unsigned char *data = 0;
- int e = XGetWindowProperty(screen->display(), screen->rootWindow(),
+ int e = XGetWindowProperty(screen->display()->nativeDisplay(), screen->rootWindow(),
this->atom(QXlibStatic::_NET_SUPPORTED), 0, 0,
False, XA_ATOM, &type, &format, &nitems, &after, &data);
if (data)
@@ -397,7 +398,7 @@ private:
ts.open(QIODevice::WriteOnly);
while (after > 0) {
- XGetWindowProperty(screen->display(), screen->rootWindow(),
+ XGetWindowProperty(screen->display()->nativeDisplay(), screen->rootWindow(),
this->atom(QXlibStatic::_NET_SUPPORTED), offset, 1024,
False, XA_ATOM, &type, &format, &nitems, &after, &data);
@@ -427,7 +428,7 @@ private:
{
#ifndef QT_NO_XFIXES
// See if Xfixes is supported on the connected display
- if (XQueryExtension(screen->display(), "XFIXES", &xfixes_major,
+ if (XQueryExtension(screen->display()->nativeDisplay(), "XFIXES", &xfixes_major,
&xfixes_eventbase, &xfixes_errorbase)) {
ptrXFixesQueryExtension = XFIXES_LOAD_V1(XFixesQueryExtension);
ptrXFixesQueryVersion = XFIXES_LOAD_V1(XFixesQueryVersion);
@@ -435,7 +436,7 @@ private:
ptrXFixesSelectSelectionInput = XFIXES_LOAD_V2(XFixesSelectSelectionInput);
if(ptrXFixesQueryExtension && ptrXFixesQueryVersion
- && ptrXFixesQueryExtension(screen->display(), &xfixes_eventbase,
+ && ptrXFixesQueryExtension(screen->display()->nativeDisplay(), &xfixes_eventbase,
&xfixes_errorbase)) {
// Xfixes is supported.
// Note: the XFixes protocol version is negotiated using QueryVersion.
@@ -446,7 +447,7 @@ private:
// X server when it receives an XFixes request is undefined.
int major = 3;
int minor = 0;
- ptrXFixesQueryVersion(screen->display(), &major, &minor);
+ ptrXFixesQueryVersion(screen->display()->nativeDisplay(), &major, &minor);
use_xfixes = (major >= 1);
xfixes_major = major;
}
diff --git a/src/plugins/platforms/xlib/qxlibwindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp
index ddd4002..90b36cf 100644
--- a/src/plugins/platforms/xlib/qxlibwindow.cpp
+++ b/src/plugins/platforms/xlib/qxlibwindow.cpp
@@ -45,6 +45,7 @@
#include "qxlibscreen.h"
#include "qxlibkeyboard.h"
#include "qxlibstatic.h"
+#include "qxlibdisplay.h"
#include <QtGui/QWindowSystemInterface>
#include <QSocketNotifier>
@@ -86,9 +87,9 @@ QXlibWindow::QXlibWindow(QWidget *window)
#else
QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat());
- EGLDisplay eglDisplay = eglGetDisplay(mScreen->display());
+ EGLDisplay eglDisplay = eglGetDisplay(mScreen->display()->nativeDisplay());
EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,windowFormat);
- VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display(),eglConfig);
+ VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display()->nativeDisplay(),eglConfig);
XVisualInfo visualInfoTemplate;
memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
@@ -96,14 +97,14 @@ QXlibWindow::QXlibWindow(QWidget *window)
XVisualInfo *visualInfo;
int matchingCount = 0;
- visualInfo = XGetVisualInfo(mScreen->display(), VisualIDMask, &visualInfoTemplate, &matchingCount);
+ visualInfo = XGetVisualInfo(mScreen->display()->nativeDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount);
#endif //!defined(QT_OPENGL_ES_2)
if (visualInfo) {
- Colormap cmap = XCreateColormap(mScreen->display(),mScreen->rootWindow(),visualInfo->visual,AllocNone);
+ Colormap cmap = XCreateColormap(mScreen->display()->nativeDisplay(),mScreen->rootWindow(),visualInfo->visual,AllocNone);
XSetWindowAttributes a;
a.colormap = cmap;
- x_window = XCreateWindow(mScreen->display(), mScreen->rootWindow(),x, y, w, h,
+ x_window = XCreateWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),x, y, w, h,
0, visualInfo->depth, InputOutput, visualInfo->visual,
CWColormap, &a);
} else {
@@ -111,7 +112,7 @@ QXlibWindow::QXlibWindow(QWidget *window)
}
#endif //!defined(QT_NO_OPENGL)
} else {
- x_window = XCreateSimpleWindow(mScreen->display(), mScreen->rootWindow(),
+ x_window = XCreateSimpleWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),
x, y, w, h, 0 /*border_width*/,
mScreen->blackPixel(), mScreen->whitePixel());
}
@@ -120,9 +121,9 @@ QXlibWindow::QXlibWindow(QWidget *window)
qDebug() << "QTestLiteWindow::QTestLiteWindow creating" << hex << x_window << window;
#endif
- XSetWindowBackgroundPixmap(mScreen->display(), x_window, XNone);
+ XSetWindowBackgroundPixmap(mScreen->display()->nativeDisplay(), x_window, XNone);
- XSelectInput(mScreen->display(), x_window,
+ XSelectInput(mScreen->display()->nativeDisplay(), x_window,
ExposureMask | KeyPressMask | KeyReleaseMask |
EnterWindowMask | LeaveWindowMask | FocusChangeMask |
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
@@ -141,7 +142,7 @@ QXlibWindow::QXlibWindow(QWidget *window)
#endif // QT_NO_XSYNC
if (window->windowFlags() & Qt::WindowContextHelpButtonHint)
protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_CONTEXT_HELP);
- XSetWMProtocols(mScreen->display(), x_window, protocols, n);
+ XSetWMProtocols(mScreen->display()->nativeDisplay(), x_window, protocols, n);
}
@@ -152,8 +153,8 @@ QXlibWindow::~QXlibWindow()
qDebug() << "~QTestLiteWindow" << hex << x_window;
#endif
delete mGLContext;
- XFreeGC(mScreen->display(), gc);
- XDestroyWindow(mScreen->display(), x_window);
+ XFreeGC(mScreen->display()->nativeDisplay(), gc);
+ XDestroyWindow(mScreen->display()->nativeDisplay(), x_window);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -245,7 +246,7 @@ void QXlibWindow::handleFocusOutEvent()
void QXlibWindow::setGeometry(const QRect &rect)
{
- XMoveResizeWindow(mScreen->display(), x_window, rect.x(), rect.y(), rect.width(), rect.height());
+ XMoveResizeWindow(mScreen->display()->nativeDisplay(), x_window, rect.x(), rect.y(), rect.width(), rect.height());
QPlatformWindow::setGeometry(rect);
}
@@ -263,17 +264,17 @@ WId QXlibWindow::winId() const
void QXlibWindow::setParent(const QPlatformWindow *window)
{
QPoint topLeft = geometry().topLeft();
- XReparentWindow(mScreen->display(),x_window,window->winId(),topLeft.x(),topLeft.y());
+ XReparentWindow(mScreen->display()->nativeDisplay(),x_window,window->winId(),topLeft.x(),topLeft.y());
}
void QXlibWindow::raise()
{
- XRaiseWindow(mScreen->display(), x_window);
+ XRaiseWindow(mScreen->display()->nativeDisplay(), x_window);
}
void QXlibWindow::lower()
{
- XLowerWindow(mScreen->display(), x_window);
+ XLowerWindow(mScreen->display()->nativeDisplay(), x_window);
}
void QXlibWindow::setWindowTitle(const QString &title)
@@ -285,14 +286,14 @@ void QXlibWindow::setWindowTitle(const QString &title)
windowName.format = 8;
windowName.nitems = ba.length();
- XSetWMName(mScreen->display(), x_window, &windowName);
+ XSetWMName(mScreen->display()->nativeDisplay(), x_window, &windowName);
}
GC QXlibWindow::createGC()
{
GC gc;
- gc = XCreateGC(mScreen->display(), x_window, 0, 0);
+ gc = XCreateGC(mScreen->display()->nativeDisplay(), x_window, 0, 0);
if (gc < 0) {
qWarning("QTestLiteWindow::createGC() could not create GC");
}
@@ -311,7 +312,7 @@ void QXlibWindow::paintEvent()
void QXlibWindow::requestActivateWindow()
{
- XSetInputFocus(mScreen->display(), x_window, XRevertToParent, CurrentTime);
+ XSetInputFocus(mScreen->display()->nativeDisplay(), x_window, XRevertToParent, CurrentTime);
}
void QXlibWindow::resizeEvent(XConfigureEvent *e)
@@ -365,7 +366,7 @@ QXlibMWMHints QXlibWindow::getMWMHints() const
ulong nitems, bytesLeft;
uchar *data = 0;
Atom atomForMotifWmHints = QXlibStatic::atom(QXlibStatic::_MOTIF_WM_HINTS);
- if ((XGetWindowProperty(mScreen->display(), x_window, atomForMotifWmHints, 0, 5, false,
+ if ((XGetWindowProperty(mScreen->display()->nativeDisplay(), x_window, atomForMotifWmHints, 0, 5, false,
atomForMotifWmHints, &type, &format, &nitems, &bytesLeft,
&data) == Success)
&& (type == atomForMotifWmHints
@@ -390,11 +391,11 @@ void QXlibWindow::setMWMHints(const QXlibMWMHints &mwmhints)
{
Atom atomForMotifWmHints = QXlibStatic::atom(QXlibStatic::_MOTIF_WM_HINTS);
if (mwmhints.flags != 0l) {
- XChangeProperty(mScreen->display(), x_window,
+ XChangeProperty(mScreen->display()->nativeDisplay(), x_window,
atomForMotifWmHints, atomForMotifWmHints, 32,
PropModeReplace, (unsigned char *) &mwmhints, 5);
} else {
- XDeleteProperty(mScreen->display(), x_window, atomForMotifWmHints);
+ XDeleteProperty(mScreen->display()->nativeDisplay(), x_window, atomForMotifWmHints);
}
}
@@ -421,7 +422,7 @@ QVector<Atom> QXlibWindow::getNetWmState() const
ulong propertyLength;
ulong bytesLeft;
uchar *propertyData = 0;
- if (XGetWindowProperty(mScreen->display(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), 0, 0,
+ if (XGetWindowProperty(mScreen->display()->nativeDisplay(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), 0, 0,
False, XA_ATOM, &actualType, &actualFormat,
&propertyLength, &bytesLeft, &propertyData) == Success
&& actualType == XA_ATOM && actualFormat == 32) {
@@ -429,7 +430,7 @@ QVector<Atom> QXlibWindow::getNetWmState() const
XFree((char*) propertyData);
// fetch all data
- if (XGetWindowProperty(mScreen->display(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), 0,
+ if (XGetWindowProperty(mScreen->display()->nativeDisplay(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), 0,
returnValue.size(), False, XA_ATOM, &actualType, &actualFormat,
&propertyLength, &bytesLeft, &propertyData) != Success) {
returnValue.clear();
@@ -591,11 +592,11 @@ Qt::WindowFlags QXlibWindow::setWindowFlags(Qt::WindowFlags flags)
}
if (!netWmState.isEmpty()) {
- XChangeProperty(mScreen->display(), x_window,
+ XChangeProperty(mScreen->display()->nativeDisplay(), x_window,
QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), XA_ATOM, 32, PropModeReplace,
(unsigned char *) netWmState.data(), netWmState.size());
} else {
- XDeleteProperty(mScreen->display(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE));
+ XDeleteProperty(mScreen->display()->nativeDisplay(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE));
}
//##### only if initializeWindow???
@@ -609,7 +610,7 @@ Qt::WindowFlags QXlibWindow::setWindowFlags(Qt::WindowFlags flags)
wsa.override_redirect = True;
wsa.save_under = True;
- XChangeWindowAttributes(mScreen->display(), x_window, CWOverrideRedirect | CWSaveUnder,
+ XChangeWindowAttributes(mScreen->display()->nativeDisplay(), x_window, CWOverrideRedirect | CWSaveUnder,
&wsa);
} else {
#ifdef MYX11_DEBUG
@@ -634,22 +635,22 @@ void QXlibWindow::setVisible(bool visible)
parentXWindow = parentWidnow->x_window;
}
}
- XSetTransientForHint(mScreen->display(),x_window,parentXWindow);
+ XSetTransientForHint(mScreen->display()->nativeDisplay(),x_window,parentXWindow);
}
if (visible) {
//ensure that the window is viewed in correct position.
doSizeHints();
- XMapWindow(mScreen->display(), x_window);
+ XMapWindow(mScreen->display()->nativeDisplay(), x_window);
} else {
- XUnmapWindow(mScreen->display(), x_window);
+ XUnmapWindow(mScreen->display()->nativeDisplay(), x_window);
}
}
void QXlibWindow::setCursor(const Cursor &cursor)
{
- XDefineCursor(mScreen->display(), x_window, cursor);
- XFlush(mScreen->display());
+ XDefineCursor(mScreen->display()->nativeDisplay(), x_window, cursor);
+ mScreen->display()->flush();
}
QPlatformGLContext *QXlibWindow::glContext() const
@@ -662,7 +663,7 @@ QPlatformGLContext *QXlibWindow::glContext() const
#if !defined(QT_OPENGL_ES_2)
that->mGLContext = new QGLXContext(x_window, mScreen,widget()->platformWindowFormat());
#else
- EGLDisplay display = eglGetDisplay(mScreen->display());
+ EGLDisplay display = eglGetDisplay(mScreen->display()->nativeDisplay());
QPlatformWindowFormat windowFormat = correctColorBuffers(widget()->platformWindowFormat());
@@ -706,7 +707,7 @@ void QXlibWindow::doSizeHints()
s.flags |= PSize;
s.flags |= PWinGravity;
s.win_gravity = QApplication::isRightToLeft() ? NorthEastGravity : NorthWestGravity;
- XSetWMNormalHints(mScreen->display(), x_window, &s);
+ XSetWMNormalHints(mScreen->display()->nativeDisplay(), x_window, &s);
}
QPlatformWindowFormat QXlibWindow::correctColorBuffers(const QPlatformWindowFormat &platformWindowFormat) const
diff --git a/src/plugins/platforms/xlib/qxlibwindowsurface.cpp b/src/plugins/platforms/xlib/qxlibwindowsurface.cpp
index 92e1793..fa1e197 100644
--- a/src/plugins/platforms/xlib/qxlibwindowsurface.cpp
+++ b/src/plugins/platforms/xlib/qxlibwindowsurface.cpp
@@ -47,6 +47,7 @@
#include "qxlibwindow.h"
#include "qxlibscreen.h"
+#include "qxlibdisplay.h"
# include <sys/ipc.h>
# include <sys/shm.h>
@@ -88,12 +89,11 @@ void QXlibWindowSurface::resizeShmImage(int width, int height)
if (image_info)
image_info->destroy();
else
- image_info = new QXlibShmImageInfo(screen->display());
+ image_info = new QXlibShmImageInfo(screen->display()->nativeDisplay());
- Visual *visual = DefaultVisual(screen->display(), screen->xScreenNumber());
+ Visual *visual = screen->defaultVisual();
-
- XImage *image = XShmCreateImage (screen->display(), visual, 24, ZPixmap, 0,
+ XImage *image = XShmCreateImage (screen->display()->nativeDisplay(), visual, 24, ZPixmap, 0,
&image_info->shminfo, width, height);
@@ -105,7 +105,7 @@ void QXlibWindowSurface::resizeShmImage(int width, int height)
image_info->image = image;
- Status shm_attach_status = XShmAttach(screen->display(), &image_info->shminfo);
+ Status shm_attach_status = XShmAttach(screen->display()->nativeDisplay(), &image_info->shminfo);
Q_ASSERT(shm_attach_status == True);
@@ -185,11 +185,11 @@ void QXlibWindowSurface::flush(QWidget *widget, const QRegion &region, const QPo
// We could set send_event to true, and then use the ShmCompletion to synchronize,
// but let's do like Qt/11 and just use XSync
- XShmPutImage (screen->display(), window, gc, image_info->image, 0, 0,
+ XShmPutImage (screen->display()->nativeDisplay(), window, gc, image_info->image, 0, 0,
x, y, image_info->image->width, image_info->image->height,
/*send_event*/ False);
- XSync(screen->display(), False);
+ screen->display()->sync();
}
#endif
}
diff --git a/src/plugins/platforms/xlib/xlib.pro b/src/plugins/platforms/xlib/xlib.pro
index 999621b..dc22b80 100644
--- a/src/plugins/platforms/xlib/xlib.pro
+++ b/src/plugins/platforms/xlib/xlib.pro
@@ -13,7 +13,8 @@ SOURCES = \
qxlibkeyboard.cpp \
qxlibclipboard.cpp \
qxlibmime.cpp \
- qxlibstatic.cpp
+ qxlibstatic.cpp \
+ qxlibdisplay.cpp
HEADERS = \
qxlibintegration.h \
@@ -24,7 +25,8 @@ HEADERS = \
qxlibkeyboard.h \
qxlibclipboard.h \
qxlibmime.h \
- qxlibstatic.h
+ qxlibstatic.h \
+ qxlibdisplay.h
LIBS += -lX11 -lXext