diff options
31 files changed, 1036 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore index 270d228f6..e7ba647b2 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ examples/wayland/server-buffer/compositor/qwayland-server-*.cpp examples/wayland/server-buffer/compositor/qwayland-server-*.h examples/wayland/server-buffer/compositor/*-server-protocol.h examples/wayland/server-buffer/compositor/*-protocol.c +examples/wayland/subsurface/subsurface src/client/qwayland*.cpp src/client/*-protocol.c src/client/QtWaylandClient.version diff --git a/.qmake.conf b/.qmake.conf index 66a0241ed..4ef70163b 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,3 +1,3 @@ load(qt_build_config) -MODULE_VERSION = 5.6.0 +MODULE_VERSION = 5.7.0 diff --git a/examples/wayland/subsurface/child.qml b/examples/wayland/subsurface/child.qml new file mode 100644 index 000000000..b2e54054e --- /dev/null +++ b/examples/wayland/subsurface/child.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples 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 The Qt Company Ltd 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$ +** +****************************************************************************/ + +import QtQuick 2.4 +import QtQuick.Window 2.2 + +Rectangle { + width: 300 + height: 300 + + color: "darkgray" + + Rectangle { + width: 100 + height: 100 + color: "magenta" + + Text { + anchors.centerIn: parent + text: "quick" + } + + RotationAnimation on rotation { + duration: 10000 + loops: Animation.Infinite + from: 0 + to: 360 + } + } +} diff --git a/examples/wayland/subsurface/main.cpp b/examples/wayland/subsurface/main.cpp new file mode 100644 index 000000000..c913c32fb --- /dev/null +++ b/examples/wayland/subsurface/main.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples 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 The Qt Company Ltd 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 <QGuiApplication> +#include <QQmlEngine> +#include <QQmlFileSelector> +#include <QQmlContext> +#include <QQuickView> + +#include <QtPlatformHeaders/qwaylandwindowfunctions.h> + +#include "shmwindow.h" + +class Filter : public QObject +{ + Q_OBJECT + Q_PROPERTY(bool sync READ getSync NOTIFY syncChanged) + +public: + Filter() + { + sync = false; + } + + bool eventFilter(QObject *object, QEvent *event) + { + Q_UNUSED(object); + if (event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); + if (keyEvent->key() == Qt::Key_Space) { + toggleSync(quick); + toggleSync(shm); + } + } + return false; + } + + void toggleSync(QWindow *w) + { + sync = !QWaylandWindowFunctions::isSync(w); + if (QWaylandWindowFunctions::isSync(w)) + QWaylandWindowFunctions::setDeSync(w); + else + QWaylandWindowFunctions::setSync(w); + emit syncChanged(); + } + + bool getSync() const + { + return sync; + } + +Q_SIGNALS: + void syncChanged(); + +public: + QWindow *quick; + QWindow *shm; + bool sync; +}; + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + QQuickView view; + view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit())); + view.setResizeMode(QQuickView::SizeRootObjectToView); + + Filter f; + view.rootContext()->setContextProperty("syncStatus", &f); + view.installEventFilter(&f); + + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + + QQuickView child(&view); + child.connect(child.engine(), SIGNAL(quit()), &app, SLOT(quit())); + child.setSource(QUrl("qrc:/child.qml")); + child.setResizeMode(QQuickView::SizeRootObjectToView); + child.setGeometry(QRect(150, 70, 100, 100)); + child.show(); + + ShmWindow shm(&view); + shm.setGeometry(QRect(30, 30, 50, 50)); + shm.show(); + + f.quick = &child; + f.shm = &shm; + + return app.exec(); +} + +#include "main.moc" + diff --git a/examples/wayland/subsurface/main.qml b/examples/wayland/subsurface/main.qml new file mode 100644 index 000000000..fa71d4b6b --- /dev/null +++ b/examples/wayland/subsurface/main.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples 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 The Qt Company Ltd 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$ +** +****************************************************************************/ + +import QtQuick 2.4 +import QtQuick.Window 2.2 + +Rectangle { + id: root + + width: 300 + height: 300 + + color: "blue" + + Rectangle { + id: r + width: 100 + height: 100 + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + color: "cyan" + + MouseArea { + anchors.fill: parent + drag.target: r + drag.axis: Drag.XAndYAxis + } + } + + Text { + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: syncStatus.sync ? "sync mode" : "de-sync mode" + } +} diff --git a/examples/wayland/subsurface/qml.qrc b/examples/wayland/subsurface/qml.qrc new file mode 100644 index 000000000..f81739af9 --- /dev/null +++ b/examples/wayland/subsurface/qml.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>main.qml</file> + <file>child.qml</file> +</qresource> +</RCC> diff --git a/examples/wayland/subsurface/shmwindow.cpp b/examples/wayland/subsurface/shmwindow.cpp new file mode 100644 index 000000000..50452953a --- /dev/null +++ b/examples/wayland/subsurface/shmwindow.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2015 LG Electronics Ltd, author: <mikko.levonmaa@lge.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples 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 The Qt Company Ltd 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 "shmwindow.h" + +#include <QPainter> +#include <QDebug> + +ShmWindow::ShmWindow(QWindow *parent) + : QRasterWindow(parent) + , m_rotation(0) +{ + m_timer = startTimer(100); +} + +void ShmWindow::timerEvent(QTimerEvent *event) +{ + if (event->timerId() == m_timer) { + m_rotation++; + update(); + } +} + +void ShmWindow::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + QPainter painter(this); + + painter.fillRect(0, 0, width(), height(), Qt::white); + + qreal xc = width() * 0.5; + qreal yc = height() * 0.5; + painter.translate(xc, yc); + painter.rotate(m_rotation); + painter.drawText(QRectF(-xc, -yc, width(), height()), Qt::AlignCenter, QStringLiteral("SHM")); +} + diff --git a/examples/wayland/subsurface/shmwindow.h b/examples/wayland/subsurface/shmwindow.h new file mode 100644 index 000000000..451f5fc4a --- /dev/null +++ b/examples/wayland/subsurface/shmwindow.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2015 LG Electronics Ltd, author: <mikko.levonmaa@lge.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples 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 The Qt Company Ltd 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$ +** +****************************************************************************/ + +#ifndef SHMWINDOW_H +#define SHMWINDOW_H + +#include <QtGui> + +class ShmWindow : public QRasterWindow +{ + Q_OBJECT +public: + explicit ShmWindow(QWindow *parent); + +protected: + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; + +private: + int m_rotation; + int m_timer; +}; +#endif // SHMWINDOW_H diff --git a/examples/wayland/subsurface/subsurface.pro b/examples/wayland/subsurface/subsurface.pro new file mode 100644 index 000000000..5371ac5f5 --- /dev/null +++ b/examples/wayland/subsurface/subsurface.pro @@ -0,0 +1,17 @@ +TEMPLATE = app + +QT += \ + gui gui-private core-private\ + quick \ + waylandclient \ + +HEADERS += \ + shmwindow.h \ + +SOURCES += \ + main.cpp \ + shmwindow.cpp \ + +RESOURCES += \ + qml.qrc + diff --git a/src/client/client.pro b/src/client/client.pro index 182a5d551..6802cd47b 100644 --- a/src/client/client.pro +++ b/src/client/client.pro @@ -80,6 +80,7 @@ SOURCES += qwaylandintegration.cpp \ qwaylandwindowmanagerintegration.cpp \ qwaylandinputcontext.cpp \ qwaylanddatadevice.cpp \ + qwaylandshm.cpp \ HEADERS += qwaylandintegration_p.h \ qwaylandnativeinterface_p.h \ @@ -112,6 +113,7 @@ HEADERS += qwaylandintegration_p.h \ qwaylandwindowmanagerintegration_p.h \ qwaylandinputcontext_p.h \ qwaylanddatadevice_p.h \ + qwaylandshm_p.h \ include(hardwareintegration/hardwareintegration.pri) include(shellintegration/shellintegration.pri) diff --git a/src/client/qwaylandcursor.cpp b/src/client/qwaylandcursor.cpp index 8dfc95c36..a76e05a9a 100644 --- a/src/client/qwaylandcursor.cpp +++ b/src/client/qwaylandcursor.cpp @@ -59,7 +59,7 @@ QWaylandCursor::QWaylandCursor(QWaylandScreen *screen) int cursorSize = cursorSizeFromEnv.toInt(&hasCursorSize); if (!hasCursorSize || cursorSize <= 0) cursorSize = 32; - mCursorTheme = wl_cursor_theme_load(cursorTheme, cursorSize, mDisplay->shm()); + mCursorTheme = wl_cursor_theme_load(cursorTheme, cursorSize, mDisplay->shm()->object()); if (!mCursorTheme) qDebug() << "Could not load theme" << cursorTheme; initCursorMap(); diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index a6f52bc24..82c1f201e 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -256,7 +256,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin mCompositorVersion = qMin((int)version, 3); mCompositor.init(registry, id, mCompositorVersion); } else if (interface == QStringLiteral("wl_shm")) { - mShm = static_cast<struct wl_shm *>(wl_registry_bind(registry, id, &wl_shm_interface,1)); + mShm.reset(new QWaylandShm(this, version, id)); } else if (interface == QStringLiteral("xdg_shell") && qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL")) { mShellXdg.reset(new QWaylandXdgShell(registry,id)); diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h index d5ee16fc9..65e914395 100644 --- a/src/client/qwaylanddisplay_p.h +++ b/src/client/qwaylanddisplay_p.h @@ -56,6 +56,7 @@ #include <QtWaylandClient/private/qwayland-wayland.h> #include <QtWaylandClient/private/qwaylandclientexport_p.h> #include <QtWaylandClient/private/qwayland-xdg-shell.h> +#include <QtWaylandClient/private/qwaylandshm_p.h> struct wl_cursor_image; @@ -156,7 +157,7 @@ public: * to enable many listeners at once. */ void addRegistryListener(RegistryListener listener, void *data); - struct wl_shm *shm() const { return mShm; } + QWaylandShm *shm() const { return mShm.data(); } static uint32_t currentTimeMillisec(); @@ -185,7 +186,7 @@ private: struct wl_display *mDisplay; QtWayland::wl_compositor mCompositor; - struct wl_shm *mShm; + QScopedPointer<QWaylandShm> mShm; QScopedPointer<QtWayland::wl_shell> mShell; QScopedPointer<QWaylandXdgShell> mShellXdg; QList<QWaylandScreen *> mScreens; diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp index 39fff533d..c04ddb610 100644 --- a/src/client/qwaylandintegration.cpp +++ b/src/client/qwaylandintegration.cpp @@ -130,8 +130,19 @@ QWaylandIntegration::QWaylandIntegration() mDrag = new QWaylandDrag(mDisplay); QString icStr = QPlatformInputContextFactory::requested(); - icStr.isNull() ? mInputContext.reset(new QWaylandInputContext(mDisplay)) - : mInputContext.reset(QPlatformInputContextFactory::create(icStr)); + if (!icStr.isNull()) { + mInputContext.reset(QPlatformInputContextFactory::create(icStr)); + } else { + //try to use the input context using the wl_text_input interface + QPlatformInputContext *ctx = new QWaylandInputContext(mDisplay); + mInputContext.reset(ctx); + + //use the traditional way for on screen keyboards for now + if (!mInputContext.data()->isValid()) { + ctx = QPlatformInputContextFactory::create(); + mInputContext.reset(ctx); + } + } } QWaylandIntegration::~QWaylandIntegration() diff --git a/src/client/qwaylandnativeinterface.cpp b/src/client/qwaylandnativeinterface.cpp index 98e1a7366..7df31bbc5 100644 --- a/src/client/qwaylandnativeinterface.cpp +++ b/src/client/qwaylandnativeinterface.cpp @@ -34,6 +34,7 @@ #include "qwaylandnativeinterface_p.h" #include "qwaylanddisplay_p.h" #include "qwaylandwindow_p.h" +#include "qwaylandsubsurface_p.h" #include "qwaylandextendedsurface_p.h" #include "qwaylandintegration_p.h" #include "qwaylanddisplay_p.h" @@ -44,6 +45,8 @@ #include <QtGui/QScreen> #include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h> +#include <QtPlatformHeaders/qwaylandwindowfunctions.h> + QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -151,6 +154,44 @@ void QWaylandNativeInterface::emitWindowPropertyChanged(QPlatformWindow *window, emit windowPropertyChanged(window,name); } +QFunctionPointer QWaylandNativeInterface::platformFunction(const QByteArray &resource) const +{ + if (resource == QWaylandWindowFunctions::setSyncIdentifier()) { + return QFunctionPointer(setSync); + } else if (resource == QWaylandWindowFunctions::setDeSyncIdentifier()) { + return QFunctionPointer(setDeSync); + } else if (resource == QWaylandWindowFunctions::isSyncIdentifier()) { + return QFunctionPointer(isSync); + } + return 0; +} + + +void QWaylandNativeInterface::setSync(QWindow *window) +{ + QWaylandWindow *ww = static_cast<QWaylandWindow*>(window->handle()); + if (ww->subSurfaceWindow()) { + ww->subSurfaceWindow()->setSync(); + } +} + +void QWaylandNativeInterface::setDeSync(QWindow *window) +{ + QWaylandWindow *ww = static_cast<QWaylandWindow*>(window->handle()); + if (ww->subSurfaceWindow()) { + ww->subSurfaceWindow()->setDeSync(); + } +} + +bool QWaylandNativeInterface::isSync(QWindow *window) +{ + QWaylandWindow *ww = static_cast<QWaylandWindow*>(window->handle()); + if (ww->subSurfaceWindow()) { + return ww->subSurfaceWindow()->isSync(); + } + return false; +} + } QT_END_NAMESPACE diff --git a/src/client/qwaylandnativeinterface_p.h b/src/client/qwaylandnativeinterface_p.h index 7050f9758..9ea62a90c 100644 --- a/src/client/qwaylandnativeinterface_p.h +++ b/src/client/qwaylandnativeinterface_p.h @@ -75,9 +75,15 @@ public: void emitWindowPropertyChanged(QPlatformWindow *window, const QString &name); + QFunctionPointer platformFunction(const QByteArray &resource) const Q_DECL_OVERRIDE; + private: QWaylandIntegration *m_integration; QHash<QPlatformWindow*, QVariantMap> m_windowProperties; + + static void setSync(QWindow *window); + static void setDeSync(QWindow *window); + static bool isSync(QWindow *window); }; } diff --git a/src/client/qwaylandshm.cpp b/src/client/qwaylandshm.cpp new file mode 100644 index 000000000..1d7981477 --- /dev/null +++ b/src/client/qwaylandshm.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QtWaylandClient/private/qwaylandshm_p.h> +#include <QtWaylandClient/private/qwaylanddisplay_p.h> + +#include "qwaylandshmformathelper.h" + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +QWaylandShm::QWaylandShm(QWaylandDisplay *display, int version, uint32_t id) + : QtWayland::wl_shm(display->wl_registry(), id, qMin(version, 1)) +{ +} + +QWaylandShm::~QWaylandShm() +{ + +} + +void QWaylandShm::shm_format(uint32_t format) +{ + m_formats << format; +} + +bool QWaylandShm::formatSupported(wl_shm_format format) const +{ + return m_formats.contains(format); +} + +bool QWaylandShm::formatSupported(QImage::Format format) const +{ + wl_shm_format fmt = formatFrom(format); + return formatSupported(fmt); +} + +wl_shm_format QWaylandShm::formatFrom(QImage::Format format) +{ + return QWaylandShmFormatHelper::fromQImageFormat(format); +} + +QImage::Format QWaylandShm::formatFrom(wl_shm_format format) +{ + return QWaylandShmFormatHelper::fromWaylandShmFormat(format); +} + +} + +QT_END_NAMESPACE diff --git a/src/client/qwaylandshm_p.h b/src/client/qwaylandshm_p.h new file mode 100644 index 000000000..10feae6a7 --- /dev/null +++ b/src/client/qwaylandshm_p.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDSHM_H +#define QWAYLANDSHM_H + +#include <QVector> +#include <QImage> + +#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/private/qwayland-wayland.h> + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +class QWaylandDisplay; + +class Q_WAYLAND_CLIENT_EXPORT QWaylandShm : public QtWayland::wl_shm +{ + +public: + + QWaylandShm(QWaylandDisplay *display, int version, uint32_t id); + ~QWaylandShm(); + + bool formatSupported(wl_shm_format format) const; + bool formatSupported(QImage::Format format) const; + + static wl_shm_format formatFrom(QImage::Format format); + static QImage::Format formatFrom(wl_shm_format format); + +protected: + virtual void shm_format(uint32_t format); + +private: + QVector<uint32_t> m_formats; + +}; + +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/client/qwaylandshmbackingstore.cpp b/src/client/qwaylandshmbackingstore.cpp index f009e0811..87205d4cd 100644 --- a/src/client/qwaylandshmbackingstore.cpp +++ b/src/client/qwaylandshmbackingstore.cpp @@ -32,6 +32,7 @@ ****************************************************************************/ #include "qwaylandshmbackingstore_p.h" #include "qwaylandwindow_p.h" +#include "qwaylandsubsurface_p.h" #include "qwaylanddisplay_p.h" #include "qwaylandscreen_p.h" #include "qwaylandabstractdecoration_p.h" @@ -42,7 +43,6 @@ #include <wayland-client.h> #include <wayland-client-protocol.h> -#include "qwaylandshmformathelper.h" #include <unistd.h> #include <fcntl.h> @@ -85,11 +85,12 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display, return; } - wl_shm_format wl_format = QWaylandShmFormatHelper::fromQImageFormat(format); + QWaylandShm* shm = display->shm(); + wl_shm_format wl_format = shm->formatFrom(format); mImage = QImage(data, size.width(), size.height(), stride, format); mImage.setDevicePixelRatio(qreal(scale)); - mShmPool = wl_shm_create_pool(display->shm(), fd, alloc); + mShmPool = wl_shm_create_pool(shm->object(), fd, alloc); mBuffer = wl_shm_pool_create_buffer(mShmPool,0, size.width(), size.height(), stride, wl_format); close(fd); @@ -174,8 +175,13 @@ void QWaylandShmBackingStore::beginPaint(const QRegion &) ensureSize(); QWaylandWindow *window = waylandWindow(); - if (window->attached() && mBackBuffer == window->attached() && mFrameCallback) + QWaylandSubSurface *sub = window->subSurfaceWindow(); + + bool waiting = window->attached() && mBackBuffer == window->attached() && mFrameCallback; + bool syncSubSurface = sub && sub->isSync(); + if (waiting && !syncSubSurface) { window->waitForFrameSync(); + } window->setCanResize(false); } @@ -219,34 +225,47 @@ void QWaylandShmBackingStore::flush(QWindow *window, const QRegion ®ion, cons mFrontBuffer = mBackBuffer; + QWaylandWindow *w = waylandWindow(); + bool synchModeSubSurface = w->subSurfaceWindow() && w->subSurfaceWindow()->isSync(); + if (mFrameCallback) { - mFrontBufferIsDirty = true; - return; + if (synchModeSubSurface) { + wl_callback_destroy(mFrameCallback); + mFrameCallback = Q_NULLPTR; + } else { + mFrontBufferIsDirty = true; + return; + } } - mFrameCallback = waylandWindow()->frame(); - wl_callback_add_listener(mFrameCallback,&frameCallbackListener,this); - QMargins margins = windowDecorationMargins(); + // Dont acquire the frame callback as that will cause beginPaint + // to block in waiting for frame sync since the damage will trigger + // its own sync request + if (!synchModeSubSurface) { + mFrameCallback = w->frame(); + wl_callback_add_listener(mFrameCallback, &frameCallbackListener, this); + } + QMargins margins = windowDecorationMargins(); bool damageAll = false; - if (waylandWindow()->attached() != mFrontBuffer) { - delete waylandWindow()->attached(); + if (w->attached() != mFrontBuffer) { + delete w->attached(); damageAll = true; } - waylandWindow()->attachOffset(mFrontBuffer); + w->attachOffset(mFrontBuffer); if (damageAll) { //need to damage it all, otherwise the attach offset may screw up - waylandWindow()->damage(QRect(QPoint(0,0), window->size())); + w->damage(QRect(QPoint(0,0), window->size())); } else { QVector<QRect> rects = region.rects(); for (int i = 0; i < rects.size(); i++) { QRect rect = rects.at(i); rect.translate(margins.left(),margins.top()); - waylandWindow()->damage(rect); + w->damage(rect); } } - waylandWindow()->commit(); + w->commit(); mFrontBufferIsDirty = false; } diff --git a/src/client/qwaylandsubsurface.cpp b/src/client/qwaylandsubsurface.cpp index ec813609f..eac847c75 100644 --- a/src/client/qwaylandsubsurface.cpp +++ b/src/client/qwaylandsubsurface.cpp @@ -45,9 +45,10 @@ QWaylandSubSurface::QWaylandSubSurface(QWaylandWindow *window, QWaylandWindow *p : QtWayland::wl_subsurface(sub_surface) , m_window(window) , m_parent(parent) + , m_synchronized(false) { m_parent->mChildren << this; - set_desync(); + setDeSync(); } QWaylandSubSurface::~QWaylandSubSurface() @@ -55,6 +56,30 @@ QWaylandSubSurface::~QWaylandSubSurface() m_parent->mChildren.removeOne(this); } +void QWaylandSubSurface::setSync() +{ + QMutexLocker l(&m_syncLock); + QWaylandSubSurface::set_sync(); +} + +void QWaylandSubSurface::setDeSync() +{ + QMutexLocker l(&m_syncLock); + QWaylandSubSurface::set_desync(); +} + +void QWaylandSubSurface::set_sync() +{ + m_synchronized = true; + QtWayland::wl_subsurface::set_sync(); +} + +void QWaylandSubSurface::set_desync() +{ + m_synchronized = false; + QtWayland::wl_subsurface::set_desync(); +} + } QT_END_NAMESPACE diff --git a/src/client/qwaylandsubsurface_p.h b/src/client/qwaylandsubsurface_p.h index 4cbb99251..b8ea6aaf3 100644 --- a/src/client/qwaylandsubsurface_p.h +++ b/src/client/qwaylandsubsurface_p.h @@ -48,6 +48,7 @@ #include <wayland-client.h> #include <QtCore/qglobal.h> +#include <QtCore/qmutex.h> #include <QtWaylandClient/private/qwaylandclientexport_p.h> #include <QtWaylandClient/private/qwayland-wayland.h> @@ -68,9 +69,22 @@ public: QWaylandWindow *window() const { return m_window; } QWaylandWindow *parent() const { return m_parent; } + void setSync(); + void setDeSync(); + bool isSync() const { return m_synchronized; } + QMutex *syncMutex() { return &m_syncLock; } + private: + + // Intentionally hide public methods from ::wl_subsurface + // to keep track of the sync state + void set_sync(); + void set_desync(); QWaylandWindow *m_window; QWaylandWindow *m_parent; + bool m_synchronized; + QMutex m_syncLock; + }; QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandtexturebufferattacher.cpp b/src/compositor/compositor_api/qwaylandtexturebufferattacher.cpp new file mode 100644 index 000000000..11ead006e --- /dev/null +++ b/src/compositor/compositor_api/qwaylandtexturebufferattacher.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandtexturebufferattacher_p.h" + +#include <QQuickWindow> +#include <QSGTexture> + +#include <QtCompositor/qwaylandquicksurface.h> +#include <QtCompositor/qwaylandoutput.h> + +QWaylandTextureBufferAttacher::QWaylandTextureBufferAttacher(QWaylandQuickSurface *surface) + : m_surface(surface) + , m_texture(0) + , m_update(false) +{ +} + +QWaylandTextureBufferAttacher::~QWaylandTextureBufferAttacher() +{ + if (m_texture) + m_texture->deleteLater(); + m_buffer = QWaylandBufferRef(); + m_nextBuffer = QWaylandBufferRef(); +} + +void QWaylandTextureBufferAttacher::attach(const QWaylandBufferRef &ref) +{ + m_nextBuffer = ref; + m_update = true; +} + +void QWaylandTextureBufferAttacher::updateTexture() +{ + m_buffer = m_nextBuffer; + delete m_texture; + m_texture = 0; + + QQuickWindow *window = static_cast<QQuickWindow *>(m_surface->mainOutput()->window()); + if (m_nextBuffer) { + if (m_buffer.isShm()) { + m_texture = window->createTextureFromImage(m_buffer.image()); + } else { + QQuickWindow::CreateTextureOptions opt = 0; + if (m_surface->useTextureAlpha()) { + opt |= QQuickWindow::TextureHasAlphaChannel; + } + m_texture = window->createTextureFromId(m_buffer.createTexture(), m_surface->size(), opt); + } + m_texture->bind(); + } + + m_update = false; +} + +void QWaylandTextureBufferAttacher::unmap() +{ + m_nextBuffer = QWaylandBufferRef(); + m_update = true; +} + +void QWaylandTextureBufferAttacher::invalidateTexture() +{ + if (m_buffer) + m_buffer.destroyTexture(); + delete m_texture; + m_texture = 0; + m_update = true; + m_buffer = QWaylandBufferRef(); +} + diff --git a/src/compositor/compositor_api/qwaylandtexturebufferattacher_p.h b/src/compositor/compositor_api/qwaylandtexturebufferattacher_p.h new file mode 100644 index 000000000..ea4556d27 --- /dev/null +++ b/src/compositor/compositor_api/qwaylandtexturebufferattacher_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDTEXTUREBUFFERATTACHER_H +#define QWAYLANDTEXTUREBUFFERATTACHER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCompositor/qwaylandsurface.h> +#include <QtCompositor/qwaylandbufferref.h> + +QT_BEGIN_NAMESPACE + +class QSGTexture; +class QWaylandQuickSurface; + +class QWaylandTextureBufferAttacher : public QWaylandBufferAttacher +{ +public: + QWaylandTextureBufferAttacher(QWaylandQuickSurface *surface); + virtual ~QWaylandTextureBufferAttacher(); + + void updateTexture(); + void invalidateTexture(); + + bool isDirty() const { return m_update; } + QSGTexture* texture() const { return m_texture; } + QWaylandBufferRef currentBuffer() const { return m_buffer; } + +protected: + virtual void attach(const QWaylandBufferRef &ref) Q_DECL_OVERRIDE; + virtual void unmap() Q_DECL_OVERRIDE; + + QWaylandQuickSurface *m_surface; + QSGTexture *m_texture; + + QWaylandBufferRef m_buffer; + QWaylandBufferRef m_nextBuffer; + bool m_update; +}; + +QT_END_NAMESPACE +#endif + + diff --git a/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h b/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h index 4f97ca1b2..a3866f285 100644 --- a/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h +++ b/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h @@ -88,7 +88,7 @@ public: void setDisplayed(); - inline bool isComitted() const { return m_committed; } + inline bool isCommitted() const { return m_committed; } inline void setCommitted() { m_committed = true; } inline bool isDisplayed() const { return m_is_displayed; } diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp index faaa6aef8..2df291531 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp @@ -35,6 +35,7 @@ #include <QtWaylandClient/private/qwaylanddisplay_p.h> #include <QtWaylandClient/private/qwaylandwindow_p.h> +#include <QtWaylandClient/private/qwaylandsubsurface_p.h> #include <QtWaylandClient/private/qwaylandabstractdecoration_p.h> #include <QtWaylandClient/private/qwaylandintegration_p.h> #include "qwaylandeglwindow.h" @@ -50,6 +51,8 @@ #include <QtGui/QOpenGLShaderProgram> #include <QtGui/QOpenGLFunctions> +#include <QtCore/qmutex.h> + // Constants from EGL_KHR_create_context #ifndef EGL_CONTEXT_MINOR_VERSION_KHR #define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB @@ -220,6 +223,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *dis , m_display(display) , m_blitter(0) , mUseNativeDefaultFbo(false) + , mSupportNonBlockingSwap(true) { QSurfaceFormat fmt = format; if (static_cast<QWaylandIntegration *>(QGuiApplicationPrivate::platformIntegration())->display()->supportsWindowDecoration()) @@ -290,6 +294,17 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *dis return; } + EGLint a = EGL_MIN_SWAP_INTERVAL; + EGLint b = EGL_MAX_SWAP_INTERVAL; + if (!eglGetConfigAttrib(m_eglDisplay, m_config, a, &a) || + !eglGetConfigAttrib(m_eglDisplay, m_config, b, &b) || + a > 0) { + mSupportNonBlockingSwap = false; + } + if (!mSupportNonBlockingSwap) { + qWarning() << "Non-blocking swap buffers not supported. Subsurface rendering can be affected."; + } + updateGLFormat(); } @@ -518,7 +533,20 @@ void QWaylandGLContext::swapBuffers(QPlatformSurface *surface) m_blitter->blit(window); } - eglSwapBuffers(m_eglDisplay, eglSurface); + + QWaylandSubSurface *sub = window->subSurfaceWindow(); + if (sub) { + QMutexLocker l(sub->syncMutex()); + + int si = (sub->isSync() && mSupportNonBlockingSwap) ? 0 : m_format.swapInterval(); + + eglSwapInterval(m_eglDisplay, si); + eglSwapBuffers(m_eglDisplay, eglSurface); + } else { + eglSwapInterval(m_eglDisplay, m_format.swapInterval()); + eglSwapBuffers(m_eglDisplay, eglSurface); + } + window->setCanResize(true); } diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h index bc92c9501..42236c643 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h @@ -86,6 +86,7 @@ private: DecorationsBlitter *m_blitter; bool mUseNativeDefaultFbo; uint m_api; + bool mSupportNonBlockingSwap; friend class DecorationsBlitter; }; diff --git a/src/platformheaders/platformheaders.pro b/src/platformheaders/platformheaders.pro new file mode 100644 index 000000000..1d64b354e --- /dev/null +++ b/src/platformheaders/platformheaders.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs +VERSION = $$MODULE_VERSION +MODULE_INCNAME = QtPlatformHeaders + +include(waylandfunctions/waylandfunctions.pri) + +load(qt_module_headers) +#load(qt_docs) +load(qt_installs) + diff --git a/src/platformheaders/waylandfunctions/qwaylandwindowfunctions.h b/src/platformheaders/waylandfunctions/qwaylandwindowfunctions.h new file mode 100644 index 000000000..a9c40f91d --- /dev/null +++ b/src/platformheaders/waylandfunctions/qwaylandwindowfunctions.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2015 LG Electronics Ltd, author: mikko.levonmaa@lge.com +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDWINDOWFUNCTIONS_H +#define QWAYLANDWINDOWFUNCTIONS_H + +#include <QtCore/QByteArray> +#include <QtGui/QGuiApplication> + +QT_BEGIN_NAMESPACE + +class QWindow; + +class QWaylandWindowFunctions { +public: + + typedef void (*SetWindowSync)(QWindow *window); + typedef void (*SetWindowDeSync)(QWindow *window); + typedef bool (*IsWindowSync)(QWindow *window); + static const QByteArray setSyncIdentifier() { return QByteArrayLiteral("WaylandSubSurfaceSetSync"); } + static const QByteArray setDeSyncIdentifier() { return QByteArrayLiteral("WaylandSubSurfaceSetDeSync"); } + static const QByteArray isSyncIdentifier() { return QByteArrayLiteral("WaylandSubSurfaceIsSync"); } + + static void setSync(QWindow *window) + { + static SetWindowSync func = reinterpret_cast<SetWindowSync>(QGuiApplication::platformFunction(setSyncIdentifier())); + Q_ASSERT(func); + func(window); + } + + static void setDeSync(QWindow *window) + { + static SetWindowDeSync func = reinterpret_cast<SetWindowDeSync>(QGuiApplication::platformFunction(setDeSyncIdentifier())); + Q_ASSERT(func); + func(window); + } + + static bool isSync(QWindow *window) + { + static IsWindowSync func = reinterpret_cast<IsWindowSync>(QGuiApplication::platformFunction(isSyncIdentifier())); + Q_ASSERT(func); + return func(window); + } + +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDWINDOWFUNCTIONS_H + diff --git a/src/platformheaders/waylandfunctions/waylandfunctions.pri b/src/platformheaders/waylandfunctions/waylandfunctions.pri new file mode 100644 index 000000000..202df907e --- /dev/null +++ b/src/platformheaders/waylandfunctions/waylandfunctions.pri @@ -0,0 +1 @@ +HEADERS += $$PWD/qwaylandwindowfunctions.h diff --git a/src/src.pro b/src/src.pro index bf5ffe36a..f9cf9172d 100644 --- a/src/src.pro +++ b/src/src.pro @@ -23,3 +23,5 @@ sub_plugins.subdir = plugins sub_plugins.depends = sub-qtwaylandscanner sub-client sub-compositor sub_plugins.target = sub-plugins SUBDIRS += sub_plugins + +SUBDIRS += platformheaders diff --git a/sync.profile b/sync.profile index 6fee67e41..13e5340b8 100644 --- a/sync.profile +++ b/sync.profile @@ -1,6 +1,7 @@ %modules = ( # path to module name map "QtWaylandCompositor" => "$basedir/src/compositor", "QtWaylandClient" => "$basedir/src/client", + "QtPlatformHeaders" => "$basedir/src/platformheaders", ); %moduleheaders = ( # restrict the module headers to those found in relative path ); |