diff options
author | Mikko Levonmaa <mikko.levonmaa@lge.com> | 2015-10-30 12:20:24 +0200 |
---|---|---|
committer | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2015-11-06 15:08:47 +0000 |
commit | 2eff05fe14c910c8b2cade8674e49404c6843e74 (patch) | |
tree | d076bb844ea82b7c224a5d9c39d5dd8834095149 | |
parent | 6e46086974b05d3ed71470cf31916c4b7ffd11bc (diff) |
Add QWaylandWindowFunctions
Allow the control of the subsurface sync mode
Change-Id: I19f35261313282873f57228487a63a8f6a780b0c
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
-rw-r--r-- | src/client/qwaylandnativeinterface.cpp | 41 | ||||
-rw-r--r-- | src/client/qwaylandnativeinterface_p.h | 6 | ||||
-rw-r--r-- | src/client/qwaylandsubsurface.cpp | 25 | ||||
-rw-r--r-- | src/client/qwaylandsubsurface_p.h | 11 | ||||
-rw-r--r-- | src/platformheaders/platformheaders.pro | 10 | ||||
-rw-r--r-- | src/platformheaders/waylandfunctions/qwaylandwindowfunctions.h | 80 | ||||
-rw-r--r-- | src/platformheaders/waylandfunctions/waylandfunctions.pri | 1 | ||||
-rw-r--r-- | src/src.pro | 2 | ||||
-rw-r--r-- | sync.profile | 1 |
9 files changed, 176 insertions, 1 deletions
diff --git a/src/client/qwaylandnativeinterface.cpp b/src/client/qwaylandnativeinterface.cpp index 0d20075f0..050099f8b 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" @@ -43,6 +44,8 @@ #include <QtGui/QScreen> #include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h> +#include <QtPlatformHeaders/qwaylandwindowfunctions.h> + QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -141,6 +144,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/qwaylandsubsurface.cpp b/src/client/qwaylandsubsurface.cpp index ec813609f..72b80c18f 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,28 @@ QWaylandSubSurface::~QWaylandSubSurface() m_parent->mChildren.removeOne(this); } +void QWaylandSubSurface::setSync() +{ + QWaylandSubSurface::set_sync(); +} + +void QWaylandSubSurface::setDeSync() +{ + 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..5255df5c9 100644 --- a/src/client/qwaylandsubsurface_p.h +++ b/src/client/qwaylandsubsurface_p.h @@ -68,9 +68,20 @@ public: QWaylandWindow *window() const { return m_window; } QWaylandWindow *parent() const { return m_parent; } + void setSync(); + void setDeSync(); + bool isSync() const { return m_synchronized; } + 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; + }; QT_END_NAMESPACE 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 332d0dfdb..ed193bd3c 100644 --- a/src/src.pro +++ b/src/src.pro @@ -22,3 +22,5 @@ sub_plugins.depends = sub-qtwaylandscanner sub-client contains(CONFIG, wayland-compositor): sub_plugins.depends += sub-compositor sub_plugins.target = sub-plugins SUBDIRS += sub_plugins + +SUBDIRS += platformheaders diff --git a/sync.profile b/sync.profile index 5bff75354..61302e99f 100644 --- a/sync.profile +++ b/sync.profile @@ -1,6 +1,7 @@ %modules = ( # path to module name map "QtCompositor" => "$basedir/src/compositor", "QtWaylandClient" => "$basedir/src/client", + "QtPlatformHeaders" => "$basedir/src/platformheaders", ); %moduleheaders = ( # restrict the module headers to those found in relative path ); |