diff options
Diffstat (limited to 'src/plugins/platforms/xcb')
55 files changed, 2667 insertions, 705 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..75b35f4fb8 --- /dev/null +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglintegration.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** 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; + +#ifdef USE_XCB_XLIB + Display *dpy = (Display *)m_connection->xlib_display(); +#else + EGLNativeDisplayType dpy = EGL_DEFAULT_DISPLAY; +#endif + 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..e65a7bb085 --- /dev/null +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.cpp @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** 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 <QtGui/private/qguiapplication_p.h> +#include "qxcbeglwindow.h" +#include "qxcbintegration.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::NativeResourceForIntegrationFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForIntegration(const QByteArray &resource) const{ + switch (resourceType(resource)) { + case EglDisplay: + return eglDisplay; + default: + break; + } + return Q_NULLPTR; +} + +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::eglDisplay() +{ + QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration()); + QXcbEglIntegration *eglIntegration = static_cast<QXcbEglIntegration *>(integration->defaultConnection()->glIntegration()); + return eglIntegration->eglDisplay(); +} + +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..7734bcd048 --- /dev/null +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglnativeinterfacehandler.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 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::NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) const Q_DECL_OVERRIDE; + QPlatformNativeInterface::NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) const Q_DECL_OVERRIDE; + QPlatformNativeInterface::NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) const Q_DECL_OVERRIDE; +private: + static void *eglDisplay(); + 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 5777980093..73a17d69b4 100644 --- a/src/plugins/platforms/xcb/qglxintegration.h +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.h @@ -54,14 +54,14 @@ public: const QVariant &nativeHandle); ~QGLXContext(); - bool makeCurrent(QPlatformSurface *surface); - void doneCurrent(); - void swapBuffers(QPlatformSurface *surface); - void (*getProcAddress(const QByteArray &procName)) (); + bool makeCurrent(QPlatformSurface *surface) Q_DECL_OVERRIDE; + void doneCurrent() Q_DECL_OVERRIDE; + void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE; + void (*getProcAddress(const QByteArray &procName)) () Q_DECL_OVERRIDE; - QSurfaceFormat format() const; - bool isSharing() const; - bool isValid() const; + QSurfaceFormat format() const Q_DECL_OVERRIDE; + bool isSharing() const Q_DECL_OVERRIDE; + bool isValid() const Q_DECL_OVERRIDE; GLXContext glxContext() const { return m_context; } GLXFBConfig glxConfig() const { return m_config; } @@ -94,8 +94,8 @@ public: explicit QGLXPbuffer(QOffscreenSurface *offscreenSurface); ~QGLXPbuffer(); - QSurfaceFormat format() const { return m_format; } - bool isValid() const { return m_pbuffer != 0; } + QSurfaceFormat format() const Q_DECL_OVERRIDE { return m_format; } + bool isValid() const Q_DECL_OVERRIDE { return m_pbuffer != 0; } GLXPbuffer pbuffer() const { return m_pbuffer; } 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/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 0b9717759b..5c200b4058 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -287,10 +287,12 @@ void QXcbBackingStore::beginPaint(const QRegion ®ion) } } +#ifndef QT_NO_OPENGL QImage QXcbBackingStore::toImage() const { return m_image && m_image->image() ? *m_image->image() : QImage(); } +#endif void QXcbBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.h b/src/plugins/platforms/xcb/qxcbbackingstore.h index 38fb5a7ae4..3a7e124b3f 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.h +++ b/src/plugins/platforms/xcb/qxcbbackingstore.h @@ -50,18 +50,18 @@ public: QXcbBackingStore(QWindow *widget); ~QXcbBackingStore(); - QPaintDevice *paintDevice(); - void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); + QPaintDevice *paintDevice() Q_DECL_OVERRIDE; + void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) Q_DECL_OVERRIDE; #ifndef QT_NO_OPENGL void composeAndFlush(QWindow *window, const QRegion ®ion, const QPoint &offset, QPlatformTextureList *textures, QOpenGLContext *context, - bool translucentBackground); + bool translucentBackground) Q_DECL_OVERRIDE; + QImage toImage() const Q_DECL_OVERRIDE; #endif - QImage toImage() const; - void resize(const QSize &size, const QRegion &staticContents); - bool scroll(const QRegion &area, int dx, int dy); + void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE; + bool scroll(const QRegion &area, int dx, int dy) Q_DECL_OVERRIDE; - void beginPaint(const QRegion &); + void beginPaint(const QRegion &) Q_DECL_OVERRIDE; private: QXcbShmImage *m_image; diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index f56a29d985..61e9860802 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -84,7 +84,7 @@ public: } protected: - QStringList formats_sys() const + QStringList formats_sys() const Q_DECL_OVERRIDE { if (isEmpty()) return QStringList(); @@ -114,13 +114,13 @@ protected: return formatList; } - bool hasFormat_sys(const QString &format) const + bool hasFormat_sys(const QString &format) const Q_DECL_OVERRIDE { QStringList list = formats(); return list.contains(format); } - QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const + QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const Q_DECL_OVERRIDE { if (fmt.isEmpty() || isEmpty()) return QByteArray(); @@ -232,7 +232,7 @@ public: } protected: - void timerEvent(QTimerEvent *ev) + void timerEvent(QTimerEvent *ev) Q_DECL_OVERRIDE { if (ev->timerId() == abort_timer) { // this can happen when the X client we are sending data diff --git a/src/plugins/platforms/xcb/qxcbclipboard.h b/src/plugins/platforms/xcb/qxcbclipboard.h index e76d502691..5993eea326 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.h +++ b/src/plugins/platforms/xcb/qxcbclipboard.h @@ -53,11 +53,11 @@ public: QXcbClipboard(QXcbConnection *connection); ~QXcbClipboard(); - QMimeData *mimeData(QClipboard::Mode mode); - void setMimeData(QMimeData *data, QClipboard::Mode mode); + QMimeData *mimeData(QClipboard::Mode mode) Q_DECL_OVERRIDE; + void setMimeData(QMimeData *data, QClipboard::Mode mode) Q_DECL_OVERRIDE; - bool supportsMode(QClipboard::Mode mode) const; - bool ownsMode(QClipboard::Mode mode) const; + bool supportsMode(QClipboard::Mode mode) const Q_DECL_OVERRIDE; + bool ownsMode(QClipboard::Mode mode) const Q_DECL_OVERRIDE; QXcbScreen *screen() const { return m_screen; } diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 5510c3b1b4..56b4a9abda 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) { @@ -166,7 +127,7 @@ QXcbScreen* QXcbConnection::findOrCreateScreen(QList<QXcbScreen *>& newScreens, int dotPos = displayName.lastIndexOf('.'); if (dotPos != -1) displayName.truncate(dotPos); - name = displayName + QLatin1Char('.') + QString::number(screenNumber); + name = QString::fromLocal8Bit(displayName) + QLatin1Char('.') + QString::number(screenNumber); } foreach (QXcbScreen* scr, m_screens) if (scr->name() == name && scr->root() == xcbScreen->root) @@ -279,11 +240,12 @@ void QXcbConnection::updateScreens() ++xcbScreenNumber; } // for each xcb screen + QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration()); // Now activeScreens is the complete set of screens which are active at this time. // Delete any existing screens which are not in activeScreens for (int i = m_screens.count() - 1; i >= 0; --i) { if (!activeScreens.contains(m_screens[i])) { - delete m_screens[i]; + integration->destroyScreen(m_screens.at(i)); m_screens.removeAt(i); } } @@ -300,7 +262,7 @@ void QXcbConnection::updateScreens() // Now that they are in the right order, emit the added signals for new screens only foreach (QXcbScreen* screen, m_screens) if (newScreens.contains(screen)) - ((QXcbIntegration*)QGuiApplicationPrivate::platformIntegration())->screenAdded(screen); + integration->screenAdded(screen); } QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, const char *displayName) @@ -309,11 +271,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 +285,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 +304,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 +316,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 +332,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra initializeXRandr(); updateScreens(); - initializeGLX(); initializeXFixes(); initializeXRender(); m_xi2Enabled = false; @@ -405,6 +354,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")) @@ -431,14 +401,10 @@ QXcbConnection::~QXcbConnection() delete m_reader; + QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration()); // Delete screens in reverse order to avoid crash in case of multiple screens while (!m_screens.isEmpty()) - delete m_screens.takeLast(); - -#ifdef XCB_USE_EGL - if (m_has_egl) - eglTerminate(m_egl_display); -#endif //XCB_USE_EGL + integration->destroyScreen(m_screens.takeLast()); #ifdef XCB_USE_XLIB XCloseDisplay((Display *)m_xlib_display); @@ -990,51 +956,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 +1155,13 @@ xcb_window_t QXcbConnection::rootWindow() return primaryScreen()->root(); } +#ifdef XCB_USE_XLIB +void *QXcbConnection::xlib_display() const +{ + return m_xlib_display; +} +#endif + void QXcbConnection::processXcbEvents() { int connection_error = xcb_connection_has_error(xcb_connection()); @@ -1674,34 +1604,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 +1713,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 7286b6b89b..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 { @@ -295,7 +297,7 @@ class QXcbEventReader : public QThread public: QXcbEventReader(QXcbConnection *connection); - void run(); + void run() Q_DECL_OVERRIDE; QXcbEventArray *lock(); void unlock(); @@ -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/qxcbcursor.h b/src/plugins/platforms/xcb/qxcbcursor.h index 8ed23154ed..8f03f01747 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.h +++ b/src/plugins/platforms/xcb/qxcbcursor.h @@ -70,10 +70,10 @@ public: QXcbCursor(QXcbConnection *conn, QXcbScreen *screen); ~QXcbCursor(); #ifndef QT_NO_CURSOR - void changeCursor(QCursor *cursor, QWindow *widget); + void changeCursor(QCursor *cursor, QWindow *widget) Q_DECL_OVERRIDE; #endif - QPoint pos() const; - void setPos(const QPoint &pos); + QPoint pos() const Q_DECL_OVERRIDE; + void setPos(const QPoint &pos) Q_DECL_OVERRIDE; static void queryPointer(QXcbConnection *c, xcb_window_t *rootWin, QPoint *pos, int *keybMask = 0); diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 7037e102e2..5de5b6bb55 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -117,9 +117,9 @@ public: ~QXcbDropData(); protected: - bool hasFormat_sys(const QString &mimeType) const; - QStringList formats_sys() const; - QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const; + bool hasFormat_sys(const QString &mimeType) const Q_DECL_OVERRIDE; + QStringList formats_sys() const Q_DECL_OVERRIDE; + QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const Q_DECL_OVERRIDE; QVariant xdndObtainData(const QByteArray &format, QVariant::Type requestedType) const; diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index e273492837..1bca9a036f 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -68,14 +68,14 @@ public: QXcbDrag(QXcbConnection *c); ~QXcbDrag(); - virtual QMimeData *platformDropData(); + virtual QMimeData *platformDropData() Q_DECL_OVERRIDE; - void startDrag(); - void cancel(); - void move(const QMouseEvent *me); - void drop(const QMouseEvent *me); - void endDrag(); + void startDrag() Q_DECL_OVERRIDE; + void cancel() Q_DECL_OVERRIDE; + void move(const QMouseEvent *me) Q_DECL_OVERRIDE; + void drop(const QMouseEvent *me) Q_DECL_OVERRIDE; + void endDrag() Q_DECL_OVERRIDE; void handleEnter(QWindow *window, const xcb_client_message_event_t *event); void handlePosition(QWindow *w, const xcb_client_message_event_t *event); @@ -92,7 +92,7 @@ public: xcb_timestamp_t targetTime() { return target_time; } protected: - void timerEvent(QTimerEvent* e); + void timerEvent(QTimerEvent* e) Q_DECL_OVERRIDE; private: friend class QXcbDropData; 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 f0c4a7f691..352d3255e4 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> @@ -177,7 +169,7 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char #ifdef Q_XCB_DEBUG qDebug() << "QXcbIntegration: Connecting to additional display: " << parameters.at(i) << parameters.at(i+1); #endif - QString display = parameters.at(i) + ':' + parameters.at(i+1); + QString display = parameters.at(i) + QLatin1Char(':') + parameters.at(i+1); m_connections << new QXcbConnection(m_nativeInterface.data(), display.toLatin1().constData()); } @@ -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 db6ad541ea..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,51 +46,51 @@ class QAbstractEventDispatcher; class QXcbNativeInterface; class QXcbScreen; -class QXcbIntegration : public QPlatformIntegration +class Q_XCB_EXPORT QXcbIntegration : public QPlatformIntegration { public: QXcbIntegration(const QStringList ¶meters, int &argc, char **argv); ~QXcbIntegration(); - QPlatformWindow *createPlatformWindow(QWindow *window) const; + QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE; #ifndef QT_NO_OPENGL - QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; + QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE; #endif - QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; + QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE; - QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const; + QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE; - bool hasCapability(Capability cap) const; - QAbstractEventDispatcher *createEventDispatcher() const; - void initialize(); + bool hasCapability(Capability cap) const Q_DECL_OVERRIDE; + QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE; + void initialize() Q_DECL_OVERRIDE; void moveToScreen(QWindow *window, int screen); - QPlatformFontDatabase *fontDatabase() const; + QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE; - QPlatformNativeInterface *nativeInterface()const; + QPlatformNativeInterface *nativeInterface()const Q_DECL_OVERRIDE; #ifndef QT_NO_CLIPBOARD - QPlatformClipboard *clipboard() const; + QPlatformClipboard *clipboard() const Q_DECL_OVERRIDE; #endif #ifndef QT_NO_DRAGANDDROP - QPlatformDrag *drag() const; + QPlatformDrag *drag() const Q_DECL_OVERRIDE; #endif - QPlatformInputContext *inputContext() const; + QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE; #ifndef QT_NO_ACCESSIBILITY - QPlatformAccessibility *accessibility() const; + QPlatformAccessibility *accessibility() const Q_DECL_OVERRIDE; #endif - QPlatformServices *services() const; + QPlatformServices *services() const Q_DECL_OVERRIDE; - Qt::KeyboardModifiers queryKeyboardModifiers() const; - QList<int> possibleKeys(const QKeyEvent *e) const; + Qt::KeyboardModifiers queryKeyboardModifiers() const Q_DECL_OVERRIDE; + QList<int> possibleKeys(const QKeyEvent *e) const Q_DECL_OVERRIDE; - QStringList themeNames() const; - QPlatformTheme *createPlatformTheme(const QString &name) const; - QVariant styleHint(StyleHint hint) const; + QStringList themeNames() const Q_DECL_OVERRIDE; + QPlatformTheme *createPlatformTheme(const QString &name) const Q_DECL_OVERRIDE; + QVariant styleHint(StyleHint hint) const Q_DECL_OVERRIDE; QXcbConnection *defaultConnection() const { return m_connections.first(); } @@ -98,7 +100,7 @@ public: QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const Q_DECL_OVERRIDE; #endif - void sync(); + void sync() Q_DECL_OVERRIDE; private: QList<QXcbConnection *> m_connections; diff --git a/src/plugins/platforms/xcb/qxcbmain.cpp b/src/plugins/platforms/xcb/qxcbmain.cpp index 80de5ba6f1..921c71711e 100644 --- a/src/plugins/platforms/xcb/qxcbmain.cpp +++ b/src/plugins/platforms/xcb/qxcbmain.cpp @@ -41,7 +41,7 @@ class QXcbIntegrationPlugin : public QPlatformIntegrationPlugin Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "xcb.json") public: - QPlatformIntegration *create(const QString&, const QStringList&, int &, char **); + QPlatformIntegration *create(const QString&, const QStringList&, int &, char **) Q_DECL_OVERRIDE; }; QPlatformIntegration* QXcbIntegrationPlugin::create(const QString& system, const QStringList& parameters, int &argc, char **argv) diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 3058b29f2d..956b0f83d2 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); } @@ -208,10 +199,26 @@ void QXcbNativeInterface::clearRegion(const QWindow *qwindow, const QRect& rect) } } +void QXcbNativeInterface::setParentRelativeBackPixmap(const QWindow *qwindow) +{ + if (const QPlatformWindow *platformWindow = qwindow->handle()) { + const QXcbWindow *qxwindow = static_cast<const QXcbWindow *>(platformWindow); + xcb_connection_t *xcb_conn = qxwindow->xcb_connection(); + + const quint32 mask = XCB_CW_BACK_PIXMAP; + const quint32 values[] = { XCB_BACK_PIXMAP_PARENT_RELATIVE }; + Q_XCB_CALL(xcb_change_window_attributes(xcb_conn, qxwindow->xcb_window(), mask, values)); + } +} + 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; @@ -221,6 +228,9 @@ void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resour case RootWindow: result = rootWindow(); break; + case Display: + result = display(); + break; default: break; } @@ -230,32 +240,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(); @@ -291,14 +289,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; @@ -312,17 +311,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") @@ -330,8 +354,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); } @@ -380,6 +424,17 @@ void *QXcbNativeInterface::rootWindow() return 0; } +void *QXcbNativeInterface::display() +{ +#ifdef XCB_USE_XLIB + QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration()); + QXcbConnection *defaultConnection = integration->defaultConnection(); + return defaultConnection->xlib_display(); +#else + return 0; +#endif +} + void QXcbNativeInterface::setAppTime(QScreen* screen, xcb_timestamp_t time) { static_cast<QXcbScreen *>(screen->handle())->connection()->setTime(time); @@ -399,15 +454,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; @@ -430,17 +476,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); @@ -453,54 +488,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; } -void *QXcbNativeInterface::glxConfigForContext(QOpenGLContext *context) +QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::handlerNativeResourceFunctionForScreen(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); + NativeResourceForScreenFunction result = handler->nativeResourceFunctionForScreen(resource); + if (result) + return result; + } + return Q_NULLPTR; +} + +QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterface::handlerNativeResourceFunctionForWindow(const QByteArray &resource) const +{ + 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 b667f1a372..b2044e6ee9 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); @@ -95,21 +95,21 @@ public: void *startupId(); void *x11Screen(); void *rootWindow(); + void *display(); 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; Q_INVOKABLE void clearRegion(const QWindow *qwindow, const QRect& rect); + Q_INVOKABLE void setParentRelativeBackPixmap(const QWindow *window); Q_INVOKABLE bool systrayVisualHasAlphaChannel(); 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); @@ -122,6 +122,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.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 8bdedba8ac..def6e2ce9a 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -320,7 +320,7 @@ QDpi QXcbScreen::logicalDpi() const qreal QXcbScreen::devicePixelRatio() const { - static int override_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toInt(); + static int override_dpr = qEnvironmentVariableIntValue("QT_DEVICE_PIXEL_RATIO"); static bool auto_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto"; if (override_dpr > 0) return override_dpr; diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index ca0aee2cc4..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,28 +51,28 @@ 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, xcb_randr_get_output_info_reply_t *output, QString outputName, int number); ~QXcbScreen(); - QPixmap grabWindow(WId window, int x, int y, int width, int height) const; - - QWindow *topLevelAt(const QPoint &point) const; - - QRect geometry() const { return m_geometry; } - QRect availableGeometry() const {return m_availableGeometry;} - int depth() const { return m_screen->root_depth; } - QImage::Format format() const; - QSizeF physicalSize() const { return m_sizeMillimeters; } - QDpi logicalDpi() const; - qreal devicePixelRatio() const; - QPlatformCursor *cursor() const; - qreal refreshRate() const { return m_refreshRate; } - Qt::ScreenOrientation orientation() const { return m_orientation; } - QList<QPlatformScreen *> virtualSiblings() const { return m_siblings; } + QPixmap grabWindow(WId window, int x, int y, int width, int height) const Q_DECL_OVERRIDE; + + QWindow *topLevelAt(const QPoint &point) const Q_DECL_OVERRIDE; + + QRect geometry() const Q_DECL_OVERRIDE { return m_geometry; } + QRect availableGeometry() const Q_DECL_OVERRIDE {return m_availableGeometry;} + int depth() const Q_DECL_OVERRIDE { return m_screen->root_depth; } + QImage::Format format() const Q_DECL_OVERRIDE; + QSizeF physicalSize() const Q_DECL_OVERRIDE { return m_sizeMillimeters; } + QDpi logicalDpi() const Q_DECL_OVERRIDE; + qreal devicePixelRatio() const Q_DECL_OVERRIDE; + QPlatformCursor *cursor() const Q_DECL_OVERRIDE; + qreal refreshRate() const Q_DECL_OVERRIDE { return m_refreshRate; } + Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE { return m_orientation; } + QList<QPlatformScreen *> virtualSiblings() const Q_DECL_OVERRIDE { return m_siblings; } void setVirtualSiblings(QList<QPlatformScreen *> sl) { m_siblings = sl; } int screenNumber() const { return m_number; } @@ -88,7 +89,7 @@ public: const xcb_visualtype_t *visualForId(xcb_visualid_t) const; quint8 depthOfVisual(xcb_visualid_t) const; - QString name() const { return m_outputName; } + QString name() const Q_DECL_OVERRIDE { return m_outputName; } void handleScreenChange(xcb_randr_screen_change_notify_event_t *change_event); void updateGeometry(xcb_timestamp_t timestamp); diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.h b/src/plugins/platforms/xcb/qxcbsystemtraytracker.h index 2e297c4ae5..2f364d3e55 100644 --- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.h +++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.h @@ -55,7 +55,7 @@ public: void notifyManagerClientMessageEvent(const xcb_client_message_event_t *); - void handleDestroyNotifyEvent(const xcb_destroy_notify_event_t *); + void handleDestroyNotifyEvent(const xcb_destroy_notify_event_t *) Q_DECL_OVERRIDE; signals: void systemTrayWindowChanged(QScreen *screen); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index e1ccc3f086..4d14dd14a3 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,12 @@ void QXcbWindow::create() window()->setFormat(parentFormat); } } - m_format = window()->requestedFormat(); -#if (defined(XCB_USE_GLX) || defined(XCB_USE_EGL)) && defined(XCB_USE_XLIB) + resolveFormat(); + +#ifdef XCB_USE_XLIB 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 +338,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); @@ -386,9 +360,9 @@ void QXcbWindow::create() XFree(visualInfo); } } +#endif 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 +423,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 +548,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 +1524,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 12d20d004d..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 { @@ -71,45 +70,45 @@ public: QXcbWindow(QWindow *window); ~QXcbWindow(); - void setGeometry(const QRect &rect); + void setGeometry(const QRect &rect) Q_DECL_OVERRIDE; - QMargins frameMargins() const; + QMargins frameMargins() const Q_DECL_OVERRIDE; - void setVisible(bool visible); - void setWindowFlags(Qt::WindowFlags flags); - void setWindowState(Qt::WindowState state); - WId winId() const; - void setParent(const QPlatformWindow *window); + void setVisible(bool visible) Q_DECL_OVERRIDE; + void setWindowFlags(Qt::WindowFlags flags) Q_DECL_OVERRIDE; + void setWindowState(Qt::WindowState state) Q_DECL_OVERRIDE; + WId winId() const Q_DECL_OVERRIDE; + void setParent(const QPlatformWindow *window) Q_DECL_OVERRIDE; - bool isExposed() const; - bool isEmbedded(const QPlatformWindow *parentWindow) const; - QPoint mapToGlobal(const QPoint &pos) const; - QPoint mapFromGlobal(const QPoint &pos) const; + bool isExposed() const Q_DECL_OVERRIDE; + bool isEmbedded(const QPlatformWindow *parentWindow) const Q_DECL_OVERRIDE; + QPoint mapToGlobal(const QPoint &pos) const Q_DECL_OVERRIDE; + QPoint mapFromGlobal(const QPoint &pos) const Q_DECL_OVERRIDE; - void setWindowTitle(const QString &title); - void setWindowIcon(const QIcon &icon); - void raise(); - void lower(); - void propagateSizeHints(); + void setWindowTitle(const QString &title) Q_DECL_OVERRIDE; + void setWindowIcon(const QIcon &icon) Q_DECL_OVERRIDE; + void raise() Q_DECL_OVERRIDE; + void lower() Q_DECL_OVERRIDE; + void propagateSizeHints() Q_DECL_OVERRIDE; - void requestActivateWindow(); + void requestActivateWindow() Q_DECL_OVERRIDE; - bool setKeyboardGrabEnabled(bool grab); - bool setMouseGrabEnabled(bool grab); + bool setKeyboardGrabEnabled(bool grab) Q_DECL_OVERRIDE; + bool setMouseGrabEnabled(bool grab) Q_DECL_OVERRIDE; void setCursor(xcb_cursor_t cursor); - QSurfaceFormat format() const; + QSurfaceFormat format() const Q_DECL_OVERRIDE; - void windowEvent(QEvent *event); + void windowEvent(QEvent *event) Q_DECL_OVERRIDE; - bool startSystemResize(const QPoint &pos, Qt::Corner corner); + bool startSystemResize(const QPoint &pos, Qt::Corner corner) Q_DECL_OVERRIDE; - void setOpacity(qreal level); - void setMask(const QRegion ®ion); + void setOpacity(qreal level) Q_DECL_OVERRIDE; + void setMask(const QRegion ®ion) Q_DECL_OVERRIDE; - void setAlertState(bool enabled); - bool isAlertState() const { return m_alertState; } + void setAlertState(bool enabled) Q_DECL_OVERRIDE; + bool isAlertState() const Q_DECL_OVERRIDE { return m_alertState; } xcb_window_t xcb_window() const { return m_window; } uint depth() const { return m_depth; } @@ -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; @@ -152,12 +147,18 @@ public: void postSyncWindowRequest(); void clearSyncWindowRequest() { m_pendingSyncRequest = 0; } - qreal devicePixelRatio() const; + 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 129076c916..09ab1ad77a 100644 --- a/src/plugins/platforms/xcb/xcb-plugin.pro +++ b/src/plugins/platforms/xcb/xcb-plugin.pro @@ -5,117 +5,9 @@ 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 - + 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 +} + |