xcb: Use QT_CONFIG macro to check for xcb-xlib

... and remove the XCB_USE_XLIB define.

This patch also removes the unnecessary checks for xcb-xlib in:

- qxcbglxintegration.cpp as this files is build _only_ when
xcb-xlib is present. From gl_integrations.pro:

 qtConfig(xcb-xlib):qtConfig(opengl):!qtConfig(opengles2) {
    SUBDIRS += xcb_glx
 }

This also would have been the right place where to define
XCB_USE_XLIB, instead of unconditional line in xcb_glx.pro:

 DEFINES += XCB_USE_GLX XCB_USE_XLIB

- qxcbnativeinterface.cpp as this cpp file does not use any
Xlib APIs directly, there is no need to include Xlib.h.

Change-Id: I531b5f1e79606fcfd1c63810cf51b7d5e9dc58a7
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
This commit is contained in:
Alexander Volkov 2017-02-22 13:55:28 +03:00 committed by Gatis Paeglis
parent 8612b0ed93
commit b1381ea9eb
15 changed files with 32 additions and 42 deletions

View File

@ -7,7 +7,6 @@ load(qt_build_paths)
# needed by Xcursor ...
qtConfig(xcb-xlib) {
DEFINES += XCB_USE_XLIB
qtConfig(xinput2) {
DEFINES += XCB_USE_XINPUT2
}

View File

@ -116,7 +116,7 @@ QPlatformOffscreenSurface *QXcbEglIntegration::createPlatformOffscreenSurface(QO
void *QXcbEglIntegration::xlib_display() const
{
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
return m_connection->xlib_display();
#else
return EGL_DEFAULT_DISPLAY;

View File

@ -65,7 +65,7 @@ void QXcbEglWindow::resolveFormat(const QSurfaceFormat &format)
m_format = q_glFormatFromConfig(m_glIntegration->eglDisplay(), m_config, format);
}
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
const xcb_visualtype_t *QXcbEglWindow::createVisual()
{
QXcbScreen *scr = xcbScreen();

View File

@ -62,7 +62,7 @@ protected:
void create() override;
void resolveFormat(const QSurfaceFormat &format) override;
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
const xcb_visualtype_t *createVisual() override;
#endif

View File

@ -5,8 +5,6 @@ QT += egl_support-private
CONFIG += egl
qtConfig(xcb-xlib): DEFINES += XCB_USE_XLIB
DEFINES += QT_NO_FOREACH
HEADERS += \

View File

@ -75,7 +75,7 @@ typedef struct xcb_glx_buffer_swap_complete_event_t {
} xcb_glx_buffer_swap_complete_event_t;
#endif
#if defined(XCB_USE_XLIB) && defined(XCB_USE_GLX)
#if defined(XCB_USE_GLX)
typedef struct {
int type;
unsigned long serial; /* # of last request processed by server */
@ -202,10 +202,9 @@ QPlatformOffscreenSurface *QXcbGlxIntegration::createPlatformOffscreenSurface(QO
if (!vendorChecked) {
vendorChecked = true;
Display *display = glXGetCurrentDisplay();
#ifdef XCB_USE_XLIB
if (!display)
display = static_cast<Display *>(m_connection->xlib_display());
#endif
const char *glxvendor = glXGetClientString(display, GLX_VENDOR);
if (glxvendor) {
if (!strcmp(glxvendor, "ATI") || !strcmp(glxvendor, "Chromium"))
@ -231,10 +230,9 @@ bool QXcbGlxIntegration::supportsSwitchableWidgetComposition() const
if (!vendorChecked) {
vendorChecked = true;
Display *display = glXGetCurrentDisplay();
#ifdef XCB_USE_XLIB
if (!display)
display = static_cast<Display *>(m_connection->xlib_display());
#endif
const char *glxvendor = glXGetClientString(display, GLX_VENDOR);
if (glxvendor) {
if (!strcmp(glxvendor, "Parallels Inc"))

View File

@ -4,7 +4,7 @@ include(../gl_integrations_plugin_base.pri)
QT += glx_support-private
#should be removed from the sources
DEFINES += XCB_USE_GLX XCB_USE_XLIB
DEFINES += XCB_USE_GLX
DEFINES += QT_NO_FOREACH
qtConfig(xcb-glx) {

View File

@ -69,7 +69,7 @@
#include <xcb/xfixes.h>
#include <xcb/xinerama.h>
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
#include <X11/Xlib.h>
#include <X11/Xlib-xcb.h>
#include <X11/Xlibint.h>
@ -136,7 +136,7 @@ static inline bool isXIEvent(xcb_generic_event_t *event, int opCode)
}
#endif // XCB_USE_XINPUT2
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
static const char * const xcbConnectionErrors[] = {
"No error", /* Error 0 */
"I/O error", /* XCB_CONN_ERROR */
@ -557,7 +557,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
, m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY"))
, m_nativeInterface(nativeInterface)
{
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
Display *dpy = XOpenDisplay(m_displayName.constData());
if (dpy) {
m_primaryScreenNumber = DefaultScreen(dpy);
@ -569,7 +569,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
}
#else
m_connection = xcb_connect(m_displayName.constData(), &m_primaryScreenNumber);
#endif //XCB_USE_XLIB
#endif // QT_CONFIG(xcb_xlib)
if (Q_UNLIKELY(!m_connection || xcb_connection_has_error(m_connection)))
qFatal("QXcbConnection: Could not connect to display %s", m_displayName.constData());
@ -685,7 +685,7 @@ QXcbConnection::~QXcbConnection()
delete m_glIntegration;
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
XCloseDisplay(static_cast<Display *>(m_xlib_display));
#else
xcb_disconnect(xcb_connection());
@ -1551,7 +1551,7 @@ xcb_window_t QXcbConnection::clientLeader()
return m_clientLeader;
}
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
void *QXcbConnection::xlib_display() const
{
return m_xlib_display;

View File

@ -421,7 +421,7 @@ public:
bool hasDefaultVisualId() const { return m_defaultVisualId != UINT_MAX; }
xcb_visualid_t defaultVisualId() const { return m_defaultVisualId; }
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
void *xlib_display() const;
void *createVisualInfoForDefaultVisualId() const;
#endif
@ -632,7 +632,7 @@ private:
QScopedPointer<QXcbWMSupport> m_wmSupport;
QXcbNativeInterface *m_nativeInterface = nullptr;
#if defined(XCB_USE_XLIB)
#if QT_CONFIG(xcb_xlib)
void *m_xlib_display = nullptr;
#endif
QXcbEventReader *m_reader = nullptr;

View File

@ -60,7 +60,7 @@ typedef char *(*PtrXcursorLibraryGetTheme)(void *);
typedef int (*PtrXcursorLibrarySetTheme)(void *, const char *);
typedef int (*PtrXcursorLibraryGetDefaultSize)(void *);
#if defined(XCB_USE_XLIB) && QT_CONFIG(library)
#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
#include <X11/Xlib.h>
enum {
XCursorShape = CursorShape
@ -308,7 +308,7 @@ QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen)
const char *cursorStr = "cursor";
xcb_open_font(xcb_connection(), cursorFont, strlen(cursorStr), cursorStr);
#if defined(XCB_USE_XLIB) && QT_CONFIG(library)
#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
static bool function_ptrs_not_initialized = true;
if (function_ptrs_not_initialized) {
QLibrary xcursorLib(QLatin1String("Xcursor"), 1);
@ -509,7 +509,7 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape)
return cursor;
}
#if defined(XCB_USE_XLIB) && QT_CONFIG(library)
#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
bool updateCursorTheme(void *dpy, const QByteArray &theme) {
if (!ptrXcursorLibraryGetTheme
|| !ptrXcursorLibrarySetTheme)
@ -553,7 +553,7 @@ static xcb_cursor_t loadCursor(void *dpy, int cshape)
}
return cursor;
}
#endif // XCB_USE_XLIB / QT_CONFIG(library)
#endif // QT_CONFIG(xcb_xlib) / QT_CONFIG(library)
xcb_cursor_t QXcbCursor::createFontCursor(int cshape)
{
@ -562,7 +562,7 @@ xcb_cursor_t QXcbCursor::createFontCursor(int cshape)
xcb_cursor_t cursor = XCB_NONE;
// Try Xcursor first
#if defined(XCB_USE_XLIB) && QT_CONFIG(library)
#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
if (cshape >= 0 && cshape <= Qt::LastCursor) {
void *dpy = connection()->xlib_display();
// special case for non-standard dnd-* cursors

View File

@ -101,7 +101,7 @@ private:
#ifndef QT_NO_CURSOR
CursorHash m_cursorHash;
#endif
#if defined(XCB_USE_XLIB) && QT_CONFIG(library)
#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library)
static void cursorThemePropertyChanged(QXcbVirtualDesktop *screen,
const QByteArray &name,
const QVariant &property,

View File

@ -63,7 +63,7 @@
#include <QtGui/private/qguiapplication_p.h>
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
#include <X11/Xlib.h>
#endif
@ -123,7 +123,7 @@ QXcbIntegration::QXcbIntegration(const QStringList &parameters, int &argc, char
qApp->setAttribute(Qt::AA_CompressHighFrequencyEvents, true);
qRegisterMetaType<QXcbWindow*>();
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
XInitThreads();
#endif
m_nativeInterface.reset(new QXcbNativeInterface);

View File

@ -57,11 +57,7 @@
#include <QtPlatformHeaders/qxcbintegrationfunctions.h>
#include <QtPlatformHeaders/qxcbscreenfunctions.h>
#ifdef XCB_USE_XLIB
# include <X11/Xlib.h>
#else
# include <stdio.h>
#endif
#include <stdio.h>
#include <algorithm>
@ -210,7 +206,7 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resourceStr
const QXcbScreen *xcbScreen = static_cast<QXcbScreen *>(screen->handle());
switch (resourceType(lowerCaseResource)) {
case Display:
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
result = xcbScreen->connection()->xlib_display();
#endif
break;
@ -436,7 +432,7 @@ void *QXcbNativeInterface::rootWindow()
void *QXcbNativeInterface::display()
{
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
QXcbIntegration *integration = QXcbIntegration::instance();
QXcbConnection *defaultConnection = integration->defaultConnection();
if (defaultConnection)
@ -514,7 +510,7 @@ QXcbScreen *QXcbNativeInterface::qPlatformScreenForWindow(QWindow *window)
void *QXcbNativeInterface::displayForWindow(QWindow *window)
{
#if defined(XCB_USE_XLIB)
#if QT_CONFIG(xcb_xlib)
QXcbScreen *screen = qPlatformScreenForWindow(window);
return screen ? screen->connection()->xlib_display() : Q_NULLPTR;
#else

View File

@ -99,7 +99,7 @@
#include <QTextCodec>
#include <stdio.h>
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#endif
@ -251,7 +251,7 @@ static inline bool positionIncludesFrame(QWindow *w)
return qt_window_private(w)->positionPolicy == QWindowPrivate::WindowFrameInclusive;
}
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
{
#include <X11/Xatom.h>
@ -297,7 +297,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
#endif
return &tp;
}
#endif // XCB_USE_XLIB
#endif // QT_CONFIG(xcb_xlib)
// TODO move this into a utility function in QWindow or QGuiApplication
static QWindow *childWindowAt(QWindow *win, const QPoint &p)
@ -569,7 +569,7 @@ void QXcbWindow::create()
if (window()->flags() & Qt::WindowTransparentForInput)
setTransparentForMouseEvents(true);
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
// force sync to read outstanding requests - see QTBUG-29106
XSync(DISPLAY_FROM_XCB(platformScreen), false);
#endif
@ -1535,7 +1535,7 @@ void QXcbWindow::setWindowTitle(const QString &title)
ba.length(),
ba.constData()));
#ifdef XCB_USE_XLIB
#if QT_CONFIG(xcb_xlib)
XTextProperty *text = qstringToXTP(DISPLAY_FROM_XCB(this), title);
if (text)
XSetWMName(DISPLAY_FROM_XCB(this), m_window, text);

View File

@ -50,7 +50,6 @@ load(qt_build_paths)
DEFINES += QT_BUILD_XCB_PLUGIN
# needed by Xcursor ...
qtConfig(xcb-xlib) {
DEFINES += XCB_USE_XLIB
QMAKE_USE += xcb_xlib
qtConfig(xinput2) {