Make GLX and EGL dynamic dependencies for xcb

[ChangeLog][QPA][Xcb] GLX and EGL code paths are now dynamically
resolved, making it possible for one build of a plugin to use both code
paths. Default is to use the GLX code path if available. This can be
overwritten by specifying QT_XCB_GL_INTEGRATION=xcb_egl as an
evnironment variable. Enable qt.xcb.glintegration.debug to get debug log
output of what integration is used

Change-Id: Ia9fa95fcca3d901b91dadb8c98a695fea0ae3b1e
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
This commit is contained in:
Jørgen Lind 2014-09-10 16:31:32 +02:00 committed by Jørgen Lind
parent eb2014382b
commit 8758f532ae
48 changed files with 2578 additions and 602 deletions

View File

@ -9,6 +9,7 @@ QMAKE_DOCS = $$PWD/doc/qtgui.qdocconf
MODULE_PLUGIN_TYPES = \ MODULE_PLUGIN_TYPES = \
platforms \ platforms \
xcbglintegrations \
platformthemes \ platformthemes \
platforminputcontexts \ platforminputcontexts \
generic \ generic \

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,108 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qxcbeglintegration.h"
#include "qxcbeglcontext.h"
#include <QtGui/QOffscreenSurface>
#include "qxcbeglnativeinterfacehandler.h"
QT_BEGIN_NAMESPACE
QXcbEglIntegration::QXcbEglIntegration()
: m_connection(Q_NULLPTR)
, m_egl_display(EGL_NO_DISPLAY)
{
qCDebug(QT_XCB_GLINTEGRATION) << "Xcb EGL gl-integration created";
}
QXcbEglIntegration::~QXcbEglIntegration()
{
if (m_egl_display != EGL_NO_DISPLAY)
eglTerminate(m_egl_display);
}
bool QXcbEglIntegration::initialize(QXcbConnection *connection)
{
m_connection = connection;
Display *dpy = (Display *)m_connection->xlib_display();
m_egl_display = eglGetDisplay(dpy);
EGLint major, minor;
bool success = eglInitialize(m_egl_display, &major, &minor);
if (!success) {
m_egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
qCDebug(QT_XCB_GLINTEGRATION) << "Xcb EGL gl-integration retrying with display" << m_egl_display;
success = eglInitialize(m_egl_display, &major, &minor);
}
m_native_interface_handler.reset(new QXcbEglNativeInterfaceHandler(connection->nativeInterface()));
qCDebug(QT_XCB_GLINTEGRATION) << "Xcb EGL gl-integration successfully initialized";
return success;
}
QXcbWindow *QXcbEglIntegration::createWindow(QWindow *window) const
{
return new QXcbEglWindow(window, const_cast<QXcbEglIntegration *>(this));
}
QPlatformOpenGLContext *QXcbEglIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
QXcbEglContext *platformContext = new QXcbEglContext(context->format(),
context->shareHandle(),
eglDisplay(),
screen->connection(),
context->nativeHandle());
context->setNativeHandle(platformContext->nativeHandle());
return platformContext;
}
QPlatformOffscreenSurface *QXcbEglIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
{
return new QEGLPbuffer(eglDisplay(), surface->requestedFormat(), surface);
}
QT_END_NAMESPACE

View File

@ -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

View File

@ -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"

View File

@ -0,0 +1,120 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qxcbeglnativeinterfacehandler.h"
#include "qxcbeglwindow.h"
#include "qxcbeglintegration.h"
#include "qxcbeglcontext.h"
QT_BEGIN_NAMESPACE
static int resourceType(const QByteArray &key)
{
static const QByteArray names[] = { // match QXcbEglNativeInterfaceHandler::ResourceType
QByteArrayLiteral("egldisplay"),
QByteArrayLiteral("eglcontext"),
QByteArrayLiteral("eglconfig")
};
for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
if (key == names[i])
return i;
}
if (key == QByteArrayLiteral("get_egl_context"))
return QXcbEglNativeInterfaceHandler::EglContext;
return sizeof(names) / sizeof(names[0]);
}
QXcbEglNativeInterfaceHandler::QXcbEglNativeInterfaceHandler(QXcbNativeInterface *nativeInterface)
: QXcbNativeInterfaceHandler(nativeInterface)
{
}
QPlatformNativeInterface::NativeResourceForContextFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForContext(const QByteArray &resource) const
{
switch (resourceType(resource)) {
case EglContext:
return eglContextForContext;
case EglConfig:
return eglConfigForContext;
default:
break;
}
return Q_NULLPTR;
}
QPlatformNativeInterface::NativeResourceForWindowFunction QXcbEglNativeInterfaceHandler::nativeResourceFunctionForWindow(const QByteArray &resource) const
{
switch (resourceType(resource)) {
case EglDisplay:
return eglDisplayForWindow;
default:
break;
}
return Q_NULLPTR;
}
void *QXcbEglNativeInterfaceHandler::eglDisplayForWindow(QWindow *window)
{
Q_ASSERT(window);
Q_ASSERT(window->handle());
if (window->supportsOpenGL())
return static_cast<QXcbEglWindow *>(window->handle())->glIntegration()->eglDisplay();
return Q_NULLPTR;
}
void *QXcbEglNativeInterfaceHandler::eglContextForContext(QOpenGLContext *context)
{
Q_ASSERT(context);
Q_ASSERT(context->handle());
return static_cast<QXcbEglContext *>(context->handle())->eglContext();
}
void *QXcbEglNativeInterfaceHandler::eglConfigForContext(QOpenGLContext *context)
{
Q_ASSERT(context);
Q_ASSERT(context->handle());
return static_cast<QXcbEglContext *>(context->handle())->eglConfig();
}
QT_END_NAMESPACE

View File

@ -0,0 +1,70 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QXCBEGLNATIVEINTERFACEHANDLER_H
#define QXCBEGLNATIVEINTERFACEHANDLER_H
#include "qxcbnativeinterfacehandler.h"
QT_BEGIN_NAMESPACE
class QXcbEglNativeInterfaceHandler : public QXcbNativeInterfaceHandler
{
public:
enum ResourceType {
EglDisplay,
EglContext,
EglConfig
};
QXcbEglNativeInterfaceHandler(QXcbNativeInterface *nativeInterface);
QPlatformNativeInterface::NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) const Q_DECL_OVERRIDE;
QPlatformNativeInterface::NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) const Q_DECL_OVERRIDE;
private:
static void *eglDisplayForWindow(QWindow *window);
static void *eglContextForContext(QOpenGLContext *context);
static void *eglConfigForContext(QOpenGLContext *context);
};
QT_END_NAMESPACE
#endif //QXCBEGLNATIVEINTERFACEHANDLER_H

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,3 @@
{
"Keys": [ "xcb_egl" ]
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,3 @@
{
"Keys": [ "xcb_glx" ]
}

View File

@ -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

View File

@ -44,6 +44,8 @@
#include "qxcbnativeinterface.h" #include "qxcbnativeinterface.h"
#include "qxcbintegration.h" #include "qxcbintegration.h"
#include "qxcbsystemtraytracker.h" #include "qxcbsystemtraytracker.h"
#include "qxcbglintegrationfactory.h"
#include "qxcbglintegration.h"
#include <QSocketNotifier> #include <QSocketNotifier>
#include <QAbstractEventDispatcher> #include <QAbstractEventDispatcher>
@ -74,14 +76,6 @@
#include <xcb/render.h> #include <xcb/render.h>
#endif #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 QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpaXInput, "qt.qpa.input") Q_LOGGING_CATEGORY(lcQpaXInput, "qt.qpa.input")
@ -121,39 +115,6 @@ static int ioErrorHandler(Display *dpy)
} }
#endif #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, QXcbScreen* QXcbConnection::findOrCreateScreen(QList<QXcbScreen *>& newScreens,
int screenNumber, xcb_screen_t* xcbScreen, xcb_randr_get_output_info_reply_t *output) int screenNumber, xcb_screen_t* xcbScreen, xcb_randr_get_output_info_reply_t *output)
{ {
@ -309,11 +270,12 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
, m_primaryScreenNumber(0) , m_primaryScreenNumber(0)
, m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY")) , m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY"))
, m_nativeInterface(nativeInterface) , m_nativeInterface(nativeInterface)
#ifdef XCB_USE_XLIB
, m_xlib_display(0)
#endif
, xfixes_first_event(0) , xfixes_first_event(0)
, xrandr_first_event(0) , xrandr_first_event(0)
, xkb_first_event(0) , xkb_first_event(0)
, glx_first_event(0)
, has_glx_extension(false)
, has_shape_extension(false) , has_shape_extension(false)
, has_randr_extension(false) , has_randr_extension(false)
, has_input_shape(false) , has_input_shape(false)
@ -322,14 +284,10 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
, m_buttons(0) , m_buttons(0)
, m_focusWindow(0) , m_focusWindow(0)
, m_systemTrayTracker(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 #ifdef XCB_USE_XLIB
dpy = XOpenDisplay(m_displayName.constData()); Display *dpy = XOpenDisplay(m_displayName.constData());
if (dpy) { if (dpy) {
m_primaryScreenNumber = DefaultScreen(dpy); m_primaryScreenNumber = DefaultScreen(dpy);
m_connection = XGetXCBConnection(dpy); m_connection = XGetXCBConnection(dpy);
@ -345,12 +303,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
if (!m_connection || xcb_connection_has_error(m_connection)) if (!m_connection || xcb_connection_has_error(m_connection))
qFatal("QXcbConnection: Could not connect to display %s", m_displayName.constData()); 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 = new QXcbEventReader(this);
m_reader->start(); m_reader->start();
@ -362,9 +314,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
#endif #endif
#ifdef XCB_USE_RENDER #ifdef XCB_USE_RENDER
&xcb_render_id, &xcb_render_id,
#endif
#ifdef XCB_HAS_XCB_GLX
&xcb_glx_id,
#endif #endif
0 0
}; };
@ -382,7 +331,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
initializeXRandr(); initializeXRandr();
updateScreens(); updateScreens();
initializeGLX();
initializeXFixes(); initializeXFixes();
initializeXRender(); initializeXRender();
m_xi2Enabled = false; m_xi2Enabled = false;
@ -405,6 +353,27 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
if (!m_startupId.isNull()) if (!m_startupId.isNull())
qunsetenv("DESKTOP_STARTUP_ID"); 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(); sync();
if (qEnvironmentVariableIsEmpty("QT_IM_MODULE")) if (qEnvironmentVariableIsEmpty("QT_IM_MODULE"))
@ -435,11 +404,6 @@ QXcbConnection::~QXcbConnection()
while (!m_screens.isEmpty()) while (!m_screens.isEmpty())
delete m_screens.takeLast(); delete m_screens.takeLast();
#ifdef XCB_USE_EGL
if (m_has_egl)
eglTerminate(m_egl_display);
#endif //XCB_USE_EGL
#ifdef XCB_USE_XLIB #ifdef XCB_USE_XLIB
XCloseDisplay((Display *)m_xlib_display); XCloseDisplay((Display *)m_xlib_display);
#else #else
@ -990,51 +954,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
} }
} }
#ifdef XCB_USE_XLIB if (!handled)
if (!handled) { handled = m_glIntegration->handleXcbEvent(event, response_type);
// 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) if (handled)
printXcbEvent("Handled XCB event", event); printXcbEvent("Handled XCB event", event);
@ -1232,6 +1153,11 @@ xcb_window_t QXcbConnection::rootWindow()
return primaryScreen()->root(); return primaryScreen()->root();
} }
void *QXcbConnection::xlib_display() const
{
return m_xlib_display;
}
void QXcbConnection::processXcbEvents() void QXcbConnection::processXcbEvents()
{ {
int connection_error = xcb_connection_has_error(xcb_connection()); int connection_error = xcb_connection_has_error(xcb_connection());
@ -1674,34 +1600,6 @@ void QXcbConnection::initializeXRender()
#endif #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() void QXcbConnection::initializeXRandr()
{ {
const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection, &xcb_randr_id); const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection, &xcb_randr_id);
@ -1811,13 +1709,6 @@ void QXcbConnection::initializeXKB()
#endif #endif
} }
#if defined(XCB_USE_EGL)
bool QXcbConnection::hasEgl() const
{
return m_has_egl;
}
#endif // defined(XCB_USE_EGL)
#if defined(XCB_USE_XINPUT2) #if defined(XCB_USE_XINPUT2)
static int xi2ValuatorOffset(unsigned char *maskPtr, int maskLen, int number) static int xi2ValuatorOffset(unsigned char *maskPtr, int maskLen, int number)
{ {

View File

@ -36,6 +36,7 @@
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include "qxcbexport.h"
#include <QHash> #include <QHash>
#include <QList> #include <QList>
#include <QMutex> #include <QMutex>
@ -85,6 +86,7 @@ class QXcbClipboard;
class QXcbWMSupport; class QXcbWMSupport;
class QXcbNativeInterface; class QXcbNativeInterface;
class QXcbSystemTrayTracker; class QXcbSystemTrayTracker;
class QXcbGlIntegration;
namespace QXcbAtom { namespace QXcbAtom {
enum Atom { enum Atom {
@ -360,7 +362,7 @@ private:
}; };
class QAbstractEventDispatcher; class QAbstractEventDispatcher;
class QXcbConnection : public QObject class Q_XCB_EXPORT QXcbConnection : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -395,15 +397,9 @@ public:
QXcbWMSupport *wmSupport() const { return m_wmSupport.data(); } QXcbWMSupport *wmSupport() const { return m_wmSupport.data(); }
xcb_window_t rootWindow(); xcb_window_t rootWindow();
#ifdef XCB_USE_XLIB #ifdef XCB_USE_XLIB
void *xlib_display() const { return m_xlib_display; } void *xlib_display() const;
#endif #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) #if defined(XCB_USE_XINPUT2)
void xi2Select(xcb_window_t window); void xi2Select(xcb_window_t window);
#endif #endif
@ -437,7 +433,6 @@ public:
inline xcb_timestamp_t netWmUserTime() const { return m_netWmUserTime; } inline xcb_timestamp_t netWmUserTime() const { return m_netWmUserTime; }
inline void setNetWmUserTime(xcb_timestamp_t t) { if (t > m_netWmUserTime) m_netWmUserTime = t; } 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 hasXFixes() const { return xfixes_first_event > 0; }
bool hasXShape() const { return has_shape_extension; } bool hasXShape() const { return has_shape_extension; }
bool hasXRandr() const { return has_randr_extension; } bool hasXRandr() const { return has_randr_extension; }
@ -446,6 +441,7 @@ public:
bool hasXKB() const { return has_xkb; } bool hasXKB() const { return has_xkb; }
bool supportsThreadedRendering() const { return m_reader->isRunning(); } bool supportsThreadedRendering() const { return m_reader->isRunning(); }
bool threadedEventHandling() const { return m_reader->isRunning(); }
xcb_timestamp_t getTimestamp(); xcb_timestamp_t getTimestamp();
@ -472,6 +468,8 @@ public:
QXcbEventReader *eventReader() const { return m_reader; } QXcbEventReader *eventReader() const { return m_reader; }
bool canGrab() const { return m_canGrabServer; } bool canGrab() const { return m_canGrabServer; }
QXcbGlIntegration *glIntegration() const { return m_glIntegration; }
protected: protected:
bool event(QEvent *e) Q_DECL_OVERRIDE; bool event(QEvent *e) Q_DECL_OVERRIDE;
@ -484,7 +482,6 @@ private slots:
private: private:
void initializeAllAtoms(); void initializeAllAtoms();
void sendConnectionEvent(QXcbAtom::Atom atom, uint id = 0); void sendConnectionEvent(QXcbAtom::Atom atom, uint id = 0);
void initializeGLX();
void initializeXFixes(); void initializeXFixes();
void initializeXRender(); void initializeXRender();
void initializeXRandr(); void initializeXRandr();
@ -580,10 +577,6 @@ private:
QHash<int, QWindowSystemInterface::TouchPoint> m_touchPoints; QHash<int, QWindowSystemInterface::TouchPoint> m_touchPoints;
QHash<int, XInput2TouchDeviceData*> m_touchDevices; QHash<int, XInput2TouchDeviceData*> m_touchDevices;
#endif #endif
#if defined(XCB_USE_EGL)
void *m_egl_display;
bool m_has_egl;
#endif
#ifdef Q_XCB_DEBUG #ifdef Q_XCB_DEBUG
struct CallInfo { struct CallInfo {
int sequence; int sequence;
@ -604,9 +597,7 @@ private:
uint32_t xfixes_first_event; uint32_t xfixes_first_event;
uint32_t xrandr_first_event; uint32_t xrandr_first_event;
uint32_t xkb_first_event; uint32_t xkb_first_event;
uint32_t glx_first_event;
bool has_glx_extension;
bool has_shape_extension; bool has_shape_extension;
bool has_randr_extension; bool has_randr_extension;
bool has_input_shape; bool has_input_shape;
@ -619,6 +610,7 @@ private:
QByteArray m_startupId; QByteArray m_startupId;
QXcbSystemTrayTracker *m_systemTrayTracker; QXcbSystemTrayTracker *m_systemTrayTracker;
QXcbGlIntegration *m_glIntegration;
friend class QXcbEventReader; friend class QXcbEventReader;
}; };
@ -668,11 +660,6 @@ cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection,
#define Q_XCB_NOOP(c) #define Q_XCB_NOOP(c)
#endif #endif
#if defined(XCB_USE_EGL)
#define EGL_DISPLAY_FROM_XCB(object) ((EGLDisplay)(object->connection()->egl_display()))
#endif
QT_END_NAMESPACE QT_END_NAMESPACE
#endif #endif

View File

@ -31,34 +31,19 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef QXCBEGLSURFACE_H #ifndef QXCBEXPORT_H
#define QXCBEGLSURFACE_H #define QXCBEXPORT_H
#include <EGL/egl.h> #include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QXcbEGLSurface # if defined(QT_BUILD_XCB_PLUGIN)
{ # define Q_XCB_EXPORT Q_DECL_EXPORT
public: # else
QXcbEGLSurface(EGLDisplay display, EGLSurface surface) # define Q_XCB_EXPORT Q_DECL_IMPORT
: m_display(display) # endif
, m_surface(surface)
{
}
~QXcbEGLSurface()
{
eglDestroySurface(m_display, m_surface);
}
EGLSurface surface() const { return m_surface; }
private:
EGLDisplay m_display;
EGLSurface m_surface;
};
QT_END_NAMESPACE QT_END_NAMESPACE
#endif //QXCBEXPORT_H
#endif

View File

@ -41,6 +41,7 @@
#include "qxcbnativeinterface.h" #include "qxcbnativeinterface.h"
#include "qxcbclipboard.h" #include "qxcbclipboard.h"
#include "qxcbdrag.h" #include "qxcbdrag.h"
#include "qxcbglintegration.h"
#ifndef QT_NO_SESSIONMANAGER #ifndef QT_NO_SESSIONMANAGER
#include "qxcbsessionmanager.h" #include "qxcbsessionmanager.h"
@ -69,15 +70,6 @@
#include <private/qgenericunixthemes_p.h> #include <private/qgenericunixthemes_p.h>
#include <qpa/qplatforminputcontext.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/QOpenGLContext>
#include <QtGui/QScreen> #include <QtGui/QScreen>
#include <QtGui/QOffscreenSurface> #include <QtGui/QOffscreenSurface>
@ -191,82 +183,32 @@ QXcbIntegration::~QXcbIntegration()
QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const
{ {
return new QXcbWindow(window); 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;
}
}
Q_ASSERT(window->type() == Qt::Desktop || !window->supportsOpenGL());
QXcbWindow *xcbWindow = new QXcbWindow(window);
xcbWindow->create();
return xcbWindow;
} }
#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()));
}
private:
QXcbConnection *m_connection;
};
#endif
#ifndef QT_NO_OPENGL #ifndef QT_NO_OPENGL
QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{ {
QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle()); QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
#if defined(XCB_USE_GLX) QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
QGLXContext *platformContext = new QGLXContext(screen, context->format(), if (!glIntegration) {
context->shareHandle(), context->nativeHandle()); qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
context->setNativeHandle(platformContext->nativeHandle()); return Q_NULLPTR;
return platformContext; }
#elif defined(XCB_USE_EGL) return glIntegration->createPlatformOpenGLContext(context);
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
} }
#endif #endif
@ -277,45 +219,23 @@ QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *wind
QPlatformOffscreenSurface *QXcbIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const 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()); QXcbScreen *screen = static_cast<QXcbScreen *>(surface->screen()->handle());
return new QEGLPbuffer(screen->connection()->egl_display(), surface->requestedFormat(), surface); QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
#else if (!glIntegration) {
Q_UNUSED(surface); qWarning("QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled");
qWarning("QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled"); return Q_NULLPTR;
return 0; }
#endif return glIntegration->createPlatformOffscreenSurface(surface);
} }
bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{ {
switch (cap) { switch (cap) {
case ThreadedPixmaps: return true; case ThreadedPixmaps: return true;
#if defined(XCB_USE_GLX) case OpenGL: return m_connections.first()->glIntegration();
case OpenGL: return m_connections.at(0)->hasGLX(); case ThreadedOpenGL: return m_connections.at(0)->threadedEventHandling()
#elif defined(XCB_USE_EGL) && m_connections.at(0)->glIntegration()
case OpenGL: return true; && m_connections.at(0)->glIntegration()->supportsThreadedOpenGL();
#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 WindowMasks: return true; case WindowMasks: return true;
case MultipleWindows: return true; case MultipleWindows: return true;
case ForeignWindows: return true; case ForeignWindows: return true;

View File

@ -37,6 +37,8 @@
#include <qpa/qplatformintegration.h> #include <qpa/qplatformintegration.h>
#include <qpa/qplatformscreen.h> #include <qpa/qplatformscreen.h>
#include "qxcbexport.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QXcbConnection; class QXcbConnection;
@ -44,7 +46,7 @@ class QAbstractEventDispatcher;
class QXcbNativeInterface; class QXcbNativeInterface;
class QXcbScreen; class QXcbScreen;
class QXcbIntegration : public QPlatformIntegration class Q_XCB_EXPORT QXcbIntegration : public QPlatformIntegration
{ {
public: public:
QXcbIntegration(const QStringList &parameters, int &argc, char **argv); QXcbIntegration(const QStringList &parameters, int &argc, char **argv);

View File

@ -46,12 +46,6 @@
#include <QtGui/qopenglcontext.h> #include <QtGui/qopenglcontext.h>
#include <QtGui/qscreen.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> #include <QtPlatformHeaders/qxcbwindowfunctions.h>
#ifdef XCB_USE_XLIB #ifdef XCB_USE_XLIB
@ -62,18 +56,17 @@
#include <algorithm> #include <algorithm>
#include "qxcbnativeinterfacehandler.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
// return QXcbNativeInterface::ResourceType for the key. // return QXcbNativeInterface::ResourceType for the key.
static int resourceType(const QByteArray &key) static int resourceType(const QByteArray &key)
{ {
static const QByteArray names[] = { // match QXcbNativeInterface::ResourceType static const QByteArray names[] = { // match QXcbNativeInterface::ResourceType
QByteArrayLiteral("display"), QByteArrayLiteral("egldisplay"), QByteArrayLiteral("display"),
QByteArrayLiteral("connection"), QByteArrayLiteral("screen"), QByteArrayLiteral("connection"), QByteArrayLiteral("screen"),
QByteArrayLiteral("eglcontext"), QByteArrayLiteral("apptime"),
QByteArrayLiteral("eglconfig"),
QByteArrayLiteral("glxconfig"),
QByteArrayLiteral("glxcontext"), QByteArrayLiteral("apptime"),
QByteArrayLiteral("appusertime"), QByteArrayLiteral("hintstyle"), QByteArrayLiteral("appusertime"), QByteArrayLiteral("hintstyle"),
QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"), QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"),
QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"), 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 *end = names + sizeof(names) / sizeof(names[0]);
const QByteArray *result = std::find(names, end, key); const QByteArray *result = std::find(names, end, key);
if (result == end)
result = std::find(names, end, key.toLower());
return int(result - names); return int(result - names);
} }
@ -222,8 +213,12 @@ void QXcbNativeInterface::setParentRelativeBackPixmap(const QWindow *qwindow)
void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resourceString) void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resourceString)
{ {
void *result = 0; QByteArray lowerCaseResource = resourceString.toLower();
switch (resourceType(resourceString)) { void *result = handlerNativeResourceForIntegration(lowerCaseResource);
if (result)
return result;
switch (resourceType(lowerCaseResource)) {
case StartupId: case StartupId:
result = startupId(); result = startupId();
break; break;
@ -242,32 +237,20 @@ void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resour
void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context) void *QXcbNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context)
{ {
void *result = 0; QByteArray lowerCaseResource = resourceString.toLower();
switch (resourceType(resourceString)) { void *result = handlerNativeResourceForContext(lowerCaseResource, context);
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;
}
return result; 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()); const QXcbScreen *xcbScreen = static_cast<QXcbScreen *>(screen->handle());
switch (resourceType(resource)) { switch (resourceType(lowerCaseResource)) {
case Display: case Display:
#ifdef XCB_USE_XLIB #ifdef XCB_USE_XLIB
result = xcbScreen->connection()->xlib_display(); result = xcbScreen->connection()->xlib_display();
@ -303,14 +286,15 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q
void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{ {
void *result = 0; QByteArray lowerCaseResource = resourceString.toLower();
switch (resourceType(resourceString)) { void *result = handlerNativeResourceForWindow(lowerCaseResource, window);
if (result)
return result;
switch (resourceType(lowerCaseResource)) {
case Display: case Display:
result = displayForWindow(window); result = displayForWindow(window);
break; break;
case EglDisplay:
result = eglDisplayForWindow(window);
break;
case Connection: case Connection:
result = connectionForWindow(window); result = connectionForWindow(window);
break; break;
@ -324,17 +308,42 @@ void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceStr
return result; 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) 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") if (lowerCaseResource == "setstartupid")
return NativeResourceForIntegrationFunction(setStartupId); return NativeResourceForIntegrationFunction(setStartupId);
return 0; 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) QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::nativeResourceFunctionForScreen(const QByteArray &resource)
{ {
const QByteArray lowerCaseResource = resource.toLower(); const QByteArray lowerCaseResource = resource.toLower();
NativeResourceForScreenFunction func = handlerNativeResourceFunctionForScreen(lowerCaseResource);
if (func)
return func;
if (lowerCaseResource == "setapptime") if (lowerCaseResource == "setapptime")
return NativeResourceForScreenFunction(setAppTime); return NativeResourceForScreenFunction(setAppTime);
else if (lowerCaseResource == "setappusertime") else if (lowerCaseResource == "setappusertime")
@ -342,8 +351,28 @@ QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::n
return 0; 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 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()) { if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier()) {
return QFunctionPointer(QXcbWindow::setWmWindowTypeStatic); return QFunctionPointer(QXcbWindow::setWmWindowTypeStatic);
} }
@ -411,15 +440,6 @@ void QXcbNativeInterface::setStartupId(const char *data)
defaultConnection->setStartupId(startupId); 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 *QXcbNativeInterface::qPlatformScreenForWindow(QWindow *window)
{ {
QXcbScreen *screen; QXcbScreen *screen;
@ -442,17 +462,6 @@ void *QXcbNativeInterface::displayForWindow(QWindow *window)
#endif #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) void *QXcbNativeInterface::connectionForWindow(QWindow *window)
{ {
QXcbScreen *screen = qPlatformScreenForWindow(window); QXcbScreen *screen = qPlatformScreenForWindow(window);
@ -465,54 +474,121 @@ void *QXcbNativeInterface::screenForWindow(QWindow *window)
return screen->screen(); return screen->screen();
} }
void * QXcbNativeInterface::eglContextForContext(QOpenGLContext *context) void QXcbNativeInterface::addHandler(QXcbNativeInterfaceHandler *handler)
{ {
Q_ASSERT(context); m_handlers.removeAll(handler);
#if defined(XCB_USE_EGL) m_handlers.prepend(handler);
QEGLPlatformContext *eglPlatformContext = static_cast<QEGLPlatformContext *>(context->handle());
return eglPlatformContext->eglContext();
#else
Q_UNUSED(context);
return 0;
#endif
} }
void * QXcbNativeInterface::eglConfigForContext(QOpenGLContext *context) void QXcbNativeInterface::removeHandler(QXcbNativeInterfaceHandler *handler)
{ {
Q_ASSERT(context); m_handlers.removeAll(handler);
#if defined(XCB_USE_EGL)
QEGLPlatformContext *eglPlatformContext = static_cast<QEGLPlatformContext *>(context->handle());
return eglPlatformContext->eglConfig();
#else
Q_UNUSED(context);
return 0;
#endif
} }
void *QXcbNativeInterface::glxContextForContext(QOpenGLContext *context) QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterface::handlerNativeResourceFunctionForIntegration(const QByteArray &resource) const
{ {
Q_ASSERT(context); for (int i = 0; i < m_handlers.size(); i++) {
#if defined(XCB_USE_GLX) QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle()); NativeResourceForIntegrationFunction result = handler->nativeResourceFunctionForIntegration(resource);
return glxPlatformContext->glxContext(); if (result)
#else return result;
Q_UNUSED(context); }
return 0; return Q_NULLPTR;
#endif
} }
void *QXcbNativeInterface::glxConfigForContext(QOpenGLContext *context) QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::handlerNativeResourceFunctionForContext(const QByteArray &resource) const
{ {
Q_ASSERT(context); for (int i = 0; i < m_handlers.size(); i++) {
#if defined(XCB_USE_GLX) QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
QGLXContext *glxPlatformContext = static_cast<QGLXContext *>(context->handle()); NativeResourceForContextFunction result = handler->nativeResourceFunctionForContext(resource);
return glxPlatformContext->glxConfig(); if (result)
#else return result;
Q_UNUSED(context); }
return 0; return Q_NULLPTR;
#endif }
QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::handlerNativeResourceFunctionForScreen(const QByteArray &resource) const
{
for (int i = 0; i < m_handlers.size(); i++) {
QXcbNativeInterfaceHandler *handler = m_handlers.at(i);
NativeResourceForScreenFunction result = handler->nativeResourceFunctionForScreen(resource);
if (result)
return result;
}
return Q_NULLPTR;
}
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 QT_END_NAMESPACE

View File

@ -39,25 +39,23 @@
#include <QtCore/QRect> #include <QtCore/QRect>
#include "qxcbexport.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QWidget; class QWidget;
class QXcbScreen; class QXcbScreen;
class QXcbConnection; class QXcbConnection;
class QXcbNativeInterfaceHandler;
class QXcbNativeInterface : public QPlatformNativeInterface class Q_XCB_EXPORT QXcbNativeInterface : public QPlatformNativeInterface
{ {
Q_OBJECT Q_OBJECT
public: public:
enum ResourceType { enum ResourceType {
Display, Display,
EglDisplay,
Connection, Connection,
Screen, Screen,
EglContext,
EglConfig,
GLXConfig,
GLXContext,
AppTime, AppTime,
AppUserTime, AppUserTime,
ScreenHintStyle, ScreenHintStyle,
@ -76,17 +74,19 @@ public:
void *nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context) Q_DECL_OVERRIDE; void *nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context) Q_DECL_OVERRIDE;
void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) Q_DECL_OVERRIDE; void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) Q_DECL_OVERRIDE;
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) 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; NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) Q_DECL_OVERRIDE; NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) Q_DECL_OVERRIDE;
NativeResourceForScreenFunction nativeResourceFunctionForScreen(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; QFunctionPointer platformFunction(const QByteArray &function) const Q_DECL_OVERRIDE;
inline const QByteArray &genericEventFilterType() const { return m_genericEventFilterType; } inline const QByteArray &genericEventFilterType() const { return m_genericEventFilterType; }
void *displayForWindow(QWindow *window); void *displayForWindow(QWindow *window);
void *eglDisplayForWindow(QWindow *window);
void *connectionForWindow(QWindow *window); void *connectionForWindow(QWindow *window);
void *screenForWindow(QWindow *window); void *screenForWindow(QWindow *window);
void *appTime(const QXcbScreen *screen); void *appTime(const QXcbScreen *screen);
@ -98,10 +98,6 @@ public:
static void setStartupId(const char *); static void setStartupId(const char *);
static void setAppTime(QScreen *screen, xcb_timestamp_t time); static void setAppTime(QScreen *screen, xcb_timestamp_t time);
static void setAppUserTime(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 void beep();
Q_INVOKABLE bool systemTrayAvailable(const QScreen *screen) const; Q_INVOKABLE bool systemTrayAvailable(const QScreen *screen) const;
@ -111,6 +107,8 @@ public:
Q_INVOKABLE bool requestSystemTrayWindowDock(const QWindow *window); Q_INVOKABLE bool requestSystemTrayWindowDock(const QWindow *window);
Q_INVOKABLE QRect systemTrayWindowGlobalGeometry(const QWindow *window); Q_INVOKABLE QRect systemTrayWindowGlobalGeometry(const QWindow *window);
void addHandler(QXcbNativeInterfaceHandler *handler);
void removeHandler(QXcbNativeInterfaceHandler *handler);
signals: signals:
void systemTrayWindowChanged(QScreen *screen); void systemTrayWindowChanged(QScreen *screen);
@ -123,6 +121,19 @@ private:
xcb_visualid_t m_systrayVisualId; xcb_visualid_t m_systrayVisualId;
static QXcbScreen *qPlatformScreenForWindow(QWindow *window); 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 QT_END_NAMESPACE

View File

@ -41,6 +41,7 @@
#include <xcb/randr.h> #include <xcb/randr.h>
#include "qxcbobject.h" #include "qxcbobject.h"
#include "qxcbscreen.h"
#include <private/qfontengine_p.h> #include <private/qfontengine_p.h>
@ -50,7 +51,7 @@ class QXcbConnection;
class QXcbCursor; class QXcbCursor;
class QXcbXSettings; class QXcbXSettings;
class QXcbScreen : public QXcbObject, public QPlatformScreen class Q_XCB_EXPORT QXcbScreen : public QXcbObject, public QPlatformScreen
{ {
public: public:
QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen,

View File

@ -97,15 +97,6 @@
#include <X11/extensions/XInput2.h> #include <X11/extensions/XInput2.h>
#endif #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 #define XCOORD_MAX 16383
enum { enum {
defaultWindowWidth = 160, defaultWindowWidth = 160,
@ -234,9 +225,6 @@ QXcbWindow::QXcbWindow(QWindow *window)
, m_alertState(false) , m_alertState(false)
, m_netWmUserTimeWindow(XCB_NONE) , m_netWmUserTimeWindow(XCB_NONE)
, m_dirtyFrameMargins(false) , m_dirtyFrameMargins(false)
#if defined(XCB_USE_EGL)
, m_eglSurface(0)
#endif
, m_lastWindowStateEvent(-1) , m_lastWindowStateEvent(-1)
, m_syncState(NoSyncNeeded) , m_syncState(NoSyncNeeded)
, m_pendingSyncRequest(0) , m_pendingSyncRequest(0)
@ -244,11 +232,6 @@ QXcbWindow::QXcbWindow(QWindow *window)
m_screen = static_cast<QXcbScreen *>(window->screen()->handle()); m_screen = static_cast<QXcbScreen *>(window->screen()->handle());
setConnection(m_screen->connection()); setConnection(m_screen->connection());
if (window->type() != Qt::ForeignWindow)
create();
else
m_window = window->winId();
} }
#ifdef Q_COMPILER_CLASS_ENUM #ifdef Q_COMPILER_CLASS_ENUM
@ -274,6 +257,11 @@ enum {
void QXcbWindow::create() void QXcbWindow::create()
{ {
if (window()->type() == Qt::ForeignWindow) {
m_window = window()->winId();
return;
}
destroy(); destroy();
m_deferredExpose = false; m_deferredExpose = false;
@ -337,27 +325,11 @@ void QXcbWindow::create()
window()->setFormat(parentFormat); window()->setFormat(parentFormat);
} }
} }
m_format = window()->requestedFormat();
#if (defined(XCB_USE_GLX) || defined(XCB_USE_EGL)) && defined(XCB_USE_XLIB) resolveFormat();
if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) {
#if defined(XCB_USE_GLX) XVisualInfo *visualInfo = static_cast<XVisualInfo *>(createVisual());
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
if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface) if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface)
qFatal("Could not initialize OpenGL"); qFatal("Could not initialize OpenGL");
@ -365,6 +337,7 @@ void QXcbWindow::create()
qWarning("Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface."); qWarning("Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.");
window()->setSurfaceType(QSurface::RasterSurface); window()->setSurfaceType(QSurface::RasterSurface);
} }
if (visualInfo) { if (visualInfo) {
m_depth = visualInfo->depth; m_depth = visualInfo->depth;
m_imageFormat = imageFormatForVisual(visualInfo->depth, visualInfo->red_mask, visualInfo->blue_mask); m_imageFormat = imageFormatForVisual(visualInfo->depth, visualInfo->red_mask, visualInfo->blue_mask);
@ -388,7 +361,6 @@ void QXcbWindow::create()
} }
if (!m_window) if (!m_window)
#endif //defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
{ {
m_window = xcb_generate_id(xcb_connection()); m_window = xcb_generate_id(xcb_connection());
m_visualId = m_screen->screen()->root_visual; m_visualId = m_screen->screen()->root_visual;
@ -449,12 +421,10 @@ void QXcbWindow::create()
properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS); properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS);
properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING); properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING);
m_usingSyncProtocol = m_screen->syncRequestSupported(); if (m_screen->syncRequestSupported())
#if !defined(XCB_USE_GLX) m_usingSyncProtocol = supportsSyncProtocol();
// synced resize only implemented on GLX else
if (window()->supportsOpenGL())
m_usingSyncProtocol = false; m_usingSyncProtocol = false;
#endif
if (m_usingSyncProtocol) if (m_usingSyncProtocol)
properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST); properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST);
@ -576,11 +546,6 @@ void QXcbWindow::destroy()
} }
m_mapped = false; m_mapped = false;
#if defined(XCB_USE_EGL)
delete m_eglSurface;
m_eglSurface = 0;
#endif
if (m_pendingSyncRequest) if (m_pendingSyncRequest)
m_pendingSyncRequest->invalidate(); m_pendingSyncRequest->invalidate();
} }
@ -1557,21 +1522,6 @@ QSurfaceFormat QXcbWindow::format() const
return m_format; 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) void QXcbWindow::setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes)
{ {
if (window->handle()) if (window->handle())

View File

@ -48,11 +48,10 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QXcbScreen; class QXcbScreen;
class QXcbEGLSurface;
class QXcbSyncWindowRequest; class QXcbSyncWindowRequest;
class QIcon; class QIcon;
class QXcbWindow : public QXcbObject, public QXcbWindowEventListener, public QPlatformWindow class Q_XCB_EXPORT QXcbWindow : public QXcbObject, public QXcbWindowEventListener, public QPlatformWindow
{ {
public: public:
enum NetWmState { enum NetWmState {
@ -138,10 +137,6 @@ public:
void updateNetWmUserTime(xcb_timestamp_t timestamp); void updateNetWmUserTime(xcb_timestamp_t timestamp);
#if defined(XCB_USE_EGL)
QXcbEGLSurface *eglSurface() const;
#endif
static void setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes); static void setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes);
QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const; QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
@ -154,10 +149,16 @@ public:
qreal devicePixelRatio() const Q_DECL_OVERRIDE; qreal devicePixelRatio() const Q_DECL_OVERRIDE;
virtual void create();
virtual void destroy();
public Q_SLOTS: public Q_SLOTS:
void updateSyncRequestCounter(); 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); void changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two = 0);
NetWmStates netWmStates(); NetWmStates netWmStates();
void setNetWmStates(NetWmStates); void setNetWmStates(NetWmStates);
@ -176,9 +177,6 @@ private:
quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0); quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0);
void handleXEmbedMessage(const xcb_client_message_event_t *event); void handleXEmbedMessage(const xcb_client_message_event_t *event);
void create();
void destroy();
void show(); void show();
void hide(); void hide();
@ -215,10 +213,6 @@ private:
mutable bool m_dirtyFrameMargins; mutable bool m_dirtyFrameMargins;
mutable QMargins m_frameMargins; mutable QMargins m_frameMargins;
#if defined(XCB_USE_EGL)
mutable QXcbEGLSurface *m_eglSurface;
#endif
QRegion m_exposeRegion; QRegion m_exposeRegion;
xcb_visualid_t m_visualId; xcb_visualid_t m_visualId;

View File

@ -5,122 +5,10 @@ PLUGIN_CLASS_NAME = QXcbIntegrationPlugin
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - !equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
load(qt_plugin) load(qt_plugin)
QT += core-private gui-private platformsupport-private QT += core-private gui-private platformsupport-private xcb_qpa_lib-private
SOURCES = \ SOURCES = \
qxcbclipboard.cpp \ qxcbmain.cpp
qxcbconnection.cpp \
qxcbintegration.cpp \
qxcbkeyboard.cpp \
qxcbmime.cpp \
qxcbdrag.cpp \
qxcbscreen.cpp \
qxcbwindow.cpp \
qxcbbackingstore.cpp \
qxcbwmsupport.cpp \
qxcbmain.cpp \
qxcbnativeinterface.cpp \
qxcbcursor.cpp \
qxcbimage.cpp \
qxcbxsettings.cpp \
qxcbsystemtraytracker.cpp
HEADERS = \
qxcbclipboard.h \
qxcbconnection.h \
qxcbintegration.h \
qxcbkeyboard.h \
qxcbdrag.h \
qxcbmime.h \
qxcbobject.h \
qxcbscreen.h \
qxcbwindow.h \
qxcbbackingstore.h \
qxcbwmsupport.h \
qxcbnativeinterface.h \
qxcbcursor.h \
qxcbimage.h \
qxcbxsettings.h \
qxcbsystemtraytracker.h
LIBS += $$QMAKE_LIBS_DYNLOAD
# needed by GLX, Xcursor ...
contains(QT_CONFIG, xcb-xlib) {
DEFINES += XCB_USE_XLIB
LIBS += -lX11 -lX11-xcb
contains(QT_CONFIG, xinput2) {
DEFINES += XCB_USE_XINPUT2
SOURCES += qxcbconnection_xi2.cpp
LIBS += -lXi
}
}
# to support custom cursors with depth > 1
contains(QT_CONFIG, xcb-render) {
DEFINES += XCB_USE_RENDER
LIBS += -lxcb-render -lxcb-render-util
}
# build with session management support
contains(QT_CONFIG, xcb-sm) {
DEFINES += XCB_USE_SM
LIBS += -lSM -lICE
SOURCES += qxcbsessionmanager.cpp
HEADERS += qxcbsessionmanager.h
}
contains(QT_CONFIG, opengl) {
contains(QT_CONFIG, xcb-xlib):!contains(QT_CONFIG, opengles2) {
DEFINES += XCB_USE_GLX
HEADERS += qglxintegration.h
SOURCES += qglxintegration.cpp
LIBS += $$QMAKE_LIBS_DYNLOAD
contains(QT_CONFIG, xcb-glx) {
DEFINES += XCB_HAS_XCB_GLX
LIBS += -lxcb-glx
}
} else:contains(QT_CONFIG, egl):contains(QT_CONFIG, egl_x11) {
DEFINES += XCB_USE_EGL
CONFIG += egl
HEADERS += qxcbeglsurface.h
# EGL on MeeGo 1.2 Harmattan needs this macro to map EGLNativeDisplayType
# and other types to the correct X11 types
DEFINES += SUPPORT_X11
}
}
DEFINES += $$QMAKE_DEFINES_XCB
LIBS += $$QMAKE_LIBS_XCB
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB
QMAKE_CFLAGS += $$QMAKE_CFLAGS_XCB
CONFIG += qpa/genericunixfontdatabase
contains(QT_CONFIG, dbus) {
QT += dbus
LIBS += -ldbus-1
}
OTHER_FILES += xcb.json README 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
}

View File

@ -2,4 +2,7 @@ TEMPLATE = subdirs
CONFIG += ordered CONFIG += ordered
contains(QT_CONFIG, xcb-qt):SUBDIRS+=xcb-static contains(QT_CONFIG, xcb-qt):SUBDIRS+=xcb-static
SUBDIRS += xcb_qpa_lib.pro
SUBDIRS += xcb-plugin.pro SUBDIRS += xcb-plugin.pro
SUBDIRS += gl_integrations

View File

@ -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
}

View File

@ -0,0 +1,70 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite 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 <QtGui/QGuiApplication>
#include <QtGui/QWindow>
#include <QtGui/QOpenGLContext>
#include <QtGui/qpa/qplatformnativeinterface.h>
#include <QtCore/QDebug>
int main (int argc, char **argv)
{
QGuiApplication app(argc, argv);
QWindow window;
window.setSurfaceType(QSurface::OpenGLSurface);
window.create();
QOpenGLContext context;
context.create();
QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface();
qDebug() << "EGLDisplay" << ni->nativeResourceForWindow(QByteArrayLiteral("egldisplay"), &window);
qDebug() << "EGLContext" << ni->nativeResourceForContext(QByteArrayLiteral("eglcontext"), &context);
qDebug() << "EGLConfig" << ni->nativeResourceForContext(QByteArrayLiteral("eglconfig"), &context);
qDebug() << "GLXContext" << ni->nativeResourceForContext(QByteArrayLiteral("glxcontext"), &context);
qDebug() << "GLXConfig" << ni->nativeResourceForContext(QByteArrayLiteral("glxconfig"), &context);
return 0;
}

View File

@ -0,0 +1,8 @@
TEMPLATE = app
TARGET = xcb_gl_integration
INCLUDEPATH += .
QT += gui-private
# Input
SOURCES += main.cpp