diff options
Diffstat (limited to 'src/platformheaders')
19 files changed, 1145 insertions, 0 deletions
diff --git a/src/platformheaders/doc/qtplatformheaders.qdocconf b/src/platformheaders/doc/qtplatformheaders.qdocconf new file mode 100644 index 0000000000..1c09971e23 --- /dev/null +++ b/src/platformheaders/doc/qtplatformheaders.qdocconf @@ -0,0 +1,38 @@ +include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) + +project = QtPlatformHeaders +description = Qt Platform Headers Reference Documentation +version = $QT_VERSION + +examplesinstallpath = qtplatformheaders + +qhp.projects = QtPlatformHeaders + +qhp.QtPlatformHeaders.file = qtplatformheaders.qhp +qhp.QtPlatformHeaders.namespace = org.qt-project.qtplatformheaders.$QT_VERSION_TAG +qhp.QtPlatformHeaders.virtualFolder = qtplatformheaders +qhp.QtPlatformHeaders.indexTitle = Qt Platform Headers +qhp.QtPlatformHeaders.indexRoot = + +qhp.QtPlatformHeaders.filterAttributes = qtplatformheaders $QT_VERSION qtrefdoc +qhp.QtPlatformHeaders.customFilters.Qt.name = QtPlatformHeaders $QT_VERSION +qhp.QtPlatformHeaders.customFilters.Qt.filterAttributes = qtplatformheaders $QT_VERSION + +qhp.QtPlatformHeaders.subprojects = classes +qhp.QtPlatformHeaders.subprojects.classes.title = C++ Classes +qhp.QtPlatformHeaders.subprojects.classes.indexTitle = Qt Platform Headers C++ Classes +qhp.QtPlatformHeaders.subprojects.classes.selectors = class fake:headerfile +qhp.QtPlatformHeaders.subprojects.classes.sortPages = true + +depends += \ + qtcore \ + qtgui \ + qtdoc + +headerdirs += .. +sourcedirs += .. +exampledirs += snippets +imagedirs += images + +navigation.landingpage = "Qt Platform Headers" +navigation.cppclassespage = "Qt Platform Headers C++ Classes" diff --git a/src/platformheaders/doc/snippets/qxcbwindowfunctions/main.cpp b/src/platformheaders/doc/snippets/qxcbwindowfunctions/main.cpp new file mode 100644 index 0000000000..d4cb965bda --- /dev/null +++ b/src/platformheaders/doc/snippets/qxcbwindowfunctions/main.cpp @@ -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 documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtWidgets> +#include <QtPlatformHeaders/qxcbwindowfunctions.h> + +//! [0] +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QPushButton topLevelWidget("Hello World!"); + topLevelWidget.winId(); //have to create the QWindow + + QWindow *tlwWindow = topLevelWidget.windowHandle(); + + QXcbWindowFunctions::setWmWindowType(tlwWindow, QXcbWindowFunctions::Dock); + + topLevelWidget.show(); + + return app.exec(); +} +//! [0] + diff --git a/src/platformheaders/doc/src/qtplatformheaders.qdoc b/src/platformheaders/doc/src/qtplatformheaders.qdoc new file mode 100644 index 0000000000..74df288d3d --- /dev/null +++ b/src/platformheaders/doc/src/qtplatformheaders.qdoc @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \module QtPlatformHeaders + \title Qt Platform Headers C++ Classes + \ingroup modules + + \brief The Qt Platform Headers module offers header-only inline classes that + encapsulate platform-specific information that is tied to a given runtime + configuration of a platform plugin. +*/ + +/*! + \page qtplatformheaders-index.html + \title Qt Platform Headers + + \brief The Qt Platform Headers module offers header-only inline classes that + encapsulate platform-specific information that is tied to a given runtime + configuration of a platform plugin. + + Some applications may need to interface Qt with other frameworks. This often + means using graphics contexts or other types of native handles created by + one framework with another. For example, on some platforms, QOpenGLContext + offers the ability to wrap an existing native OpenGL context, instead of + creating a new one. This existing native context can be created by some + other third-party code. + + The type of such native handles is highly platform specific and in some + cases the platform plugin will need more information to adopt a handle, just + the handle in itself will not be sufficient. Therefore the public API + consists of functions taking or returning a QVariant that contains a + platform-specific value type. See for example + QOpenGLContext::setNativeHandle() and QOpenGLContext::nativeHandle(). When + running on Linux/X11, using the xcb platform plugin and the GLX windowing + system interface, the variant contains a QGLXNativeContext. On other + platforms a different class will be used. These classes are all placed in + the Qt Platform Headers module. + + Platform headers can be used in conjunction with + QGuiApplication::platformFunction() to give a type safe interface to + platform specific functionality. It is possible for headers defined in + QtPlatformHeaders to define typedefs for functions that can be returned by + a platform plugin from QGuiApplication::platformFunction(). Headers in + QtPlatformHeaders can also implement wrapper functions for the function + pointer, giving a static function that can be called from any context after + the platform integration has been created. An implementation of this + pattern is QXcbWindowFunctions::setWmWindowType(). This function retrieves + a function pointer from QGuiApplication::platformFunction, and executes + that function if the requested function was returned. + + \note Similar to the other QPA APIs, there are no binary compatibility + guarantees for these classes, meaning that an application using these + classes is only guaranteed to work with the Qt version it was developed + against. Unlike QPA however, source compatibility is guaranteed. + + \sa QXcbWindowFunctions + */ diff --git a/src/platformheaders/eglfsfunctions/eglfsfunctions.pri b/src/platformheaders/eglfsfunctions/eglfsfunctions.pri new file mode 100644 index 0000000000..e4e645f5a5 --- /dev/null +++ b/src/platformheaders/eglfsfunctions/eglfsfunctions.pri @@ -0,0 +1 @@ +HEADERS += $$PWD/qeglfsfunctions.h diff --git a/src/platformheaders/eglfsfunctions/qeglfsfunctions.h b/src/platformheaders/eglfsfunctions/qeglfsfunctions.h new file mode 100644 index 0000000000..702d0b2f8c --- /dev/null +++ b/src/platformheaders/eglfsfunctions/qeglfsfunctions.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QEGLFSFUNCTIONS_H +#define QEGLFSFUNCTIONS_H + +#include <QtCore/QByteArray> +#include <QtGui/QGuiApplication> + +QT_BEGIN_NAMESPACE + +class QEglFSFunctions +{ +public: + typedef void (*LoadKeymapType)(const QString &filename); + static QByteArray loadKeymapTypeIdentifier() { return QByteArrayLiteral("EglFSLoadKeymap"); } + + static void loadKeymap(const QString &filename) + { + LoadKeymapType func = reinterpret_cast<LoadKeymapType>(QGuiApplication::platformFunction(loadKeymapTypeIdentifier())); + if (func) + func(filename); + } +}; + + +QT_END_NAMESPACE + +#endif // QEGLFSFUNCTIONS_H diff --git a/src/platformheaders/eglfsfunctions/qeglfsfunctions.qdoc b/src/platformheaders/eglfsfunctions/qeglfsfunctions.qdoc new file mode 100644 index 0000000000..b8dae9b13f --- /dev/null +++ b/src/platformheaders/eglfsfunctions/qeglfsfunctions.qdoc @@ -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 documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QEglFSFunctions + \inmodule QtPlatformHeaders + + \brief The QEglFSFunctions class is an inline class containing + platform-specific functionality for the eglfs platform plugin that is + typically used on systems running Embedded Linux or Android. + + \note There is no binary compatibility guarantee for this class, + meaning that an application using it is only guaranteed to work with the Qt + version it was developed against. +*/ + +/*! + \typedef QEglFSFunctions::LoadKeymapType + + Function type for loadKeymap. +*/ + +/*! + \fn QByteArray QEglFSFunctions::loadKeymapTypeIdentifier() + + \return the identifier that can be passed to + QGuiApplication::platformFunction() to query the entry point for the + loadKeymap function implementation. +*/ + +/*! + \fn void QEglFSFunctions::loadKeymap(const QString &filename) + + Loads and switches to the keymap from \a filename. When \a filename is + empty, the default keymap, which is either the built-on one or the keymap + given in the plugin specification, is restored. + + \note This is functional only when the evdev keyboard support code is + compiled in to the platform plugin. When using external generic plugins via + the \c{-plugin} argument, or when the environment variable + \c{QT_QPA_EGLFS_DISABLE_INPUT} is set or when building Qt without evdev + support, this function will have no effect. +*/ diff --git a/src/platformheaders/nativecontexts/nativecontexts.pri b/src/platformheaders/nativecontexts/nativecontexts.pri new file mode 100644 index 0000000000..cfb190e4fa --- /dev/null +++ b/src/platformheaders/nativecontexts/nativecontexts.pri @@ -0,0 +1,4 @@ +HEADERS += $$PWD/qglxnativecontext.h \ + $$PWD/qeglnativecontext.h \ + $$PWD/qcocoanativecontext.h \ + $$PWD/qwglnativecontext.h diff --git a/src/platformheaders/nativecontexts/qcocoanativecontext.h b/src/platformheaders/nativecontexts/qcocoanativecontext.h new file mode 100644 index 0000000000..34994089c4 --- /dev/null +++ b/src/platformheaders/nativecontexts/qcocoanativecontext.h @@ -0,0 +1,70 @@ +/**************************************************************************** + ** + ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). + ** Contact: http://www.qt-project.org/legal + ** + ** This file is part of the plugins of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:LGPL$ + ** Commercial License Usage + ** Licensees holding valid commercial Qt licenses may use this file in + ** accordance with the commercial license agreement provided with the + ** Software or, alternatively, in accordance with the terms contained in + ** a written agreement between you and Digia. For licensing terms and + ** conditions see http://qt.digia.com/licensing. For further information + ** use the contact form at http://qt.digia.com/contact-us. + ** + ** GNU Lesser General Public License Usage + ** Alternatively, this file may be used under the terms of the GNU Lesser + ** General Public License version 2.1 as published by the Free Software + ** Foundation and appearing in the file LICENSE.LGPL included in the + ** packaging of this file. Please review the following information to + ** ensure the GNU Lesser General Public License version 2.1 requirements + ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + ** + ** In addition, as a special exception, Digia gives you certain additional + ** rights. These rights are described in the Digia Qt LGPL Exception + ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. + ** + ** GNU General Public License Usage + ** Alternatively, this file may be used under the terms of the GNU + ** General Public License version 3.0 as published by the Free Software + ** Foundation and appearing in the file LICENSE.GPL included in the + ** packaging of this file. Please review the following information to + ** ensure the GNU General Public License version 3.0 requirements will be + ** met: http://www.gnu.org/copyleft/gpl.html. + ** + ** + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + +#ifndef QCOCOANATIVECONTEXT_H +#define QCOCOANATIVECONTEXT_H + +#include <QtCore/QMetaType> +#include <AppKit/NSOpenGL.h> + +QT_BEGIN_NAMESPACE + +struct QCocoaNativeContext +{ + QCocoaNativeContext() + : m_context(0) + { } + + QCocoaNativeContext(NSOpenGLContext *ctx) + : m_context(ctx) + { } + + NSOpenGLContext *context() const { return m_context; } + +private: + NSOpenGLContext *m_context; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QCocoaNativeContext) + +#endif // QCOCOANATIVECONTEXT_H diff --git a/src/platformheaders/nativecontexts/qcocoanativecontext.qdoc b/src/platformheaders/nativecontexts/qcocoanativecontext.qdoc new file mode 100644 index 0000000000..96b33ce5f8 --- /dev/null +++ b/src/platformheaders/nativecontexts/qcocoanativecontext.qdoc @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QCocoaNativeContext + \inmodule QtPlatformHeaders + \since 5.4 + + \brief A class encapsulating a Cocoa NSOpenGLContext. + + \note There is no binary compatibility guarantee for this class, meaning + that an application using it is only guaranteed to work with the Qt version it was + developed against. + + \sa QOpenGLContext::setNativeHandle(), QOpenGLContext::nativeHandle() + */ + +/*! + \fn NSOpenGLContext *QCocoaNativeContext::context() const + + \return the context. + */ + +/*! + \fn QCocoaNativeContext::QCocoaNativeContext() + + Construct a new instance with no handles. + */ + +/*! + \fn QCocoaNativeContext::QCocoaNativeContext(NSOpenGLContext *ctx) + + Constructs a new instance with the provided \a ctx handle. + */ diff --git a/src/platformheaders/nativecontexts/qeglnativecontext.h b/src/platformheaders/nativecontexts/qeglnativecontext.h new file mode 100644 index 0000000000..a2411419ef --- /dev/null +++ b/src/platformheaders/nativecontexts/qeglnativecontext.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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 QEGLNATIVECONTEXT_H +#define QEGLNATIVECONTEXT_H + +#include <QtCore/QMetaType> +#include <EGL/egl.h> + +QT_BEGIN_NAMESPACE + +struct QEGLNativeContext +{ + QEGLNativeContext() + : m_context(0), + m_display(0) + { } + + QEGLNativeContext(EGLContext ctx, EGLDisplay dpy) + : m_context(ctx), + m_display(dpy) + { } + + EGLContext context() const { return m_context; } + EGLDisplay display() const { return m_display; } + +private: + EGLContext m_context; + EGLDisplay m_display; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QEGLNativeContext) + +#endif // QEGLNATIVECONTEXT_H diff --git a/src/platformheaders/nativecontexts/qeglnativecontext.qdoc b/src/platformheaders/nativecontexts/qeglnativecontext.qdoc new file mode 100644 index 0000000000..edadbdfa83 --- /dev/null +++ b/src/platformheaders/nativecontexts/qeglnativecontext.qdoc @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QEGLNativeContext + \inmodule QtPlatformHeaders + \since 5.4 + + \brief A class encapsulating an EGL context and display handle + + \note There is no binary compatibility guarantee for this class, meaning + that an application using it is only guaranteed to work with the Qt version it was + developed against. + + \sa QOpenGLContext::setNativeHandle(), QOpenGLContext::nativeHandle() + */ + +/*! + \fn EGLContext QEGLNativeContext::context() const + + \return the EGL context. + */ + +/*! + \fn EGLDisplay QEGLNativeContext::display() const + + \return the EGL display. + */ + +/*! + \fn QEGLNativeContext::QEGLNativeContext() + + Construct a new instance with no handles. + */ + +/*! + \fn QEGLNativeContext::QEGLNativeContext(EGLContext ctx, EGLDisplay dpy) + + Constructs a new instance with the provided \a ctx and \a dpy handles. + */ diff --git a/src/platformheaders/nativecontexts/qglxnativecontext.h b/src/platformheaders/nativecontexts/qglxnativecontext.h new file mode 100644 index 0000000000..21ae334c25 --- /dev/null +++ b/src/platformheaders/nativecontexts/qglxnativecontext.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGLXNATIVECONTEXT_H +#define QGLXNATIVECONTEXT_H + +#include <QtCore/QMetaType> +#include <X11/Xlib.h> +#include <GL/glx.h> + +QT_BEGIN_NAMESPACE + +struct QGLXNativeContext +{ + QGLXNativeContext() + : m_context(0), + m_display(0), + m_window(0), + m_visualId(0) + { } + + QGLXNativeContext(GLXContext ctx, Display *dpy = 0, Window wnd = 0, VisualID vid = 0) + : m_context(ctx), + m_display(dpy), + m_window(wnd), + m_visualId(vid) + { } + + GLXContext context() const { return m_context; } + Display *display() const { return m_display; } + Window window() const { return m_window; } + VisualID visualId() const { return m_visualId; } + +private: + GLXContext m_context; + Display *m_display; + Window m_window; + VisualID m_visualId; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QGLXNativeContext) + +#endif // QGLXNATIVECONTEXT_H diff --git a/src/platformheaders/nativecontexts/qglxnativecontext.qdoc b/src/platformheaders/nativecontexts/qglxnativecontext.qdoc new file mode 100644 index 0000000000..81f3c0b2ca --- /dev/null +++ b/src/platformheaders/nativecontexts/qglxnativecontext.qdoc @@ -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 documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QGLXNativeContext + \inmodule QtPlatformHeaders + \since 5.4 + + \brief A class encapsulating a GLXContext and related native handles. + + \note Only context() is guaranteed to be valid. The other handles may be all \c 0. They are + useful however when QOpenGLContext::setNativeHandle() is used to adopt a legacy context + created by glXCreateContext. To adopt such a context, either the Window or VisualID + that had been used to create the context needs to be known, otherwise the adoption will + fail. For modern contexts created with an FBConfig, these are not necessary, the + GLXContext itself is sufficient. The Display is optional. + + \note There is no binary compatibility guarantee for this class, meaning + that an application using it is only guaranteed to work with the Qt version it was + developed against. + + \sa QOpenGLContext::setNativeHandle(), QOpenGLContext::nativeHandle() + */ + +/*! + \fn GLXContext QGLXNativeContext::context() const + + \return the GLXContext. + */ + +/*! + \fn Display *QGLXNativeContext::display() const + + \return a pointer to the X11 display or \c NULL if not available. + */ + +/*! + \fn Window QGLXNativeContext::window() const + + \return the X11 Window or \c 0 if not available. + */ + +/*! + \fn VisualID QGLXNativeContext::visualId() const + + \return the X11 visual ID or \c 0 if not available. + */ + +/*! + \fn QGLXNativeContext::QGLXNativeContext() + + Construct a new instance with no handles. + */ + +/*! + \fn QGLXNativeContext::QGLXNativeContext(GLXContext ctx, Display *dpy = 0, Window wnd = 0, VisualID vid = 0) + + Constructs a new instance with the provided \a ctx, \a dpy, \a wnd, \a vid handles. + */ diff --git a/src/platformheaders/nativecontexts/qwglnativecontext.h b/src/platformheaders/nativecontexts/qwglnativecontext.h new file mode 100644 index 0000000000..4a68633703 --- /dev/null +++ b/src/platformheaders/nativecontexts/qwglnativecontext.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWGLNATIVECONTEXT_H +#define QWGLNATIVECONTEXT_H + +#include <QtCore/QMetaType> +#include <wingdi.h> +#include <GL/gl.h> + +QT_BEGIN_NAMESPACE + +class QWGLNativeContext +{ +public: + QWGLNativeContext() + : m_context(0), + m_window(0) + { } + + QWGLNativeContext(HGLRC ctx, HWND wnd) + : m_context(ctx), + m_window(wnd) + { } + + HGLRC context() const { return m_context; } + HWND window() const { return m_window; } + +private: + HGLRC m_context; + HWND m_window; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QWGLNativeContext) + +#endif // QWGLNATIVECONTEXT_H diff --git a/src/platformheaders/nativecontexts/qwglnativecontext.qdoc b/src/platformheaders/nativecontexts/qwglnativecontext.qdoc new file mode 100644 index 0000000000..86ae291aaa --- /dev/null +++ b/src/platformheaders/nativecontexts/qwglnativecontext.qdoc @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QWGLNativeContext + \inmodule QtPlatformHeaders + \since 5.4 + + \brief A class encapsulating a WGL context on Windows with desktop OpenGL (opengl32.dll) + + \note There is no binary compatibility guarantee for this class, + meaning that an application using it is only guaranteed to work with the Qt + version it was developed against. + + QWGLNativeContext is a value class that can be passed to + QOpenGLContext::setNativeHandle(). When creating a QOpenGLContext with the + native handle set, no new context will get created. Instead, the provided + handles are used, without taking ownership. This allows wrapping a context + created by an external framework or rendering engine. The typical usage will + be similar to the following snippet: + + \code + #include <QtPlatformSupport/QWGLNativeContext> + ...create and retrieve the WGL context and the corresponding window... + QOpenGLContext *context = new QOpenGLContext; + QWGLNativeContext nativeContext(hglrc, hwnd); + context->setNativeHandle(QVariant::fromValue(nativeContext)); + context->create(); + ... + \endcode + + The window is needed because the its pixel format will be queried. When the + adoption is successful, QOpenGLContext::format() will return a QSurfaceFormat + describing this pixel format. + + It is recommended to restrict the usage of QOpenGLContexts created this way. + Various platform-specific behavior and issues may prevent such contexts to be + made current with windows (surfaces) created by Qt due to non-matching pixel + formats for example. A potentially safer solution is to use the wrapped + context only to set up sharing and perform Qt-based rendering offscreen, + using a separate, dedicated QOpenGLContext. The resulting textures are then + accessible in the foreign context too. + + \code + ...like above... + QOpenGLContext *qtcontext = new QOpenGLContext; + qtcontext->setShareContext(context); + qtcontext->setFormat(context->format()); + qtcontext->create(); + ...use qtcontext for rendering with Qt... + \endcode + + In addition to being used with QOpenGLContext::setNativeHandle(), this class + is used also to retrieve the native context handle, that is, a HGLRC value, + from a QOpenGLContext. Calling QOpenGLContext::nativeHandle() returns a + QVariant which, on Windows with opengl32.dll at least, will contain a + QWGLNativeContext: + + \code + QVariant nativeHandle = context->nativeHandle(); + if (!nativeHandle.isNull() && nativeHandle.canConvert<QWGLNativeContext>()) { + QWGLNativeContext nativeContext = nativeHandle.value<QWGLNativeContext>(); + HGLRC hglrc = nativeContext.context(); + ... + } + \endcode + + \sa QOpenGLContext::setNativeHandle(), QOpenGLContext::nativeHandle() + */ + +/*! + \fn HGLRC QWGLNativeContext::context() const + + \return the WGL context. + */ + +/*! + \fn HWND QWGLNativeContext::window() const + + \note The window handle is not available when the QWGLNativeContext is + queried from a regular, non-adopted QOpenGLContext using + QOpenGLContext::nativeHandle(). This is because the \e windows platform + plugin creates WGL contexts using a dummy window that is not available + afterwards. Instead, the native window handle (HWND) is queriable from a + QWindow via QPlatformNativeInterface::nativeResourceForWindow() using the \e + "handle" resource key. Note however that the window will not have its pixel + format set until it is first associated with a context via + QOpenGLContext::makeCurrent(). + + \return handle for the window for which the context was created. + */ + +/*! + \fn QWGLNativeContext::QWGLNativeContext() + + Construct a new instance with no handles. + */ + +/*! + \fn QWGLNativeContext::QWGLNativeContext(HGLRC ctx, HWND wnd) + + Constructs a new instance with the provided \a ctx context handle and \a wnd window handle. + + \note The window specified by \a wnd must have its pixel format set to a + format compatible with the context's. If no SetPixelFormat() call was made on + any device context belonging to the window, adopting the context will fail. + */ diff --git a/src/platformheaders/platformheaders.pro b/src/platformheaders/platformheaders.pro new file mode 100644 index 0000000000..a3132ecf23 --- /dev/null +++ b/src/platformheaders/platformheaders.pro @@ -0,0 +1,14 @@ +# Only headers here, no library is wanted. +TEMPLATE = subdirs +VERSION = $$MODULE_VERSION +MODULE_INCNAME = QtPlatformHeaders + +include(nativecontexts/nativecontexts.pri) +include(xcbfunctions/xcbfunctions.pri) +include(eglfsfunctions/eglfsfunctions.pri) + +QMAKE_DOCS = $$PWD/doc/qtplatformheaders.qdocconf + +load(qt_module_headers) +load(qt_docs) +load(qt_installs) diff --git a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h new file mode 100644 index 0000000000..48fc0c13b6 --- /dev/null +++ b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 QXCBWINDOWFUNCTIONS_H +#define QXCBWINDOWFUNCTIONS_H + +#include <QtCore/QByteArray> +#include <QtGui/QGuiApplication> + +QT_BEGIN_NAMESPACE + +class QWindow; + +class QXcbWindowFunctions { +public: + enum WmWindowType { + Normal = 0x000001, + Desktop = 0x000002, + Dock = 0x000004, + Toolbar = 0x000008, + Menu = 0x000010, + Utility = 0x000020, + Splash = 0x000040, + Dialog = 0x000080, + DropDownMenu = 0x000100, + PopupMenu = 0x000200, + Tooltip = 0x000400, + Notification = 0x000800, + Combo = 0x001000, + Dnd = 0x002000, + KdeOverride = 0x004000 + }; + + Q_DECLARE_FLAGS(WmWindowTypes, WmWindowType) + + typedef void (*SetWmWindowType)(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowType); + static const QByteArray setWmWindowTypeIdentifier() { return QByteArrayLiteral("XcbSetWmWindowType"); } + + static void setWmWindowType(QWindow *window, WmWindowType type) + { + SetWmWindowType func = reinterpret_cast<SetWmWindowType>(QGuiApplication::platformFunction(setWmWindowTypeIdentifier())); + if (func) + func(window, type); + } +}; + + +QT_END_NAMESPACE + +#endif // QXCBWINDOWFUNCTIONS_H diff --git a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc new file mode 100644 index 0000000000..458dbb213d --- /dev/null +++ b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc @@ -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 documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \class QXcbWindowFunctions + \inmodule QtPlatformHeaders + + \brief The QXcbWindowFunctions class is an inline class containing + miscellaneous functionality for xcb window specific functionality. + + A commen usage pattern is as follows: + \snippet qxcbwindowfunctions/main.cpp 0 + + \note There is no binary compatibility guarantee for this class, + meaning that an application using it is only guaranteed to work with the Qt + version it was developed against. +*/ + +/*! + \enum QXcbWindowFunctions::WmWindowType + + This enum represents the supported WM_WINDOW_TYPE atoms. + + \value Normal + \value Desktop + \value Dock + \value Toolbar + \value Menu + \value Utility + \value Splash + \value Dialog + \value DropDownMenu + \value PopupMenu + \value Tooltip + \value Notification + \value Combo + \value Dnd + \value KdeOverride +*/ + +/*! + \typedef QXcbWindowFunctions::SetWmWindowType + + This is the typedef for the function returned by QGuiApplication::platformFunction when passed setWmWindowTypeIdentifier. +*/ + +/*! + \fn QByteArray QXcbWindowFunctions::setWmWindowTypeIdentifier() + + This function returnes the bytearray that can be used to query + QGuiApplication::platformFunction to retrieve the SetWmWindowType function. +*/ + +/*! + \fn void QXcbWindowFunctions::setWmWindowType(QWindow *window, WmWindowType type) + + This is a convenience function that can be used directly instead of resolving the function pointer. + \a window and \a type will be relayed to the function retrieved by QGuiApplication +*/ diff --git a/src/platformheaders/xcbfunctions/xcbfunctions.pri b/src/platformheaders/xcbfunctions/xcbfunctions.pri new file mode 100644 index 0000000000..8844913cd1 --- /dev/null +++ b/src/platformheaders/xcbfunctions/xcbfunctions.pri @@ -0,0 +1 @@ +HEADERS += $$PWD/qxcbwindowfunctions.h |