summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@digia.com>2014-09-10 16:31:32 +0200
committerJørgen Lind <jorgen.lind@theqtcompany.com>2014-12-20 06:09:01 +0100
commit8758f532ae6209bcf9447e27edc4fd412c0f173d (patch)
tree082d8e259d6de5a783ad0b2ddcf7d405ad550ba8 /src/plugins/platforms
parenteb2014382be588ea92e172d8b36385b8b86b64de (diff)
Make GLX and EGL dynamic dependencies for xcb
[ChangeLog][QPA][Xcb] GLX and EGL code paths are now dynamically resolved, making it possible for one build of a plugin to use both code paths. Default is to use the GLX code path if available. This can be overwritten by specifying QT_XCB_GL_INTEGRATION=xcb_egl as an evnironment variable. Enable qt.xcb.glintegration.debug to get debug log output of what integration is used Change-Id: Ia9fa95fcca3d901b91dadb8c98a695fea0ae3b1e Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/gl_integrations.pri13
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro9
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri38
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.cpp62
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h76
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp108
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.h61
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h67
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.cpp93
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.h72
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h104
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h57
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp108
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h83
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglmain.cpp62
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp120
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.h70
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp92
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.h75
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.json3
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro27
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp (renamed from src/plugins/platforms/xcb/qglxintegration.cpp)0
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h (renamed from src/plugins/platforms/xcb/qglxintegration.h)0
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp217
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.h72
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxmain.cpp62
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.cpp95
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.h67
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp68
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.h63
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.json3
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro31
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp179
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h29
-rw-r--r--src/plugins/platforms/xcb/qxcbexport.h (renamed from src/plugins/platforms/xcb/qxcbeglsurface.h)33
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp140
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp272
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h33
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h3
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp74
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h22
-rw-r--r--src/plugins/platforms/xcb/xcb-plugin.pro116
-rw-r--r--src/plugins/platforms/xcb/xcb.pro3
-rw-r--r--src/plugins/platforms/xcb/xcb_qpa_lib.pro111
45 files changed, 2497 insertions, 600 deletions
diff --git a/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pri b/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pri
new file mode 100644
index 0000000000..56bc126652
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pri
@@ -0,0 +1,13 @@
+INCLUDEPATH += $$PWD
+
+HEADERS += \
+ $$PWD/qxcbglintegration.h \
+ $$PWD/qxcbglintegrationfactory.h \
+ $$PWD/qxcbglintegrationplugin.h \
+ $$PWD/qxcbnativeinterfacehandler.h
+
+SOURCES += \
+ $$PWD/qxcbglintegrationfactory.cpp \
+ $$PWD/qxcbglintegration.cpp \
+ $$PWD/qxcbnativeinterfacehandler.cpp
+
diff --git a/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro b/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro
new file mode 100644
index 0000000000..29fddeabd4
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/gl_integrations.pro
@@ -0,0 +1,9 @@
+TEMPLATE = subdirs
+
+contains(QT_CONFIG, egl):contains(QT_CONFIG, egl_x11) {
+ SUBDIRS += xcb_egl
+}
+
+contains(QT_CONFIG, xcb-xlib):!contains(QT_CONFIG, opengles2) {
+ SUBDIRS += xcb_glx
+}
diff --git a/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri b/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri
new file mode 100644
index 0000000000..8c60268e0d
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/gl_integrations_plugin_base.pri
@@ -0,0 +1,38 @@
+QT += core-private gui-private platformsupport-private xcb_qpa_lib-private
+
+INCLUDEPATH += $$PWD
+INCLUDEPATH += $$PWD/../
+
+# needed by Xcursor ...
+contains(QT_CONFIG, xcb-xlib) {
+ DEFINES += XCB_USE_XLIB
+ contains(QT_CONFIG, xinput2) {
+ DEFINES += XCB_USE_XINPUT2
+ }
+}
+
+# to support custom cursors with depth > 1
+contains(QT_CONFIG, xcb-render) {
+ DEFINES += XCB_USE_RENDER
+}
+
+# build with session management support
+contains(QT_CONFIG, xcb-sm) {
+ DEFINES += XCB_USE_SM
+}
+
+DEFINES += $$QMAKE_DEFINES_XCB
+LIBS += $$QMAKE_LIBS_XCB
+QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB
+
+CONFIG += qpa/genericunixfontdatabase
+
+contains(QT_CONFIG, xcb-qt) {
+ DEFINES += XCB_USE_RENDER
+ XCB_DIR = ../../../3rdparty/xcb
+ INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude
+ LIBS += -lxcb -L$$OUT_PWD/xcb-static -lxcb-static
+} else {
+ LIBS += -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms
+ !contains(DEFINES, QT_NO_XKB):LIBS += -lxcb-xkb
+}
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.cpp
new file mode 100644
index 0000000000..d864ee1198
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(QT_XCB_GLINTEGRATION, "qt.xcb.glintegration")
+
+QXcbGlIntegration::QXcbGlIntegration()
+{
+}
+QXcbGlIntegration::~QXcbGlIntegration()
+{
+}
+
+bool QXcbGlIntegration::handleXcbEvent(xcb_generic_event_t *event, uint responseType)
+{
+ Q_UNUSED(event);
+ Q_UNUSED(responseType);
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h
new file mode 100644
index 0000000000..947ef15162
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegration.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBGLINTEGRATION_H
+
+#include "qxcbexport.h"
+#include "qxcbwindow.h"
+
+#include <QtCore/QLoggingCategory>
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformOffscreenSurface;
+class QOffscreenSurface;
+class QXcbNativeInterfaceHandler;
+
+Q_XCB_EXPORT Q_DECLARE_LOGGING_CATEGORY(QT_XCB_GLINTEGRATION)
+
+class Q_XCB_EXPORT QXcbGlIntegration
+{
+public:
+ QXcbGlIntegration();
+ virtual ~QXcbGlIntegration();
+ virtual bool initialize(QXcbConnection *connection) = 0;
+
+ virtual bool supportsThreadedOpenGL() const { return false; }
+ virtual bool handleXcbEvent(xcb_generic_event_t *event, uint responseType);
+
+ virtual QXcbWindow *createWindow(QWindow *window) const = 0;
+ virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const = 0;
+ virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const = 0;
+
+ virtual QXcbNativeInterfaceHandler *nativeInterfaceHandler() const { return Q_NULLPTR; }
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBGLINTEGRATION_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp
new file mode 100644
index 0000000000..c4546b990a
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglintegrationfactory.h"
+#include "qxcbglintegrationplugin.h"
+
+#include "qxcbglintegrationplugin.h"
+#include "private/qfactoryloader_p.h"
+#include "qguiapplication.h"
+#include "qdir.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_LIBRARY
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ (QXcbGlIntegrationFactoryInterface_iid, QLatin1String("/xcbglintegrations"), Qt::CaseInsensitive))
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
+ (QXcbGlIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+
+static inline QXcbGlIntegration *loadIntegration(QFactoryLoader *loader, const QString &key)
+{
+ const int index = loader->indexOf(key);
+ if (index != -1) {
+ if (QXcbGlIntegrationPlugin *factory = qobject_cast<QXcbGlIntegrationPlugin *>(loader->instance(index)))
+ if (QXcbGlIntegration *result = factory->create())
+ return result;
+ }
+ return Q_NULLPTR;
+}
+#endif // !QT_NO_LIBRARY
+
+QStringList QXcbGlIntegrationFactory::keys(const QString &pluginPath)
+{
+#ifndef QT_NO_LIBRARY
+ QStringList list;
+ if (!pluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(pluginPath);
+ list = directLoader()->keyMap().values();
+ if (!list.isEmpty()) {
+ const QString postFix = QStringLiteral(" (from ")
+ + QDir::toNativeSeparators(pluginPath)
+ + QLatin1Char(')');
+ const QStringList::iterator end = list.end();
+ for (QStringList::iterator it = list.begin(); it != end; ++it)
+ (*it).append(postFix);
+ }
+ }
+ list.append(loader()->keyMap().values());
+ return list;
+#else
+ return QStringList();
+#endif
+}
+
+QXcbGlIntegration *QXcbGlIntegrationFactory::create(const QString &platform, const QString &pluginPath)
+{
+#ifndef QT_NO_LIBRARY
+ // Try loading the plugin from platformPluginPath first:
+ if (!pluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(pluginPath);
+ if (QXcbGlIntegration *ret = loadIntegration(directLoader(), platform))
+ return ret;
+ }
+ if (QXcbGlIntegration *ret = loadIntegration(loader(), platform))
+ return ret;
+#endif
+ return Q_NULLPTR;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.h b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.h
new file mode 100644
index 0000000000..d1fb91dee8
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationfactory.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBGLINTEGRATIONFACTORY_H
+#define QXCBGLINTEGRATIONFACTORY_H
+
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_NAMESPACE
+
+class QXcbGlIntegration;
+
+class QXcbGlIntegrationFactory
+{
+public:
+ static QStringList keys(const QString &pluginPath = QString());
+ static QXcbGlIntegration *create(const QString &name, const QString &platformPluginPath = QString());
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBGLINTEGRATIONFACTORY_H
+
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h
new file mode 100644
index 0000000000..ef630a4fbe
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbglintegrationplugin.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBGLINTEGRATIONPLUGIN_H
+#define QXCBGLINTEGRATIONPLUGIN_H
+
+#include "qxcbexport.h"
+#include <QtCore/qplugin.h>
+#include <QtCore/qfactoryinterface.h>
+
+QT_BEGIN_NAMESPACE
+
+#define QXcbGlIntegrationFactoryInterface_iid "org.qt-project.Qt.QPA.Xcb.QXcbGlIntegrationFactoryInterface.5.5"
+
+class QXcbGlIntegration;
+
+class Q_XCB_EXPORT QXcbGlIntegrationPlugin : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QXcbGlIntegrationPlugin(QObject *parent = 0)
+ : QObject(parent)
+ { }
+
+ virtual QXcbGlIntegration *create() = 0;
+};
+QT_END_NAMESPACE
+
+#endif //QXCBGLINTEGRATIONPLUGIN_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.cpp b/src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.cpp
new file mode 100644
index 0000000000..78c6fe0ccb
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbnativeinterfacehandler.h"
+
+#include "qxcbnativeinterface.h"
+
+QT_BEGIN_NAMESPACE
+
+QXcbNativeInterfaceHandler::QXcbNativeInterfaceHandler(QXcbNativeInterface *nativeInterface)
+{
+ nativeInterface->addHandler(this);
+}
+QXcbNativeInterfaceHandler::~QXcbNativeInterfaceHandler()
+{
+ m_native_interface->removeHandler(this);
+}
+
+QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterfaceHandler::nativeResourceFunctionForIntegration(const QByteArray &resource) const
+{
+ Q_UNUSED(resource);
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterfaceHandler::nativeResourceFunctionForContext(const QByteArray &resource) const
+{
+ Q_UNUSED(resource);
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterfaceHandler::nativeResourceFunctionForScreen(const QByteArray &resource) const
+{
+ Q_UNUSED(resource);
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterfaceHandler::nativeResourceFunctionForWindow(const QByteArray &resource) const
+{
+ Q_UNUSED(resource);
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForBackingStoreFunction QXcbNativeInterfaceHandler::nativeResourceFunctionForBackingStore(const QByteArray &resource) const
+{
+ Q_UNUSED(resource);
+ return Q_NULLPTR;
+}
+
+QFunctionPointer QXcbNativeInterfaceHandler::platformFunction(const QByteArray &function) const
+{
+ Q_UNUSED(function);
+ return Q_NULLPTR;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.h b/src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.h
new file mode 100644
index 0000000000..3c239c443d
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/qxcbnativeinterfacehandler.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBNATIVEINTERFACEHANDLER_H
+#define QXCBNATIVEINTERFACEHANDLER_H
+
+#include <QtCore/QByteArray>
+#include <QtGui/qpa/qplatformnativeinterface.h>
+
+#include "qxcbexport.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbNativeInterface;
+class Q_XCB_EXPORT QXcbNativeInterfaceHandler
+{
+public:
+ QXcbNativeInterfaceHandler(QXcbNativeInterface *nativeInterface);
+ virtual ~QXcbNativeInterfaceHandler();
+
+ virtual QPlatformNativeInterface::NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) const;
+ virtual QPlatformNativeInterface::NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) const;
+ virtual QPlatformNativeInterface::NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource) const;
+ virtual QPlatformNativeInterface::NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) const;
+ virtual QPlatformNativeInterface::NativeResourceForBackingStoreFunction nativeResourceFunctionForBackingStore(const QByteArray &resource) const;
+
+ virtual QFunctionPointer platformFunction(const QByteArray &function) const;
+protected:
+ QXcbNativeInterface *m_native_interface;
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBNATIVEINTERFACEHANDLER_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h
new file mode 100644
index 0000000000..0dce728019
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBEGLCONTEXT_H
+#define QXCBEGLCONTEXT_H
+
+#include "qxcbeglwindow.h"
+#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
+#include <QtPlatformSupport/private/qeglpbuffer_p.h>
+#include <QtPlatformHeaders/QEGLNativeContext>
+
+QT_BEGIN_NAMESPACE
+
+//####todo remove the noops (looks like their where there in the initial commit)
+class QXcbEglContext : public QEGLPlatformContext
+{
+public:
+ QXcbEglContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share,
+ EGLDisplay display, QXcbConnection *c, const QVariant &nativeHandle)
+ : QEGLPlatformContext(glFormat, share, display, 0, nativeHandle)
+ , m_connection(c)
+ {
+ Q_XCB_NOOP(m_connection);
+ }
+
+ void swapBuffers(QPlatformSurface *surface)
+ {
+ Q_XCB_NOOP(m_connection);
+ QEGLPlatformContext::swapBuffers(surface);
+ Q_XCB_NOOP(m_connection);
+ }
+
+ bool makeCurrent(QPlatformSurface *surface)
+ {
+ Q_XCB_NOOP(m_connection);
+ bool ret = QEGLPlatformContext::makeCurrent(surface);
+ Q_XCB_NOOP(m_connection);
+ return ret;
+ }
+
+ void doneCurrent()
+ {
+ Q_XCB_NOOP(m_connection);
+ QEGLPlatformContext::doneCurrent();
+ Q_XCB_NOOP(m_connection);
+ }
+
+ EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)
+ {
+ if (surface->surface()->surfaceClass() == QSurface::Window)
+ return static_cast<QXcbEglWindow *>(surface)->eglSurface();
+ else
+ return static_cast<QEGLPbuffer *>(surface)->pbuffer();
+ }
+
+ QVariant nativeHandle() const {
+ return QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(eglContext(), eglDisplay()));
+ }
+
+private:
+ QXcbConnection *m_connection;
+};
+
+QT_END_NAMESPACE
+#endif //QXCBEGLCONTEXT_H
+
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h
new file mode 100644
index 0000000000..bcde872423
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglinclude.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBINCLUDE_H
+#define QXCBINCLUDE_H
+
+#include <QtGui/QPalette>
+#include <QtCore/QTextStream>
+#include <QtGui/private/qmath_p.h>
+#include <QtGui/private/qcssparser_p.h>
+#include <QtGui/private/qtextengine_p.h>
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+QT_END_NAMESPACE
+
+#endif //QXCBINCLUDE_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp
new file mode 100644
index 0000000000..f5fc2e74c4
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbeglintegration.h"
+
+#include "qxcbeglcontext.h"
+
+#include <QtGui/QOffscreenSurface>
+
+#include "qxcbeglnativeinterfacehandler.h"
+
+QT_BEGIN_NAMESPACE
+
+QXcbEglIntegration::QXcbEglIntegration()
+ : m_connection(Q_NULLPTR)
+ , m_egl_display(EGL_NO_DISPLAY)
+{
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb EGL gl-integration created";
+}
+
+QXcbEglIntegration::~QXcbEglIntegration()
+{
+ if (m_egl_display != EGL_NO_DISPLAY)
+ eglTerminate(m_egl_display);
+}
+
+bool QXcbEglIntegration::initialize(QXcbConnection *connection)
+{
+ m_connection = connection;
+
+ Display *dpy = (Display *)m_connection->xlib_display();
+ m_egl_display = eglGetDisplay(dpy);
+
+ EGLint major, minor;
+ bool success = eglInitialize(m_egl_display, &major, &minor);
+ if (!success) {
+ m_egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb EGL gl-integration retrying with display" << m_egl_display;
+ success = eglInitialize(m_egl_display, &major, &minor);
+ }
+
+ m_native_interface_handler.reset(new QXcbEglNativeInterfaceHandler(connection->nativeInterface()));
+
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb EGL gl-integration successfully initialized";
+ return success;
+}
+
+QXcbWindow *QXcbEglIntegration::createWindow(QWindow *window) const
+{
+ return new QXcbEglWindow(window, const_cast<QXcbEglIntegration *>(this));
+}
+
+QPlatformOpenGLContext *QXcbEglIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+{
+ QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+ QXcbEglContext *platformContext = new QXcbEglContext(context->format(),
+ context->shareHandle(),
+ eglDisplay(),
+ screen->connection(),
+ context->nativeHandle());
+ context->setNativeHandle(platformContext->nativeHandle());
+ return platformContext;
+}
+
+QPlatformOffscreenSurface *QXcbEglIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
+{
+ return new QEGLPbuffer(eglDisplay(), surface->requestedFormat(), surface);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h
new file mode 100644
index 0000000000..9f42051804
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBEGLINTEGRATION_H
+#define QXCBEGLINTEGRATION_H
+
+#include "qxcbglintegration.h"
+
+#include "qxcbeglwindow.h"
+
+#include <QtGui/QOpenGLContext>
+#include <QtGui/qpa/qplatformscreen.h>
+#include <QtGui/QScreen>
+
+#include "qxcbscreen.h"
+
+#include "qxcbeglinclude.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbEglNativeInterfaceHandler;
+
+class QXcbEglIntegration : public QXcbGlIntegration
+{
+public:
+ QXcbEglIntegration();
+ ~QXcbEglIntegration();
+
+ bool initialize(QXcbConnection *connection) Q_DECL_OVERRIDE;
+
+ QXcbWindow *createWindow(QWindow *window) const Q_DECL_OVERRIDE;
+ QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE;
+ QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE;
+
+ EGLDisplay eglDisplay() const { return m_egl_display; }
+ void *xlib_display() const { return m_connection->xlib_display(); }
+private:
+ QXcbConnection *m_connection;
+ EGLDisplay m_egl_display;
+
+ QScopedPointer<QXcbEglNativeInterfaceHandler> m_native_interface_handler;
+};
+
+QT_END_NAMESPACE
+#endif //QXCBEGLINTEGRATION_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglmain.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglmain.cpp
new file mode 100644
index 0000000000..9feb8f31ca
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglmain.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglintegrationplugin.h"
+
+#include "qxcbeglintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbEglIntegrationPlugin : public QXcbGlIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QXcbGlIntegrationFactoryInterface_iid FILE "xcb_egl.json")
+public:
+ QXcbGlIntegration *create()
+ {
+ return new QXcbEglIntegration();
+ }
+
+};
+
+QT_END_NAMESPACE
+
+#include "qxcbeglmain.moc"
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp
new file mode 100644
index 0000000000..3037d1e331
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbeglnativeinterfacehandler.h"
+
+#include "qxcbeglwindow.h"
+#include "qxcbeglintegration.h"
+#include "qxcbeglcontext.h"
+
+QT_BEGIN_NAMESPACE
+
+static int resourceType(const QByteArray &key)
+{
+ static const QByteArray names[] = { // match QXcbEglNativeInterfaceHandler::ResourceType
+ QByteArrayLiteral("egldisplay"),
+ QByteArrayLiteral("eglcontext"),
+ QByteArrayLiteral("eglconfig")
+ };
+ for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
+ if (key == names[i])
+ return i;
+ }
+
+ if (key == QByteArrayLiteral("get_egl_context"))
+ return QXcbEglNativeInterfaceHandler::EglContext;
+
+ return sizeof(names) / sizeof(names[0]);
+}
+
+QXcbEglNativeInterfaceHandler::QXcbEglNativeInterfaceHandler(QXcbNativeInterface *nativeInterface)
+ : QXcbNativeInterfaceHandler(nativeInterface)
+{
+}
+
+QPlatformNativeInterface::NativeResourceForContextFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForContext(const QByteArray &resource) const
+{
+ switch (resourceType(resource)) {
+ case EglContext:
+ return eglContextForContext;
+ case EglConfig:
+ return eglConfigForContext;
+ default:
+ break;
+ }
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForWindowFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForWindow(const QByteArray &resource) const
+{
+ switch (resourceType(resource)) {
+ case EglDisplay:
+ return eglDisplayForWindow;
+ default:
+ break;
+ }
+ return Q_NULLPTR;
+}
+
+void *QXcbEglNativeInterfaceHandler::eglDisplayForWindow(QWindow *window)
+{
+ Q_ASSERT(window);
+ Q_ASSERT(window->handle());
+ if (window->supportsOpenGL())
+ return static_cast<QXcbEglWindow *>(window->handle())->glIntegration()->eglDisplay();
+ return Q_NULLPTR;
+}
+
+void *QXcbEglNativeInterfaceHandler::eglContextForContext(QOpenGLContext *context)
+{
+ Q_ASSERT(context);
+ Q_ASSERT(context->handle());
+ return static_cast<QXcbEglContext *>(context->handle())->eglContext();
+}
+
+void *QXcbEglNativeInterfaceHandler::eglConfigForContext(QOpenGLContext *context)
+{
+ Q_ASSERT(context);
+ Q_ASSERT(context->handle());
+ return static_cast<QXcbEglContext *>(context->handle())->eglConfig();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.h
new file mode 100644
index 0000000000..0485a87558
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBEGLNATIVEINTERFACEHANDLER_H
+#define QXCBEGLNATIVEINTERFACEHANDLER_H
+
+#include "qxcbnativeinterfacehandler.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbEglNativeInterfaceHandler : public QXcbNativeInterfaceHandler
+{
+public:
+ enum ResourceType {
+ EglDisplay,
+ EglContext,
+ EglConfig
+ };
+
+ QXcbEglNativeInterfaceHandler(QXcbNativeInterface *nativeInterface);
+
+ QPlatformNativeInterface::NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) const Q_DECL_OVERRIDE;
+ QPlatformNativeInterface::NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) const Q_DECL_OVERRIDE;
+private:
+ static void *eglDisplayForWindow(QWindow *window);
+ static void *eglContextForContext(QOpenGLContext *context);
+ static void *eglConfigForContext(QOpenGLContext *context);
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBEGLNATIVEINTERFACEHANDLER_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
new file mode 100644
index 0000000000..61dd8d5069
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbeglwindow.h"
+
+#include "qxcbeglintegration.h"
+
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtPlatformSupport/private/qxlibeglintegration_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QXcbEglWindow::QXcbEglWindow(QWindow *window, QXcbEglIntegration *glIntegration)
+ : QXcbWindow(window)
+ , m_glIntegration(glIntegration)
+ , m_config(Q_NULLPTR)
+ , m_surface(EGL_NO_SURFACE)
+{
+}
+
+QXcbEglWindow::~QXcbEglWindow()
+{
+ eglDestroySurface(m_glIntegration->eglDisplay(), m_surface);
+}
+
+void QXcbEglWindow::resolveFormat()
+{
+ m_config = q_configFromGLFormat(m_glIntegration->eglDisplay(), window()->requestedFormat(), true);
+ m_format = q_glFormatFromConfig(m_glIntegration->eglDisplay(), m_config, m_format);
+}
+
+void *QXcbEglWindow::createVisual()
+{
+ Display *xdpy = static_cast<Display *>(m_glIntegration->xlib_display());
+ VisualID id = QXlibEglIntegration::getCompatibleVisualId(xdpy, m_glIntegration->eglDisplay(), m_config);
+
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = id;
+
+ XVisualInfo *visualInfo;
+ int matchingCount = 0;
+ visualInfo = XGetVisualInfo(xdpy, VisualIDMask, &visualInfoTemplate, &matchingCount);
+ return visualInfo;
+}
+
+void QXcbEglWindow::create()
+{
+ QXcbWindow::create();
+
+ m_surface = eglCreateWindowSurface(m_glIntegration->eglDisplay(), m_config, m_window, 0);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.h
new file mode 100644
index 0000000000..7d1a4c8e37
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBEGLWINDOW_H
+#define QXCBEGLWINDOW_H
+
+#include "qxcbwindow.h"
+
+#include "qxcbeglinclude.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbEglIntegration;
+
+class QXcbEglWindow : public QXcbWindow
+{
+public:
+ QXcbEglWindow(QWindow *window, QXcbEglIntegration *glIntegration);
+ ~QXcbEglWindow();
+
+ EGLSurface eglSurface() const { return m_surface; }
+
+ QXcbEglIntegration *glIntegration() const { return m_glIntegration; }
+
+protected:
+ void create() Q_DECL_OVERRIDE;
+ void resolveFormat() Q_DECL_OVERRIDE;
+ void *createVisual() Q_DECL_OVERRIDE;
+
+private:
+ QXcbEglIntegration *m_glIntegration;
+ EGLConfig m_config;
+ EGLSurface m_surface;
+};
+
+QT_END_NAMESPACE
+#endif //QXCBEGLWINDOW_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.json b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.json
new file mode 100644
index 0000000000..6d6785691d
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "xcb_egl" ]
+}
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro
new file mode 100644
index 0000000000..082c22821a
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb_egl.pro
@@ -0,0 +1,27 @@
+TARGET = qxcb-egl-integration
+
+PLUGIN_CLASS_NAME = QXcbEglIntegrationPlugin
+PLUGIN_TYPE = xcbglintegrations
+
+load(qt_plugin)
+
+include(../gl_integrations_plugin_base.pri)
+
+CONFIG += egl
+
+DEFINES += SUPPORT_X11
+#should be removed from sources
+DEFINES += XCB_USE_EGL XCB_USE_XLIB
+
+
+HEADERS += \
+ qxcbeglcontext.h \
+ qxcbeglintegration.h \
+ qxcbeglwindow.h \
+ qxcbeglnativeinterfacehandler.h
+
+SOURCES += \
+ qxcbeglintegration.cpp \
+ qxcbeglwindow.cpp \
+ qxcbeglmain.cpp \
+ qxcbeglnativeinterfacehandler.cpp
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
index c0be836bce..c0be836bce 100644
--- a/src/plugins/platforms/xcb/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h
index 73a17d69b4..73a17d69b4 100644
--- a/src/plugins/platforms/xcb/qglxintegration.h
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp
new file mode 100644
index 0000000000..a4e603f599
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp
@@ -0,0 +1,217 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglxintegration.h"
+
+#if defined(XCB_HAS_XCB_GLX)
+#include <xcb/glx.h>
+#endif
+
+#include "qxcbnativeinterface.h"
+#include "qxcbglxwindow.h"
+#include "qxcbscreen.h"
+#include "qglxintegration.h"
+
+#include <QtGui/QOpenGLContext>
+
+#include "qxcbglxnativeinterfacehandler.h"
+
+#include <X11/Xlibint.h>
+
+QT_BEGIN_NAMESPACE
+
+#if defined(XCB_HAS_XCB_GLX) && XCB_GLX_MAJOR_VERSION == 1 && XCB_GLX_MINOR_VERSION < 4
+
+#define XCB_GLX_BUFFER_SWAP_COMPLETE 1
+
+typedef struct xcb_glx_buffer_swap_complete_event_t {
+ uint8_t response_type;
+ uint8_t pad0;
+ uint16_t sequence;
+ uint16_t event_type;
+ uint8_t pad1[2];
+ xcb_glx_drawable_t drawable;
+ uint32_t ust_hi;
+ uint32_t ust_lo;
+ uint32_t msc_hi;
+ uint32_t msc_lo;
+ uint32_t sbc;
+} xcb_glx_buffer_swap_complete_event_t;
+#endif
+
+#if defined(XCB_USE_XLIB) && defined(XCB_USE_GLX)
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable; /* drawable on which event was requested in event mask */
+ int event_type;
+ int64_t ust;
+ int64_t msc;
+ int64_t sbc;
+} QGLXBufferSwapComplete;
+#endif
+
+QXcbGlxIntegration::QXcbGlxIntegration()
+ : m_connection(Q_NULLPTR)
+ , m_glx_first_event(0)
+{
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb GLX gl-integration created";
+}
+
+QXcbGlxIntegration::~QXcbGlxIntegration()
+{
+}
+
+bool QXcbGlxIntegration::initialize(QXcbConnection *connection)
+{
+ m_connection = connection;
+#ifdef XCB_HAS_XCB_GLX
+
+ const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection->xcb_connection(), &xcb_glx_id);
+ if (!reply || !reply->present)
+ return false;
+
+ m_glx_first_event = reply->first_event;
+
+ xcb_generic_error_t *error = 0;
+ xcb_glx_query_version_cookie_t xglx_query_cookie = xcb_glx_query_version(m_connection->xcb_connection(),
+ XCB_GLX_MAJOR_VERSION,
+ XCB_GLX_MINOR_VERSION);
+ xcb_glx_query_version_reply_t *xglx_query = xcb_glx_query_version_reply(m_connection->xcb_connection(),
+ xglx_query_cookie, &error);
+ if (!xglx_query || error) {
+ qCWarning(QT_XCB_GLINTEGRATION) << "QXcbConnection: Failed to initialize GLX";
+ free(error);
+ return false;
+ }
+ free(xglx_query);
+#endif
+
+ m_native_interface_handler.reset(new QXcbGlxNativeInterfaceHandler(connection->nativeInterface()));
+
+ qCDebug(QT_XCB_GLINTEGRATION) << "Xcb GLX gl-integration successfully initialized";
+ return true;
+}
+
+bool QXcbGlxIntegration::handleXcbEvent(xcb_generic_event_t *event, uint responseType)
+{
+ bool handled = false;
+ // Check if a custom XEvent constructor was registered in xlib for this event type, and call it discarding the constructed XEvent if any.
+ // XESetWireToEvent might be used by libraries to intercept messages from the X server e.g. the OpenGL lib waiting for DRI2 events.
+ Display *xdisplay = static_cast<Display *>(m_connection->xlib_display());
+ XLockDisplay(xdisplay);
+ bool locked = true;
+ Bool (*proc)(Display*, XEvent*, xEvent*) = XESetWireToEvent(xdisplay, responseType, 0);
+ if (proc) {
+ XESetWireToEvent(xdisplay, responseType, proc);
+ XEvent dummy;
+ event->sequence = LastKnownRequestProcessed(xdisplay);
+ if (proc(xdisplay, &dummy, (xEvent*)event)) {
+#ifdef XCB_HAS_XCB_GLX
+ // DRI2 clients don't receive GLXBufferSwapComplete events on the wire.
+ // Instead the GLX event is synthesized from the DRI2BufferSwapComplete event
+ // by DRI2WireToEvent(). For an application to be able to see the event
+ // we have to convert it to an xcb_glx_buffer_swap_complete_event_t and
+ // pass it to the native event filter.
+ const uint swap_complete = m_glx_first_event + XCB_GLX_BUFFER_SWAP_COMPLETE;
+ QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance();
+ if (dispatcher && uint(dummy.type) == swap_complete && responseType != swap_complete) {
+ QGLXBufferSwapComplete *xev = reinterpret_cast<QGLXBufferSwapComplete *>(&dummy);
+ xcb_glx_buffer_swap_complete_event_t ev;
+ memset(&ev, 0, sizeof(xcb_glx_buffer_swap_complete_event_t));
+ ev.response_type = xev->type;
+ ev.sequence = xev->serial;
+ ev.event_type = xev->event_type;
+ ev.drawable = xev->drawable;
+ ev.ust_hi = xev->ust >> 32;
+ ev.ust_lo = xev->ust & 0xffffffff;
+ ev.msc_hi = xev->msc >> 32;
+ ev.msc_lo = xev->msc & 0xffffffff;
+ ev.sbc = xev->sbc & 0xffffffff;
+ // Unlock the display before calling the native event filter
+ XUnlockDisplay(xdisplay);
+ locked = false;
+ QByteArray genericEventFilterType = m_connection->nativeInterface()->genericEventFilterType();
+ long result = 0;
+ handled = dispatcher->filterNativeEvent(genericEventFilterType, &ev, &result);
+ }
+#endif
+ }
+ }
+ if (locked)
+ XUnlockDisplay(xdisplay);
+ return handled;
+}
+
+QXcbWindow *QXcbGlxIntegration::createWindow(QWindow *window) const
+{
+ return new QXcbGlxWindow(window);
+}
+
+QPlatformOpenGLContext *QXcbGlxIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+{
+ QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+ QGLXContext *platformContext = new QGLXContext(screen, context->format(),
+ context->shareHandle(), context->nativeHandle());
+ context->setNativeHandle(platformContext->nativeHandle());
+ return platformContext;
+}
+
+QPlatformOffscreenSurface *QXcbGlxIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
+{
+ static bool vendorChecked = false;
+ static bool glxPbufferUsable = true;
+ if (!vendorChecked) {
+ vendorChecked = true;
+ const char *glxvendor = glXGetClientString(glXGetCurrentDisplay(), GLX_VENDOR);
+ if (glxvendor && !strcmp(glxvendor, "ATI"))
+ glxPbufferUsable = false;
+ }
+ if (glxPbufferUsable)
+ return new QGLXPbuffer(surface);
+ else
+ return 0; // trigger fallback to hidden QWindow
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.h
new file mode 100644
index 0000000000..2ef40f9ab6
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBGLXINTEGRATION_H
+#define QXCBGLXINTEGRATION_H
+
+#include "qxcbglintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbNativeInterfaceHandler;
+
+class QXcbGlxIntegration : public QXcbGlIntegration
+{
+public:
+ QXcbGlxIntegration();
+ ~QXcbGlxIntegration();
+
+ bool initialize(QXcbConnection *connection) Q_DECL_OVERRIDE;
+ bool handleXcbEvent(xcb_generic_event_t *event, uint responseType) Q_DECL_OVERRIDE;
+
+ QXcbWindow *createWindow(QWindow *window) const Q_DECL_OVERRIDE;
+ QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE;
+ QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE;
+private:
+ QXcbConnection *m_connection;
+ uint32_t m_glx_first_event;
+
+ QScopedPointer<QXcbNativeInterfaceHandler> m_native_interface_handler;
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBGLXINTEGRATION_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxmain.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxmain.cpp
new file mode 100644
index 0000000000..93bb76f92f
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxmain.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglintegrationplugin.h"
+
+#include "qxcbglxintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbGlxIntegrationPlugin : public QXcbGlIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QXcbGlIntegrationFactoryInterface_iid FILE "xcb_glx.json")
+public:
+ QXcbGlIntegration *create()
+ {
+ return new QXcbGlxIntegration();
+ }
+
+};
+
+QT_END_NAMESPACE
+
+#include "qxcbglxmain.moc"
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.cpp
new file mode 100644
index 0000000000..6cdd4101e0
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglxnativeinterfacehandler.h"
+
+#include "qglxintegration.h"
+#include <QtGui/QOpenGLContext>
+QT_BEGIN_NAMESPACE
+
+static int resourceType(const QByteArray &key)
+{
+ static const QByteArray names[] = { // match QXcbGlxNativeInterfaceHandler::ResourceType
+ QByteArrayLiteral("glxconfig"),
+ QByteArrayLiteral("glxcontext"),
+ };
+ for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
+ if (key == names[i])
+ return i;
+ }
+
+ return sizeof(names) / sizeof(names[0]);
+}
+
+QXcbGlxNativeInterfaceHandler::QXcbGlxNativeInterfaceHandler(QXcbNativeInterface *nativeInterface)
+ : QXcbNativeInterfaceHandler(nativeInterface)
+{
+}
+
+QPlatformNativeInterface::NativeResourceForContextFunction QXcbGlxNativeInterfaceHandler::nativeResourceFunctionForContext(const QByteArray &resource) const
+{
+ switch (resourceType(resource)) {
+ case GLXConfig:
+ return glxConfigForContext;
+ case GLXContext:
+ return glxContextForContext;
+ default:
+ break;
+ }
+ return Q_NULLPTR;
+}
+
+void *QXcbGlxNativeInterfaceHandler::glxContextForContext(QOpenGLContext *context)
+{
+ Q_ASSERT(context);
+ QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle());
+ return glxPlatformContext->glxContext();
+}
+
+void *QXcbGlxNativeInterfaceHandler::glxConfigForContext(QOpenGLContext *context)
+{
+ Q_ASSERT(context);
+ QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle());
+ return glxPlatformContext->glxConfig();
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.h
new file mode 100644
index 0000000000..e9df28ea39
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxnativeinterfacehandler.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBGLXNATIVEINTERFACEHANDLER_H
+#define QXCBGLXNATIVEINTERFACEHANDLER_H
+
+#include "qxcbnativeinterfacehandler.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbGlxNativeInterfaceHandler : public QXcbNativeInterfaceHandler
+{
+public:
+ enum ResourceType {
+ GLXConfig,
+ GLXContext,
+ };
+
+ QXcbGlxNativeInterfaceHandler(QXcbNativeInterface *nativeInterface);
+ QPlatformNativeInterface::NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) const Q_DECL_OVERRIDE;
+
+private:
+ static void *glxContextForContext(QOpenGLContext *context);
+ static void *glxConfigForContext(QOpenGLContext *context);
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBGLXNATIVEINTERFACEHANDLER_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp
new file mode 100644
index 0000000000..8aabde8129
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbglxwindow.h"
+
+#include "qxcbscreen.h"
+#include <QtPlatformSupport/private/qglxconvenience_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QXcbGlxWindow::QXcbGlxWindow(QWindow *window)
+ : QXcbWindow(window)
+{
+}
+
+QXcbGlxWindow::~QXcbGlxWindow()
+{
+}
+
+void QXcbGlxWindow::resolveFormat()
+{
+ m_format = window()->requestedFormat(); //qglx_findVisualInfo sets the resovled format
+}
+
+void *QXcbGlxWindow::createVisual()
+{
+ return qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen), m_screen->screenNumber(), &m_format);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.h b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.h
new file mode 100644
index 0000000000..bb7cd7bef2
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxwindow.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBGLXWINDOW_H
+#define QXCBGLXWINDOW_H
+
+#include "qxcbglxintegration.h"
+#include "qxcbwindow.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbGlxWindow : public QXcbWindow
+{
+public:
+ QXcbGlxWindow(QWindow *window);
+ ~QXcbGlxWindow();
+
+protected:
+ void resolveFormat() Q_DECL_OVERRIDE;
+ void *createVisual() Q_DECL_OVERRIDE;
+};
+
+QT_END_NAMESPACE
+
+#endif //QXCBGLXWINDOW_H
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.json b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.json
new file mode 100644
index 0000000000..1e2641ae7c
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "xcb_glx" ]
+}
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro
new file mode 100644
index 0000000000..57cd81ec3b
--- /dev/null
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro
@@ -0,0 +1,31 @@
+TARGET = qxcb-glx-integration
+
+PLUGIN_CLASS_NAME = QXcbGlxIntegrationPlugin
+PLUGIN_TYPE = xcbglintegrations
+
+load(qt_plugin)
+
+include(../gl_integrations_plugin_base.pri)
+
+#should be removed from the sources
+DEFINES += XCB_USE_GLX XCB_USE_XLIB
+
+LIBS += -lxcb
+
+contains(QT_CONFIG, xcb-glx) {
+ DEFINES += XCB_HAS_XCB_GLX
+ LIBS += -lxcb-glx
+}
+
+HEADERS += \
+ qxcbglxintegration.h \
+ qxcbglxwindow.h \
+ qglxintegration.h \
+ qxcbglxnativeinterfacehandler.h
+
+SOURCES += \
+ qxcbglxmain.cpp \
+ qxcbglxintegration.cpp \
+ qxcbglxwindow.cpp \
+ qglxintegration.cpp \
+ qxcbglxnativeinterfacehandler.cpp
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index ea13502a21..2e429939ba 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -44,6 +44,8 @@
#include "qxcbnativeinterface.h"
#include "qxcbintegration.h"
#include "qxcbsystemtraytracker.h"
+#include "qxcbglintegrationfactory.h"
+#include "qxcbglintegration.h"
#include <QSocketNotifier>
#include <QAbstractEventDispatcher>
@@ -74,14 +76,6 @@
#include <xcb/render.h>
#endif
-#if defined(XCB_HAS_XCB_GLX)
-#include <xcb/glx.h>
-#endif
-
-#ifdef XCB_USE_EGL //don't pull in eglext prototypes
-#include <EGL/egl.h>
-#endif
-
QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpaXInput, "qt.qpa.input")
@@ -121,39 +115,6 @@ static int ioErrorHandler(Display *dpy)
}
#endif
-#if defined(XCB_HAS_XCB_GLX) && XCB_GLX_MAJOR_VERSION == 1 && XCB_GLX_MINOR_VERSION < 4
-
-#define XCB_GLX_BUFFER_SWAP_COMPLETE 1
-
-typedef struct xcb_glx_buffer_swap_complete_event_t {
- uint8_t response_type;
- uint8_t pad0;
- uint16_t sequence;
- uint16_t event_type;
- uint8_t pad1[2];
- xcb_glx_drawable_t drawable;
- uint32_t ust_hi;
- uint32_t ust_lo;
- uint32_t msc_hi;
- uint32_t msc_lo;
- uint32_t sbc;
-} xcb_glx_buffer_swap_complete_event_t;
-#endif
-
-#if defined(XCB_USE_XLIB) && defined(XCB_USE_GLX)
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Drawable drawable; /* drawable on which event was requested in event mask */
- int event_type;
- int64_t ust;
- int64_t msc;
- int64_t sbc;
-} QGLXBufferSwapComplete;
-#endif
-
QXcbScreen* QXcbConnection::findOrCreateScreen(QList<QXcbScreen *>& newScreens,
int screenNumber, xcb_screen_t* xcbScreen, xcb_randr_get_output_info_reply_t *output)
{
@@ -309,11 +270,12 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
, m_primaryScreenNumber(0)
, m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY"))
, m_nativeInterface(nativeInterface)
+#ifdef XCB_USE_XLIB
+ , m_xlib_display(0)
+#endif
, xfixes_first_event(0)
, xrandr_first_event(0)
, xkb_first_event(0)
- , glx_first_event(0)
- , has_glx_extension(false)
, has_shape_extension(false)
, has_randr_extension(false)
, has_input_shape(false)
@@ -322,14 +284,10 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
, m_buttons(0)
, m_focusWindow(0)
, m_systemTrayTracker(0)
+ , m_glIntegration(Q_NULLPTR)
{
-#ifdef XCB_USE_EGL
- EGLNativeDisplayType dpy = EGL_DEFAULT_DISPLAY;
-#elif defined(XCB_USE_XLIB)
- Display *dpy;
-#endif
#ifdef XCB_USE_XLIB
- dpy = XOpenDisplay(m_displayName.constData());
+ Display *dpy = XOpenDisplay(m_displayName.constData());
if (dpy) {
m_primaryScreenNumber = DefaultScreen(dpy);
m_connection = XGetXCBConnection(dpy);
@@ -345,12 +303,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
if (!m_connection || xcb_connection_has_error(m_connection))
qFatal("QXcbConnection: Could not connect to display %s", m_displayName.constData());
-#ifdef XCB_USE_EGL
- EGLDisplay eglDisplay = eglGetDisplay(dpy);
- m_egl_display = eglDisplay;
- EGLint major, minor;
- m_has_egl = eglInitialize(eglDisplay, &major, &minor);
-#endif //XCB_USE_EGL
m_reader = new QXcbEventReader(this);
m_reader->start();
@@ -363,9 +315,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
#ifdef XCB_USE_RENDER
&xcb_render_id,
#endif
-#ifdef XCB_HAS_XCB_GLX
- &xcb_glx_id,
-#endif
0
};
@@ -382,7 +331,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
initializeXRandr();
updateScreens();
- initializeGLX();
initializeXFixes();
initializeXRender();
m_xi2Enabled = false;
@@ -405,6 +353,27 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
if (!m_startupId.isNull())
qunsetenv("DESKTOP_STARTUP_ID");
+
+ QStringList glIntegrationNames;
+ glIntegrationNames << QStringLiteral("xcb_glx") << QStringLiteral("xcb_egl");
+ QString glIntegrationName = QString::fromLocal8Bit(qgetenv("QT_XCB_GL_INTEGRATION"));
+ if (glIntegrationName.size()) {
+ glIntegrationNames.removeAll(glIntegrationName);
+ glIntegrationNames.prepend(glIntegrationName);
+ }
+
+ qCDebug(QT_XCB_GLINTEGRATION) << "Choosing xcb gl-integration based on following priority\n" << glIntegrationNames;
+ for (int i = 0; i < glIntegrationNames.size() && !m_glIntegration; i++) {
+ m_glIntegration = QXcbGlIntegrationFactory::create(glIntegrationNames.at(i));
+ if (m_glIntegration && !m_glIntegration->initialize(this)) {
+ qCDebug(QT_XCB_GLINTEGRATION) << "Failed to initialize xcb gl-integration" << glIntegrationNames.at(i);
+ delete m_glIntegration;
+ m_glIntegration = Q_NULLPTR;
+ }
+ }
+ if (!m_glIntegration)
+ qCDebug(QT_XCB_GLINTEGRATION) << "Failed to create xcb gl-integration";
+
sync();
if (qEnvironmentVariableIsEmpty("QT_IM_MODULE"))
@@ -435,11 +404,6 @@ QXcbConnection::~QXcbConnection()
while (!m_screens.isEmpty())
delete m_screens.takeLast();
-#ifdef XCB_USE_EGL
- if (m_has_egl)
- eglTerminate(m_egl_display);
-#endif //XCB_USE_EGL
-
#ifdef XCB_USE_XLIB
XCloseDisplay((Display *)m_xlib_display);
#else
@@ -990,51 +954,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
}
}
-#ifdef XCB_USE_XLIB
- if (!handled) {
- // Check if a custom XEvent constructor was registered in xlib for this event type, and call it discarding the constructed XEvent if any.
- // XESetWireToEvent might be used by libraries to intercept messages from the X server e.g. the OpenGL lib waiting for DRI2 events.
- Display *xdisplay = (Display *)m_xlib_display;
- XLockDisplay(xdisplay);
- bool locked = true;
- Bool (*proc)(Display*, XEvent*, xEvent*) = XESetWireToEvent(xdisplay, response_type, 0);
- if (proc) {
- XESetWireToEvent(xdisplay, response_type, proc);
- XEvent dummy;
- event->sequence = LastKnownRequestProcessed(m_xlib_display);
- if (proc(xdisplay, &dummy, (xEvent*)event)) {
-#if defined(XCB_USE_GLX) && defined(XCB_HAS_XCB_GLX)
- // DRI2 clients don't receive GLXBufferSwapComplete events on the wire.
- // Instead the GLX event is synthesized from the DRI2BufferSwapComplete event
- // by DRI2WireToEvent(). For an application to be able to see the event
- // we have to convert it to an xcb_glx_buffer_swap_complete_event_t and
- // pass it to the native event filter.
- const uint swap_complete = glx_first_event + XCB_GLX_BUFFER_SWAP_COMPLETE;
- if (dispatcher && has_glx_extension && uint(dummy.type) == swap_complete && response_type != swap_complete) {
- QGLXBufferSwapComplete *xev = reinterpret_cast<QGLXBufferSwapComplete *>(&dummy);
- xcb_glx_buffer_swap_complete_event_t ev;
- memset(&ev, 0, sizeof(xcb_glx_buffer_swap_complete_event_t));
- ev.response_type = xev->type;
- ev.sequence = xev->serial;
- ev.event_type = xev->event_type;
- ev.drawable = xev->drawable;
- ev.ust_hi = xev->ust >> 32;
- ev.ust_lo = xev->ust & 0xffffffff;
- ev.msc_hi = xev->msc >> 32;
- ev.msc_lo = xev->msc & 0xffffffff;
- ev.sbc = xev->sbc & 0xffffffff;
- // Unlock the display before calling the native event filter
- XUnlockDisplay(xdisplay);
- locked = false;
- handled = dispatcher->filterNativeEvent(m_nativeInterface->genericEventFilterType(), &ev, &result);
- }
-#endif
- }
- }
- if (locked)
- XUnlockDisplay(xdisplay);
- }
-#endif
+ if (!handled)
+ handled = m_glIntegration->handleXcbEvent(event, response_type);
if (handled)
printXcbEvent("Handled XCB event", event);
@@ -1232,6 +1153,11 @@ xcb_window_t QXcbConnection::rootWindow()
return primaryScreen()->root();
}
+void *QXcbConnection::xlib_display() const
+{
+ return m_xlib_display;
+}
+
void QXcbConnection::processXcbEvents()
{
int connection_error = xcb_connection_has_error(xcb_connection());
@@ -1674,34 +1600,6 @@ void QXcbConnection::initializeXRender()
#endif
}
-void QXcbConnection::initializeGLX()
-{
-#ifdef XCB_HAS_XCB_GLX
- const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection, &xcb_glx_id);
- if (!reply || !reply->present)
- return;
-
- has_glx_extension = true;
- glx_first_event = reply->first_event;
-
- xcb_generic_error_t *error = 0;
- xcb_glx_query_version_cookie_t xglx_query_cookie = xcb_glx_query_version(m_connection,
- XCB_GLX_MAJOR_VERSION,
- XCB_GLX_MINOR_VERSION);
- xcb_glx_query_version_reply_t *xglx_query = xcb_glx_query_version_reply(m_connection,
- xglx_query_cookie, &error);
- if (!xglx_query || error) {
- qWarning("QXcbConnection: Failed to initialize GLX");
- free(error);
- has_glx_extension = false;
- }
- free(xglx_query);
-#else
- // no way to check, assume GLX is present
- has_glx_extension = true;
-#endif
-}
-
void QXcbConnection::initializeXRandr()
{
const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection, &xcb_randr_id);
@@ -1811,13 +1709,6 @@ void QXcbConnection::initializeXKB()
#endif
}
-#if defined(XCB_USE_EGL)
-bool QXcbConnection::hasEgl() const
-{
- return m_has_egl;
-}
-#endif // defined(XCB_USE_EGL)
-
#if defined(XCB_USE_XINPUT2)
static int xi2ValuatorOffset(unsigned char *maskPtr, int maskLen, int number)
{
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 65d117cc02..18fc8113e1 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -36,6 +36,7 @@
#include <xcb/xcb.h>
+#include "qxcbexport.h"
#include <QHash>
#include <QList>
#include <QMutex>
@@ -85,6 +86,7 @@ class QXcbClipboard;
class QXcbWMSupport;
class QXcbNativeInterface;
class QXcbSystemTrayTracker;
+class QXcbGlIntegration;
namespace QXcbAtom {
enum Atom {
@@ -360,7 +362,7 @@ private:
};
class QAbstractEventDispatcher;
-class QXcbConnection : public QObject
+class Q_XCB_EXPORT QXcbConnection : public QObject
{
Q_OBJECT
public:
@@ -395,15 +397,9 @@ public:
QXcbWMSupport *wmSupport() const { return m_wmSupport.data(); }
xcb_window_t rootWindow();
#ifdef XCB_USE_XLIB
- void *xlib_display() const { return m_xlib_display; }
+ void *xlib_display() const;
#endif
-#ifdef XCB_USE_EGL
- bool hasEgl() const;
-#endif
-#if defined(XCB_USE_EGL)
- void *egl_display() const { return m_egl_display; }
-#endif
#if defined(XCB_USE_XINPUT2)
void xi2Select(xcb_window_t window);
#endif
@@ -437,7 +433,6 @@ public:
inline xcb_timestamp_t netWmUserTime() const { return m_netWmUserTime; }
inline void setNetWmUserTime(xcb_timestamp_t t) { if (t > m_netWmUserTime) m_netWmUserTime = t; }
- bool hasGLX() const { return has_glx_extension; }
bool hasXFixes() const { return xfixes_first_event > 0; }
bool hasXShape() const { return has_shape_extension; }
bool hasXRandr() const { return has_randr_extension; }
@@ -446,6 +441,7 @@ public:
bool hasXKB() const { return has_xkb; }
bool supportsThreadedRendering() const { return m_reader->isRunning(); }
+ bool threadedEventHandling() const { return m_reader->isRunning(); }
xcb_timestamp_t getTimestamp();
@@ -472,6 +468,8 @@ public:
QXcbEventReader *eventReader() const { return m_reader; }
bool canGrab() const { return m_canGrabServer; }
+
+ QXcbGlIntegration *glIntegration() const { return m_glIntegration; }
protected:
bool event(QEvent *e) Q_DECL_OVERRIDE;
@@ -484,7 +482,6 @@ private slots:
private:
void initializeAllAtoms();
void sendConnectionEvent(QXcbAtom::Atom atom, uint id = 0);
- void initializeGLX();
void initializeXFixes();
void initializeXRender();
void initializeXRandr();
@@ -580,10 +577,6 @@ private:
QHash<int, QWindowSystemInterface::TouchPoint> m_touchPoints;
QHash<int, XInput2TouchDeviceData*> m_touchDevices;
#endif
-#if defined(XCB_USE_EGL)
- void *m_egl_display;
- bool m_has_egl;
-#endif
#ifdef Q_XCB_DEBUG
struct CallInfo {
int sequence;
@@ -604,9 +597,7 @@ private:
uint32_t xfixes_first_event;
uint32_t xrandr_first_event;
uint32_t xkb_first_event;
- uint32_t glx_first_event;
- bool has_glx_extension;
bool has_shape_extension;
bool has_randr_extension;
bool has_input_shape;
@@ -619,6 +610,7 @@ private:
QByteArray m_startupId;
QXcbSystemTrayTracker *m_systemTrayTracker;
+ QXcbGlIntegration *m_glIntegration;
friend class QXcbEventReader;
};
@@ -668,11 +660,6 @@ cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection,
#define Q_XCB_NOOP(c)
#endif
-
-#if defined(XCB_USE_EGL)
-#define EGL_DISPLAY_FROM_XCB(object) ((EGLDisplay)(object->connection()->egl_display()))
-#endif
-
QT_END_NAMESPACE
#endif
diff --git a/src/plugins/platforms/xcb/qxcbeglsurface.h b/src/plugins/platforms/xcb/qxcbexport.h
index b03a029094..caf5124133 100644
--- a/src/plugins/platforms/xcb/qxcbeglsurface.h
+++ b/src/plugins/platforms/xcb/qxcbexport.h
@@ -31,34 +31,19 @@
**
****************************************************************************/
-#ifndef QXCBEGLSURFACE_H
-#define QXCBEGLSURFACE_H
+#ifndef QXCBEXPORT_H
+#define QXCBEXPORT_H
-#include <EGL/egl.h>
+#include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE
-class QXcbEGLSurface
-{
-public:
- QXcbEGLSurface(EGLDisplay display, EGLSurface surface)
- : m_display(display)
- , m_surface(surface)
- {
- }
-
- ~QXcbEGLSurface()
- {
- eglDestroySurface(m_display, m_surface);
- }
-
- EGLSurface surface() const { return m_surface; }
-
-private:
- EGLDisplay m_display;
- EGLSurface m_surface;
-};
+# if defined(QT_BUILD_XCB_PLUGIN)
+# define Q_XCB_EXPORT Q_DECL_EXPORT
+# else
+# define Q_XCB_EXPORT Q_DECL_IMPORT
+# endif
QT_END_NAMESPACE
+#endif //QXCBEXPORT_H
-#endif
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 1a10a865ab..f8b2c4090f 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -41,6 +41,7 @@
#include "qxcbnativeinterface.h"
#include "qxcbclipboard.h"
#include "qxcbdrag.h"
+#include "qxcbglintegration.h"
#ifndef QT_NO_SESSIONMANAGER
#include "qxcbsessionmanager.h"
@@ -69,15 +70,6 @@
#include <private/qgenericunixthemes_p.h>
#include <qpa/qplatforminputcontext.h>
-#if defined(XCB_USE_GLX)
-#include "qglxintegration.h"
-#elif defined(XCB_USE_EGL)
-#include "qxcbeglsurface.h"
-#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
-#include <QtPlatformSupport/private/qeglpbuffer_p.h>
-#include <QtPlatformHeaders/QEGLNativeContext>
-#endif
-
#include <QtGui/QOpenGLContext>
#include <QtGui/QScreen>
#include <QtGui/QOffscreenSurface>
@@ -191,82 +183,32 @@ QXcbIntegration::~QXcbIntegration()
QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const
{
- return new QXcbWindow(window);
-}
-
-#if defined(XCB_USE_EGL)
-class QEGLXcbPlatformContext : public QEGLPlatformContext
-{
-public:
- QEGLXcbPlatformContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share,
- EGLDisplay display, QXcbConnection *c, const QVariant &nativeHandle)
- : QEGLPlatformContext(glFormat, share, display, 0, nativeHandle)
- , m_connection(c)
- {
- Q_XCB_NOOP(m_connection);
- }
-
- void swapBuffers(QPlatformSurface *surface)
- {
- Q_XCB_NOOP(m_connection);
- QEGLPlatformContext::swapBuffers(surface);
- Q_XCB_NOOP(m_connection);
- }
-
- bool makeCurrent(QPlatformSurface *surface)
- {
- Q_XCB_NOOP(m_connection);
- bool ret = QEGLPlatformContext::makeCurrent(surface);
- Q_XCB_NOOP(m_connection);
- return ret;
- }
-
- void doneCurrent()
- {
- Q_XCB_NOOP(m_connection);
- QEGLPlatformContext::doneCurrent();
- Q_XCB_NOOP(m_connection);
- }
-
- EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)
- {
- if (surface->surface()->surfaceClass() == QSurface::Window)
- return static_cast<QXcbWindow *>(surface)->eglSurface()->surface();
- else
- return static_cast<QEGLPbuffer *>(surface)->pbuffer();
- }
-
- QVariant nativeHandle() const {
- return QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(eglContext(), eglDisplay()));
+ if (window->type() != Qt::Desktop) {
+ QXcbScreen *screen = static_cast<QXcbScreen *>(window->screen()->handle());
+ QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
+ if (glIntegration) {
+ QXcbWindow *xcbWindow = glIntegration->createWindow(window);
+ xcbWindow->create();
+ return xcbWindow;
+ }
}
-private:
- QXcbConnection *m_connection;
-};
-#endif
+ Q_ASSERT(window->type() == Qt::Desktop || !window->supportsOpenGL());
+ QXcbWindow *xcbWindow = new QXcbWindow(window);
+ xcbWindow->create();
+ return xcbWindow;
+}
#ifndef QT_NO_OPENGL
QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
-#if defined(XCB_USE_GLX)
- QGLXContext *platformContext = new QGLXContext(screen, context->format(),
- context->shareHandle(), context->nativeHandle());
- context->setNativeHandle(platformContext->nativeHandle());
- return platformContext;
-#elif defined(XCB_USE_EGL)
- QEGLXcbPlatformContext *platformContext = new QEGLXcbPlatformContext(context->format(),
- context->shareHandle(),
- screen->connection()->egl_display(),
- screen->connection(),
- context->nativeHandle());
- context->setNativeHandle(platformContext->nativeHandle());
- return platformContext;
-#else
- Q_UNUSED(screen);
- qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
- return 0;
-#endif
+ QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
+ if (!glIntegration) {
+ qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+ return Q_NULLPTR;
+ }
+ return glIntegration->createPlatformOpenGLContext(context);
}
#endif
@@ -277,45 +219,23 @@ QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *wind
QPlatformOffscreenSurface *QXcbIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
{
-#if defined(XCB_USE_GLX)
- static bool vendorChecked = false;
- static bool glxPbufferUsable = true;
- if (!vendorChecked) {
- vendorChecked = true;
- const char *glxvendor = glXGetClientString(glXGetCurrentDisplay(), GLX_VENDOR);
- if (glxvendor && !strcmp(glxvendor, "ATI"))
- glxPbufferUsable = false;
- }
- if (glxPbufferUsable)
- return new QGLXPbuffer(surface);
- else
- return 0; // trigger fallback to hidden QWindow
-#elif defined(XCB_USE_EGL)
QXcbScreen *screen = static_cast<QXcbScreen *>(surface->screen()->handle());
- return new QEGLPbuffer(screen->connection()->egl_display(), surface->requestedFormat(), surface);
-#else
- Q_UNUSED(surface);
- qWarning("QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled");
- return 0;
-#endif
+ QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
+ if (!glIntegration) {
+ qWarning("QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled");
+ return Q_NULLPTR;
+ }
+ return glIntegration->createPlatformOffscreenSurface(surface);
}
bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
switch (cap) {
case ThreadedPixmaps: return true;
-#if defined(XCB_USE_GLX)
- case OpenGL: return m_connections.at(0)->hasGLX();
-#elif defined(XCB_USE_EGL)
- case OpenGL: return true;
-#else
- case OpenGL: return false;
-#endif
-#if defined(XCB_USE_GLX)
- case ThreadedOpenGL: return m_connections.at(0)->supportsThreadedRendering() && QGLXContext::supportsThreading();
-#else
- case ThreadedOpenGL: return m_connections.at(0)->supportsThreadedRendering();
-#endif
+ case OpenGL: return m_connections.first()->glIntegration();
+ case ThreadedOpenGL: return m_connections.at(0)->threadedEventHandling()
+ && m_connections.at(0)->glIntegration()
+ && m_connections.at(0)->glIntegration()->supportsThreadedOpenGL();
case WindowMasks: return true;
case MultipleWindows: return true;
case ForeignWindows: return true;
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
index 5d73191097..150e3d57cb 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.h
+++ b/src/plugins/platforms/xcb/qxcbintegration.h
@@ -37,6 +37,8 @@
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformscreen.h>
+#include "qxcbexport.h"
+
QT_BEGIN_NAMESPACE
class QXcbConnection;
@@ -44,7 +46,7 @@ class QAbstractEventDispatcher;
class QXcbNativeInterface;
class QXcbScreen;
-class QXcbIntegration : public QPlatformIntegration
+class Q_XCB_EXPORT QXcbIntegration : public QPlatformIntegration
{
public:
QXcbIntegration(const QStringList &parameters, int &argc, char **argv);
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 15ba7cc021..d5b8e6aead 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -46,12 +46,6 @@
#include <QtGui/qopenglcontext.h>
#include <QtGui/qscreen.h>
-#if defined(XCB_USE_EGL)
-#include "QtPlatformSupport/private/qeglplatformcontext_p.h"
-#elif defined (XCB_USE_GLX)
-#include "qglxintegration.h"
-#endif
-
#include <QtPlatformHeaders/qxcbwindowfunctions.h>
#ifdef XCB_USE_XLIB
@@ -62,18 +56,17 @@
#include <algorithm>
+#include "qxcbnativeinterfacehandler.h"
+
QT_BEGIN_NAMESPACE
// return QXcbNativeInterface::ResourceType for the key.
static int resourceType(const QByteArray &key)
{
static const QByteArray names[] = { // match QXcbNativeInterface::ResourceType
- QByteArrayLiteral("display"), QByteArrayLiteral("egldisplay"),
+ QByteArrayLiteral("display"),
QByteArrayLiteral("connection"), QByteArrayLiteral("screen"),
- QByteArrayLiteral("eglcontext"),
- QByteArrayLiteral("eglconfig"),
- QByteArrayLiteral("glxconfig"),
- QByteArrayLiteral("glxcontext"), QByteArrayLiteral("apptime"),
+ QByteArrayLiteral("apptime"),
QByteArrayLiteral("appusertime"), QByteArrayLiteral("hintstyle"),
QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"),
QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"),
@@ -82,8 +75,6 @@ static int resourceType(const QByteArray &key)
};
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
const QByteArray *result = std::find(names, end, key);
- if (result == end)
- result = std::find(names, end, key.toLower());
return int(result - names);
}
@@ -222,8 +213,12 @@ void QXcbNativeInterface::setParentRelativeBackPixmap(const QWindow *qwindow)
void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resourceString)
{
- void *result = 0;
- switch (resourceType(resourceString)) {
+ QByteArray lowerCaseResource = resourceString.toLower();
+ void *result = handlerNativeResourceForIntegration(lowerCaseResource);
+ if (result)
+ return result;
+
+ switch (resourceType(lowerCaseResource)) {
case StartupId:
result = startupId();
break;
@@ -242,32 +237,20 @@ void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resour
void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context)
{
- void *result = 0;
- switch (resourceType(resourceString)) {
- case EglContext:
- result = eglContextForContext(context);
- break;
- case EglConfig:
- result = eglConfigForContext(context);
- break;
- case GLXConfig:
- result = glxConfigForContext(context);
- break;
- case GLXContext:
- result = glxContextForContext(context);
- break;
- default:
- break;
- }
-
+ QByteArray lowerCaseResource = resourceString.toLower();
+ void *result = handlerNativeResourceForContext(lowerCaseResource, context);
return result;
}
-void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, QScreen *screen)
+void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resourceString, QScreen *screen)
{
- void *result = 0;
+ QByteArray lowerCaseResource = resourceString.toLower();
+ void *result = handlerNativeResourceForScreen(lowerCaseResource ,screen);
+ if (result)
+ return result;
+
const QXcbScreen *xcbScreen = static_cast<QXcbScreen *>(screen->handle());
- switch (resourceType(resource)) {
+ switch (resourceType(lowerCaseResource)) {
case Display:
#ifdef XCB_USE_XLIB
result = xcbScreen->connection()->xlib_display();
@@ -303,14 +286,15 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q
void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{
- void *result = 0;
- switch (resourceType(resourceString)) {
+ QByteArray lowerCaseResource = resourceString.toLower();
+ void *result = handlerNativeResourceForWindow(lowerCaseResource, window);
+ if (result)
+ return result;
+
+ switch (resourceType(lowerCaseResource)) {
case Display:
result = displayForWindow(window);
break;
- case EglDisplay:
- result = eglDisplayForWindow(window);
- break;
case Connection:
result = connectionForWindow(window);
break;
@@ -324,17 +308,42 @@ void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceStr
return result;
}
+void *QXcbNativeInterface::nativeResourceForBackingStore(const QByteArray &resourceString, QBackingStore *backingStore)
+{
+ const QByteArray lowerCaseResource = resourceString.toLower();
+ void *result = handlerNativeResourceForBackingStore(lowerCaseResource,backingStore);
+ return result;
+}
+
+
QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource)
{
- QByteArray lowerCaseResource = resource.toLower();
+ const QByteArray lowerCaseResource = resource.toLower();
+ QPlatformNativeInterface::NativeResourceForIntegrationFunction func = handlerNativeResourceFunctionForIntegration(lowerCaseResource);
+ if (func)
+ return func;
+
if (lowerCaseResource == "setstartupid")
return NativeResourceForIntegrationFunction(setStartupId);
return 0;
}
+QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource)
+{
+ const QByteArray lowerCaseResource = resource.toLower();
+ QPlatformNativeInterface::NativeResourceForContextFunction func = handlerNativeResourceFunctionForContext(lowerCaseResource);
+ if (func)
+ return func;
+ return Q_NULLPTR;
+}
+
QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::nativeResourceFunctionForScreen(const QByteArray &resource)
{
const QByteArray lowerCaseResource = resource.toLower();
+ NativeResourceForScreenFunction func = handlerNativeResourceFunctionForScreen(lowerCaseResource);
+ if (func)
+ return func;
+
if (lowerCaseResource == "setapptime")
return NativeResourceForScreenFunction(setAppTime);
else if (lowerCaseResource == "setappusertime")
@@ -342,8 +351,28 @@ QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::n
return 0;
}
+QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterface::nativeResourceFunctionForWindow(const QByteArray &resource)
+{
+ const QByteArray lowerCaseResource = resource.toLower();
+ NativeResourceForWindowFunction func = handlerNativeResourceFunctionForWindow(lowerCaseResource);
+ return func;
+}
+
+QPlatformNativeInterface::NativeResourceForBackingStoreFunction QXcbNativeInterface::nativeResourceFunctionForBackingStore(const QByteArray &resource)
+{
+ const QByteArray lowerCaseResource = resource.toLower();
+ NativeResourceForBackingStoreFunction func = handlerNativeResourceFunctionForBackingStore(resource);
+ return func;
+}
+
QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &function) const
{
+ const QByteArray lowerCaseFunction = function.toLower();
+ QFunctionPointer func = handlerPlatformFunction(lowerCaseFunction);
+ if (func)
+ return func;
+
+ //case sensitive
if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier()) {
return QFunctionPointer(QXcbWindow::setWmWindowTypeStatic);
}
@@ -411,15 +440,6 @@ void QXcbNativeInterface::setStartupId(const char *data)
defaultConnection->setStartupId(startupId);
}
-QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource)
-{
- QByteArray lowerCaseResource = resource.toLower();
- if (lowerCaseResource == "get_egl_context") {
- return eglContextForContext;
- }
- return 0;
-}
-
QXcbScreen *QXcbNativeInterface::qPlatformScreenForWindow(QWindow *window)
{
QXcbScreen *screen;
@@ -442,17 +462,6 @@ void *QXcbNativeInterface::displayForWindow(QWindow *window)
#endif
}
-void *QXcbNativeInterface::eglDisplayForWindow(QWindow *window)
-{
-#if defined(XCB_USE_EGL)
- QXcbScreen *screen = qPlatformScreenForWindow(window);
- return screen->connection()->egl_display();
-#else
- Q_UNUSED(window)
- return 0;
-#endif
-}
-
void *QXcbNativeInterface::connectionForWindow(QWindow *window)
{
QXcbScreen *screen = qPlatformScreenForWindow(window);
@@ -465,54 +474,121 @@ void *QXcbNativeInterface::screenForWindow(QWindow *window)
return screen->screen();
}
-void * QXcbNativeInterface::eglContextForContext(QOpenGLContext *context)
+void QXcbNativeInterface::addHandler(QXcbNativeInterfaceHandler *handler)
{
- Q_ASSERT(context);
-#if defined(XCB_USE_EGL)
- QEGLPlatformContext *eglPlatformContext = static_cast<QEGLPlatformContext *>(context->handle());
- return eglPlatformContext->eglContext();
-#else
- Q_UNUSED(context);
- return 0;
-#endif
+ m_handlers.removeAll(handler);
+ m_handlers.prepend(handler);
}
-void * QXcbNativeInterface::eglConfigForContext(QOpenGLContext *context)
+void QXcbNativeInterface::removeHandler(QXcbNativeInterfaceHandler *handler)
{
- Q_ASSERT(context);
-#if defined(XCB_USE_EGL)
- QEGLPlatformContext *eglPlatformContext = static_cast<QEGLPlatformContext *>(context->handle());
- return eglPlatformContext->eglConfig();
-#else
- Q_UNUSED(context);
- return 0;
-#endif
+ m_handlers.removeAll(handler);
}
-void *QXcbNativeInterface::glxContextForContext(QOpenGLContext *context)
+QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterface::handlerNativeResourceFunctionForIntegration(const QByteArray &resource) const
{
- Q_ASSERT(context);
-#if defined(XCB_USE_GLX)
- QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle());
- return glxPlatformContext->glxContext();
-#else
- Q_UNUSED(context);
- return 0;
-#endif
+ for (int i = 0; i < m_handlers.size(); i++) {
+ QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
+ NativeResourceForIntegrationFunction result = handler->nativeResourceFunctionForIntegration(resource);
+ if (result)
+ return result;
+ }
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::handlerNativeResourceFunctionForContext(const QByteArray &resource) const
+{
+ for (int i = 0; i < m_handlers.size(); i++) {
+ QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
+ NativeResourceForContextFunction result = handler->nativeResourceFunctionForContext(resource);
+ if (result)
+ return result;
+ }
+ return Q_NULLPTR;
+}
+QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::handlerNativeResourceFunctionForScreen(const QByteArray &resource) const
+{
+ for (int i = 0; i < m_handlers.size(); i++) {
+ QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
+ NativeResourceForScreenFunction result = handler->nativeResourceFunctionForScreen(resource);
+ if (result)
+ return result;
+ }
+ return Q_NULLPTR;
}
-void *QXcbNativeInterface::glxConfigForContext(QOpenGLContext *context)
+QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterface::handlerNativeResourceFunctionForWindow(const QByteArray &resource) const
{
- Q_ASSERT(context);
-#if defined(XCB_USE_GLX)
- QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle());
- return glxPlatformContext->glxConfig();
-#else
- Q_UNUSED(context);
- return 0;
-#endif
+ for (int i = 0; i < m_handlers.size(); i++) {
+ QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
+ NativeResourceForWindowFunction result = handler->nativeResourceFunctionForWindow(resource);
+ if (result)
+ return result;
+ }
+ return Q_NULLPTR;
+}
+
+QPlatformNativeInterface::NativeResourceForBackingStoreFunction QXcbNativeInterface::handlerNativeResourceFunctionForBackingStore(const QByteArray &resource) const
+{
+ for (int i = 0; i < m_handlers.size(); i++) {
+ QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
+ NativeResourceForBackingStoreFunction result = handler->nativeResourceFunctionForBackingStore(resource);
+ if (result)
+ return result;
+ }
+ return Q_NULLPTR;
+}
+
+QFunctionPointer QXcbNativeInterface::handlerPlatformFunction(const QByteArray &function) const
+{
+ for (int i = 0; i < m_handlers.size(); i++) {
+ QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
+ QFunctionPointer func = handler->platformFunction(function);
+ if (func)
+ return func;
+ }
+ return Q_NULLPTR;
+}
+
+void *QXcbNativeInterface::handlerNativeResourceForIntegration(const QByteArray &resource) const
+{
+ NativeResourceForIntegrationFunction func = handlerNativeResourceFunctionForIntegration(resource);
+ if (func)
+ return func();
+ return Q_NULLPTR;
+}
+
+void *QXcbNativeInterface::handlerNativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) const
+{
+ NativeResourceForContextFunction func = handlerNativeResourceFunctionForContext(resource);
+ if (func)
+ return func(context);
+ return Q_NULLPTR;
+}
+
+void *QXcbNativeInterface::handlerNativeResourceForScreen(const QByteArray &resource, QScreen *screen) const
+{
+ NativeResourceForScreenFunction func = handlerNativeResourceFunctionForScreen(resource);
+ if (func)
+ return func(screen);
+ return Q_NULLPTR;
+}
+void *QXcbNativeInterface::handlerNativeResourceForWindow(const QByteArray &resource, QWindow *window) const
+{
+ NativeResourceForWindowFunction func = handlerNativeResourceFunctionForWindow(resource);
+ if (func)
+ return func(window);
+ return Q_NULLPTR;
+}
+
+void *QXcbNativeInterface::handlerNativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) const
+{
+ NativeResourceForBackingStoreFunction func = handlerNativeResourceFunctionForBackingStore(resource);
+ if (func)
+ return func(backingStore);
+ return Q_NULLPTR;
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index 3ec96975f5..702aee63d8 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -39,25 +39,23 @@
#include <QtCore/QRect>
+#include "qxcbexport.h"
+
QT_BEGIN_NAMESPACE
class QWidget;
class QXcbScreen;
class QXcbConnection;
+class QXcbNativeInterfaceHandler;
-class QXcbNativeInterface : public QPlatformNativeInterface
+class Q_XCB_EXPORT QXcbNativeInterface : public QPlatformNativeInterface
{
Q_OBJECT
public:
enum ResourceType {
Display,
- EglDisplay,
Connection,
Screen,
- EglContext,
- EglConfig,
- GLXConfig,
- GLXContext,
AppTime,
AppUserTime,
ScreenHintStyle,
@@ -76,17 +74,19 @@ public:
void *nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context) Q_DECL_OVERRIDE;
void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) Q_DECL_OVERRIDE;
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) Q_DECL_OVERRIDE;
+ void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) Q_DECL_OVERRIDE;
NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) Q_DECL_OVERRIDE;
NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource) Q_DECL_OVERRIDE;
+ NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) Q_DECL_OVERRIDE;
+ NativeResourceForBackingStoreFunction nativeResourceFunctionForBackingStore(const QByteArray &resource) Q_DECL_OVERRIDE;
QFunctionPointer platformFunction(const QByteArray &function) const Q_DECL_OVERRIDE;
inline const QByteArray &genericEventFilterType() const { return m_genericEventFilterType; }
void *displayForWindow(QWindow *window);
- void *eglDisplayForWindow(QWindow *window);
void *connectionForWindow(QWindow *window);
void *screenForWindow(QWindow *window);
void *appTime(const QXcbScreen *screen);
@@ -98,10 +98,6 @@ public:
static void setStartupId(const char *);
static void setAppTime(QScreen *screen, xcb_timestamp_t time);
static void setAppUserTime(QScreen *screen, xcb_timestamp_t time);
- static void *eglContextForContext(QOpenGLContext *context);
- static void *eglConfigForContext(QOpenGLContext *context);
- static void *glxContextForContext(QOpenGLContext *context);
- static void *glxConfigForContext(QOpenGLContext *context);
Q_INVOKABLE void beep();
Q_INVOKABLE bool systemTrayAvailable(const QScreen *screen) const;
@@ -111,6 +107,8 @@ public:
Q_INVOKABLE bool requestSystemTrayWindowDock(const QWindow *window);
Q_INVOKABLE QRect systemTrayWindowGlobalGeometry(const QWindow *window);
+ void addHandler(QXcbNativeInterfaceHandler *handler);
+ void removeHandler(QXcbNativeInterfaceHandler *handler);
signals:
void systemTrayWindowChanged(QScreen *screen);
@@ -123,6 +121,19 @@ private:
xcb_visualid_t m_systrayVisualId;
static QXcbScreen *qPlatformScreenForWindow(QWindow *window);
+
+ QList<QXcbNativeInterfaceHandler *> m_handlers;
+ NativeResourceForIntegrationFunction handlerNativeResourceFunctionForIntegration(const QByteArray &resource) const;
+ NativeResourceForContextFunction handlerNativeResourceFunctionForContext(const QByteArray &resource) const;
+ NativeResourceForScreenFunction handlerNativeResourceFunctionForScreen(const QByteArray &resource) const;
+ NativeResourceForWindowFunction handlerNativeResourceFunctionForWindow(const QByteArray &resource) const;
+ NativeResourceForBackingStoreFunction handlerNativeResourceFunctionForBackingStore(const QByteArray &resource) const;
+ QFunctionPointer handlerPlatformFunction(const QByteArray &function) const;
+ void *handlerNativeResourceForIntegration(const QByteArray &resource) const;
+ void *handlerNativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) const;
+ void *handlerNativeResourceForScreen(const QByteArray &resource, QScreen *screen) const;
+ void *handlerNativeResourceForWindow(const QByteArray &resource, QWindow *window) const;
+ void *handlerNativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) const;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
index 194b2ceb2f..4d0ae9847a 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -41,6 +41,7 @@
#include <xcb/randr.h>
#include "qxcbobject.h"
+#include "qxcbscreen.h"
#include <private/qfontengine_p.h>
@@ -50,7 +51,7 @@ class QXcbConnection;
class QXcbCursor;
class QXcbXSettings;
-class QXcbScreen : public QXcbObject, public QPlatformScreen
+class Q_XCB_EXPORT QXcbScreen : public QXcbObject, public QPlatformScreen
{
public:
QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen,
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index e1ccc3f086..54c32dd3c4 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -97,15 +97,6 @@
#include <X11/extensions/XInput2.h>
#endif
-#if defined(XCB_USE_GLX)
-#include "qglxintegration.h"
-#include <QtPlatformSupport/private/qglxconvenience_p.h>
-#elif defined(XCB_USE_EGL)
-#include "qxcbeglsurface.h"
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
-#include <QtPlatformSupport/private/qxlibeglintegration_p.h>
-#endif
-
#define XCOORD_MAX 16383
enum {
defaultWindowWidth = 160,
@@ -234,9 +225,6 @@ QXcbWindow::QXcbWindow(QWindow *window)
, m_alertState(false)
, m_netWmUserTimeWindow(XCB_NONE)
, m_dirtyFrameMargins(false)
-#if defined(XCB_USE_EGL)
- , m_eglSurface(0)
-#endif
, m_lastWindowStateEvent(-1)
, m_syncState(NoSyncNeeded)
, m_pendingSyncRequest(0)
@@ -244,11 +232,6 @@ QXcbWindow::QXcbWindow(QWindow *window)
m_screen = static_cast<QXcbScreen *>(window->screen()->handle());
setConnection(m_screen->connection());
-
- if (window->type() != Qt::ForeignWindow)
- create();
- else
- m_window = window->winId();
}
#ifdef Q_COMPILER_CLASS_ENUM
@@ -274,6 +257,11 @@ enum {
void QXcbWindow::create()
{
+ if (window()->type() == Qt::ForeignWindow) {
+ m_window = window()->winId();
+ return;
+ }
+
destroy();
m_deferredExpose = false;
@@ -337,27 +325,11 @@ void QXcbWindow::create()
window()->setFormat(parentFormat);
}
}
- m_format = window()->requestedFormat();
-#if (defined(XCB_USE_GLX) || defined(XCB_USE_EGL)) && defined(XCB_USE_XLIB)
+ resolveFormat();
+
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) {
-#if defined(XCB_USE_GLX)
- XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen), m_screen->screenNumber(), &m_format);
-#elif defined(XCB_USE_EGL)
- EGLDisplay eglDisplay = connection()->egl_display();
- EGLConfig eglConfig = q_configFromGLFormat(eglDisplay, m_format, true);
- m_format = q_glFormatFromConfig(eglDisplay, eglConfig, m_format);
-
- VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this), eglDisplay, eglConfig);
-
- XVisualInfo visualInfoTemplate;
- memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
- visualInfoTemplate.visualid = id;
-
- XVisualInfo *visualInfo;
- int matchingCount = 0;
- visualInfo = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &visualInfoTemplate, &matchingCount);
-#endif //XCB_USE_GLX
+ XVisualInfo *visualInfo = static_cast<XVisualInfo *>(createVisual());
if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface)
qFatal("Could not initialize OpenGL");
@@ -365,6 +337,7 @@ void QXcbWindow::create()
qWarning("Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.");
window()->setSurfaceType(QSurface::RasterSurface);
}
+
if (visualInfo) {
m_depth = visualInfo->depth;
m_imageFormat = imageFormatForVisual(visualInfo->depth, visualInfo->red_mask, visualInfo->blue_mask);
@@ -388,7 +361,6 @@ void QXcbWindow::create()
}
if (!m_window)
-#endif //defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
{
m_window = xcb_generate_id(xcb_connection());
m_visualId = m_screen->screen()->root_visual;
@@ -449,12 +421,10 @@ void QXcbWindow::create()
properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS);
properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING);
- m_usingSyncProtocol = m_screen->syncRequestSupported();
-#if !defined(XCB_USE_GLX)
- // synced resize only implemented on GLX
- if (window()->supportsOpenGL())
+ if (m_screen->syncRequestSupported())
+ m_usingSyncProtocol = supportsSyncProtocol();
+ else
m_usingSyncProtocol = false;
-#endif
if (m_usingSyncProtocol)
properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST);
@@ -576,11 +546,6 @@ void QXcbWindow::destroy()
}
m_mapped = false;
-#if defined(XCB_USE_EGL)
- delete m_eglSurface;
- m_eglSurface = 0;
-#endif
-
if (m_pendingSyncRequest)
m_pendingSyncRequest->invalidate();
}
@@ -1557,21 +1522,6 @@ QSurfaceFormat QXcbWindow::format() const
return m_format;
}
-#if defined(XCB_USE_EGL)
-QXcbEGLSurface *QXcbWindow::eglSurface() const
-{
- if (!m_eglSurface) {
- EGLDisplay display = connection()->egl_display();
- EGLConfig config = q_configFromGLFormat(display, window()->requestedFormat(), true);
- EGLSurface surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)m_window, 0);
-
- m_eglSurface = new QXcbEGLSurface(display, surface);
- }
-
- return m_eglSurface;
-}
-#endif
-
void QXcbWindow::setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes)
{
if (window->handle())
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index db194f0318..340070e882 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -48,11 +48,10 @@
QT_BEGIN_NAMESPACE
class QXcbScreen;
-class QXcbEGLSurface;
class QXcbSyncWindowRequest;
class QIcon;
-class QXcbWindow : public QXcbObject, public QXcbWindowEventListener, public QPlatformWindow
+class Q_XCB_EXPORT QXcbWindow : public QXcbObject, public QXcbWindowEventListener, public QPlatformWindow
{
public:
enum NetWmState {
@@ -138,10 +137,6 @@ public:
void updateNetWmUserTime(xcb_timestamp_t timestamp);
-#if defined(XCB_USE_EGL)
- QXcbEGLSurface *eglSurface() const;
-#endif
-
static void setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes);
QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
@@ -154,10 +149,16 @@ public:
qreal devicePixelRatio() const Q_DECL_OVERRIDE;
+ virtual void create();
+ virtual void destroy();
public Q_SLOTS:
void updateSyncRequestCounter();
-private:
+protected:
+ virtual void resolveFormat() { m_format = window()->requestedFormat(); }
+ virtual void *createVisual() { return Q_NULLPTR; }
+ virtual bool supportsSyncProtocol() { return !window()->supportsOpenGL(); }
+
void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
NetWmStates netWmStates();
void setNetWmStates(NetWmStates);
@@ -176,9 +177,6 @@ private:
quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
void handleXEmbedMessage(const xcb_client_message_event_t *event);
- void create();
- void destroy();
-
void show();
void hide();
@@ -215,10 +213,6 @@ private:
mutable bool m_dirtyFrameMargins;
mutable QMargins m_frameMargins;
-#if defined(XCB_USE_EGL)
- mutable QXcbEGLSurface *m_eglSurface;
-#endif
-
QRegion m_exposeRegion;
xcb_visualid_t m_visualId;
diff --git a/src/plugins/platforms/xcb/xcb-plugin.pro b/src/plugins/platforms/xcb/xcb-plugin.pro
index f14fcde73f..8dfe08d413 100644
--- a/src/plugins/platforms/xcb/xcb-plugin.pro
+++ b/src/plugins/platforms/xcb/xcb-plugin.pro
@@ -5,122 +5,10 @@ PLUGIN_CLASS_NAME = QXcbIntegrationPlugin
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
load(qt_plugin)
-QT += core-private gui-private platformsupport-private
+QT += core-private gui-private platformsupport-private xcb_qpa_lib-private
SOURCES = \
- qxcbclipboard.cpp \
- qxcbconnection.cpp \
- qxcbintegration.cpp \
- qxcbkeyboard.cpp \
- qxcbmime.cpp \
- qxcbdrag.cpp \
- qxcbscreen.cpp \
- qxcbwindow.cpp \
- qxcbbackingstore.cpp \
- qxcbwmsupport.cpp \
- qxcbmain.cpp \
- qxcbnativeinterface.cpp \
- qxcbcursor.cpp \
- qxcbimage.cpp \
- qxcbxsettings.cpp \
- qxcbsystemtraytracker.cpp
-
-HEADERS = \
- qxcbclipboard.h \
- qxcbconnection.h \
- qxcbintegration.h \
- qxcbkeyboard.h \
- qxcbdrag.h \
- qxcbmime.h \
- qxcbobject.h \
- qxcbscreen.h \
- qxcbwindow.h \
- qxcbbackingstore.h \
- qxcbwmsupport.h \
- qxcbnativeinterface.h \
- qxcbcursor.h \
- qxcbimage.h \
- qxcbxsettings.h \
- qxcbsystemtraytracker.h
-
-LIBS += $$QMAKE_LIBS_DYNLOAD
-
-# needed by GLX, Xcursor ...
-contains(QT_CONFIG, xcb-xlib) {
- DEFINES += XCB_USE_XLIB
- LIBS += -lX11 -lX11-xcb
-
- contains(QT_CONFIG, xinput2) {
- DEFINES += XCB_USE_XINPUT2
- SOURCES += qxcbconnection_xi2.cpp
- LIBS += -lXi
- }
-}
-
-# to support custom cursors with depth > 1
-contains(QT_CONFIG, xcb-render) {
- DEFINES += XCB_USE_RENDER
- LIBS += -lxcb-render -lxcb-render-util
-}
-
-# build with session management support
-contains(QT_CONFIG, xcb-sm) {
- DEFINES += XCB_USE_SM
- LIBS += -lSM -lICE
- SOURCES += qxcbsessionmanager.cpp
- HEADERS += qxcbsessionmanager.h
-}
-
-contains(QT_CONFIG, opengl) {
- contains(QT_CONFIG, xcb-xlib):!contains(QT_CONFIG, opengles2) {
- DEFINES += XCB_USE_GLX
- HEADERS += qglxintegration.h
- SOURCES += qglxintegration.cpp
- LIBS += $$QMAKE_LIBS_DYNLOAD
- contains(QT_CONFIG, xcb-glx) {
- DEFINES += XCB_HAS_XCB_GLX
- LIBS += -lxcb-glx
- }
- } else:contains(QT_CONFIG, egl):contains(QT_CONFIG, egl_x11) {
- DEFINES += XCB_USE_EGL
- CONFIG += egl
- HEADERS += qxcbeglsurface.h
-
- # EGL on MeeGo 1.2 Harmattan needs this macro to map EGLNativeDisplayType
- # and other types to the correct X11 types
- DEFINES += SUPPORT_X11
- }
-}
-
-DEFINES += $$QMAKE_DEFINES_XCB
-LIBS += $$QMAKE_LIBS_XCB
-QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB
-QMAKE_CFLAGS += $$QMAKE_CFLAGS_XCB
-
-CONFIG += qpa/genericunixfontdatabase
-
-contains(QT_CONFIG, dbus) {
-QT += dbus
-LIBS += -ldbus-1
-}
+ qxcbmain.cpp
OTHER_FILES += xcb.json README
-contains(QT_CONFIG, xcb-qt) {
- DEFINES += XCB_USE_RENDER
- XCB_DIR = ../../../3rdparty/xcb
- INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude
- LIBS += -lxcb -L$$OUT_PWD/xcb-static -lxcb-static
-} else {
- LIBS += -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms
- !contains(DEFINES, QT_NO_XKB):LIBS += -lxcb-xkb
-}
-
-# libxkbcommon
-contains(QT_CONFIG, xkbcommon-qt): {
- QT_CONFIG += use-xkbcommon-x11support
- include(../../../3rdparty/xkbcommon.pri)
-} else {
- LIBS += $$QMAKE_LIBS_XKBCOMMON
- QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XKBCOMMON
-}
diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro
index dab0d8cb14..5915a59c0b 100644
--- a/src/plugins/platforms/xcb/xcb.pro
+++ b/src/plugins/platforms/xcb/xcb.pro
@@ -2,4 +2,7 @@ TEMPLATE = subdirs
CONFIG += ordered
contains(QT_CONFIG, xcb-qt):SUBDIRS+=xcb-static
+
+SUBDIRS += xcb_qpa_lib.pro
SUBDIRS += xcb-plugin.pro
+SUBDIRS += gl_integrations
diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
new file mode 100644
index 0000000000..770236acc7
--- /dev/null
+++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
@@ -0,0 +1,111 @@
+TARGET = QtXcbQpa
+CONFIG += no_module_headers internal_module
+
+MODULE_INCLUDES = \
+ \$\$QT_MODULE_INCLUDE_BASE \
+ \$\$QT_MODULE_INCLUDE_BASE/QtQGui
+MODULE_PRIVATE_INCLUDES = \
+ \$\$QT_MODULE_INCLUDE_BASE/QtGui/$$QT.gui.VERSION \
+ \$\$QT_MODULE_INCLUDE_BASE/QtGui/$$QT.gui.VERSION/QtGui
+
+load(qt_module)
+
+QT += core-private gui-private platformsupport-private
+
+SOURCES = \
+ qxcbclipboard.cpp \
+ qxcbconnection.cpp \
+ qxcbintegration.cpp \
+ qxcbkeyboard.cpp \
+ qxcbmime.cpp \
+ qxcbdrag.cpp \
+ qxcbscreen.cpp \
+ qxcbwindow.cpp \
+ qxcbbackingstore.cpp \
+ qxcbwmsupport.cpp \
+ qxcbnativeinterface.cpp \
+ qxcbcursor.cpp \
+ qxcbimage.cpp \
+ qxcbxsettings.cpp \
+ qxcbsystemtraytracker.cpp
+
+HEADERS = \
+ qxcbclipboard.h \
+ qxcbconnection.h \
+ qxcbintegration.h \
+ qxcbkeyboard.h \
+ qxcbdrag.h \
+ qxcbmime.h \
+ qxcbobject.h \
+ qxcbscreen.h \
+ qxcbwindow.h \
+ qxcbbackingstore.h \
+ qxcbwmsupport.h \
+ qxcbnativeinterface.h \
+ qxcbcursor.h \
+ qxcbimage.h \
+ qxcbxsettings.h \
+ qxcbsystemtraytracker.h
+
+LIBS += $$QMAKE_LIBS_DYNLOAD
+
+DEFINES += QT_BUILD_XCB_PLUGIN
+# needed by Xcursor ...
+contains(QT_CONFIG, xcb-xlib) {
+ DEFINES += XCB_USE_XLIB
+ LIBS += -lX11 -lX11-xcb
+
+ contains(QT_CONFIG, xinput2) {
+ DEFINES += XCB_USE_XINPUT2
+ SOURCES += qxcbconnection_xi2.cpp
+ LIBS += -lXi
+ }
+}
+
+# to support custom cursors with depth > 1
+contains(QT_CONFIG, xcb-render) {
+ DEFINES += XCB_USE_RENDER
+ LIBS += -lxcb-render -lxcb-render-util
+}
+
+# build with session management support
+contains(QT_CONFIG, xcb-sm) {
+ DEFINES += XCB_USE_SM
+ LIBS += -lSM -lICE
+ SOURCES += qxcbsessionmanager.cpp
+ HEADERS += qxcbsessionmanager.h
+}
+
+include(gl_integrations/gl_integrations.pri)
+
+DEFINES += $$QMAKE_DEFINES_XCB
+LIBS += $$QMAKE_LIBS_XCB
+QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB
+QMAKE_CFLAGS += $$QMAKE_CFLAGS_XCB
+
+CONFIG += qpa/genericunixfontdatabase
+
+contains(QT_CONFIG, dbus) {
+ QT += dbus
+ LIBS += -ldbus-1
+}
+
+contains(QT_CONFIG, xcb-qt) {
+ DEFINES += XCB_USE_RENDER
+ XCB_DIR = ../../../3rdparty/xcb
+ INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude
+ LIBS += -lxcb -L$$OUT_PWD/xcb-static -lxcb-static
+} else {
+ LIBS += -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms
+ !contains(DEFINES, QT_NO_XKB):LIBS += -lxcb-xkb
+}
+
+# libxkbcommon
+contains(QT_CONFIG, xkbcommon-qt) {
+ QT_CONFIG += use-xkbcommon-x11support
+ include(../../../3rdparty/xkbcommon.pri)
+} else {
+ LIBS += $$QMAKE_LIBS_XKBCOMMON
+ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XKBCOMMON
+}
+