diff options
author | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2016-05-20 14:35:43 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2016-05-20 14:36:27 +0200 |
commit | de056826921de614e2ec2d9c3d35025ed43a27ca (patch) | |
tree | 111913497f39e6cbad7403743ab40a5d9aed734c | |
parent | b623352c62e512d671cda46212d58d4f746dd220 (diff) | |
parent | 5e5e866c8c1fc8234c25770d84e9591041e67d69 (diff) | |
download | qtwayland-de056826921de614e2ec2d9c3d35025ed43a27ca.tar.gz |
Merge remote-tracking branch 'qt/5.7' into 5.7.0
Change-Id: I8396ea4fc9f656accd2e97e3c78570bff64928cd
140 files changed, 1324 insertions, 1060 deletions
diff --git a/examples/wayland/custom-extension/client/customextension.cpp b/examples/wayland/custom-extension/client/customextension.cpp index 68a1d4b8..050b0d5c 100644 --- a/examples/wayland/custom-extension/client/customextension.cpp +++ b/examples/wayland/custom-extension/client/customextension.cpp @@ -46,8 +46,6 @@ QT_BEGIN_NAMESPACE -namespace QtWaylandClient { - CustomExtension::CustomExtension() : QWaylandClientExtensionTemplate(/* Supported protocol version */ 1 ) { @@ -68,6 +66,5 @@ void CustomExtension::example_extension_qtevent(struct wl_surface *surface, emit eventReceived(text, value); } -} QT_END_NAMESPACE diff --git a/examples/wayland/custom-extension/client/customextension.h b/examples/wayland/custom-extension/client/customextension.h index 16ace4bf..a041d5a7 100644 --- a/examples/wayland/custom-extension/client/customextension.h +++ b/examples/wayland/custom-extension/client/customextension.h @@ -48,8 +48,6 @@ QT_BEGIN_NAMESPACE -namespace QtWaylandClient { - class CustomExtension : public QWaylandClientExtensionTemplate<CustomExtension>, public QtWayland::qt_example_extension { Q_OBJECT @@ -70,8 +68,6 @@ private: }; -} - QT_END_NAMESPACE #endif // CUSTOMEXTENSION_H diff --git a/examples/wayland/custom-extension/client/main.cpp b/examples/wayland/custom-extension/client/main.cpp index fe8ec59a..8c27fa77 100644 --- a/examples/wayland/custom-extension/client/main.cpp +++ b/examples/wayland/custom-extension/client/main.cpp @@ -47,8 +47,6 @@ QT_BEGIN_NAMESPACE -namespace QtWaylandClient { - static CustomExtension * extension_global; class CustomIntegrationPlugin : public QPlatformIntegrationPlugin @@ -78,8 +76,6 @@ public: return extension_global->integration(); } -} - QT_END_NAMESPACE #include "main.moc" diff --git a/examples/wayland/custom-extension/compositor/customextension.cpp b/examples/wayland/custom-extension/compositor/customextension.cpp index a63d3c5a..6c1f0597 100644 --- a/examples/wayland/custom-extension/compositor/customextension.cpp +++ b/examples/wayland/custom-extension/compositor/customextension.cpp @@ -52,7 +52,7 @@ CustomExtension::CustomExtension() void CustomExtension::initialize() { - QWaylandExtensionTemplate::initialize(); + QWaylandCompositorExtensionTemplate::initialize(); QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); init(compositor->display(), 1); } diff --git a/examples/wayland/custom-extension/compositor/customextension.h b/examples/wayland/custom-extension/compositor/customextension.h index 81c3c505..8419eeea 100644 --- a/examples/wayland/custom-extension/compositor/customextension.h +++ b/examples/wayland/custom-extension/compositor/customextension.h @@ -43,14 +43,14 @@ #include "wayland-util.h" -#include <QtWaylandCompositor/QWaylandExtensionTemplate> +#include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate> #include <QtWaylandCompositor/QWaylandQuickExtension> #include <QtWaylandCompositor/QWaylandCompositor> #include "qwayland-server-custom.h" namespace QtWayland { -class CustomExtension : public QWaylandExtensionTemplate<CustomExtension>, public QtWaylandServer::qt_example_extension +class CustomExtension : public QWaylandCompositorExtensionTemplate<CustomExtension>, public QtWaylandServer::qt_example_extension { Q_OBJECT public: diff --git a/examples/wayland/custom-extension/compositor/qml/main.qml b/examples/wayland/custom-extension/compositor/qml/main.qml index ff83133b..097bfe30 100644 --- a/examples/wayland/custom-extension/compositor/qml/main.qml +++ b/examples/wayland/custom-extension/compositor/qml/main.qml @@ -64,7 +64,7 @@ WaylandCompositor { Component { id: chromeComponent - WlShellSurfaceItem { + ShellSurfaceItem { id: chrome onSurfaceDestroyed: { if (chrome === lastItem) diff --git a/examples/wayland/custom-extension/qmltestapp/main.cpp b/examples/wayland/custom-extension/qmltestapp/main.cpp index 23e280ca..6140862d 100644 --- a/examples/wayland/custom-extension/qmltestapp/main.cpp +++ b/examples/wayland/custom-extension/qmltestapp/main.cpp @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType<QtWaylandClient::CustomExtension>("com.theqtcompany.customextension", 1, 0, "CustomExtension"); + qmlRegisterType<CustomExtension>("com.theqtcompany.customextension", 1, 0, "CustomExtension"); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); diff --git a/examples/wayland/multi-output/qml/ShellChrome.qml b/examples/wayland/multi-output/qml/ShellChrome.qml index 1dc90647..dac3eb09 100644 --- a/examples/wayland/multi-output/qml/ShellChrome.qml +++ b/examples/wayland/multi-output/qml/ShellChrome.qml @@ -41,12 +41,9 @@ import QtQuick 2.0 import QtWayland.Compositor 1.0 -WlShellSurfaceItem { +ShellSurfaceItem { id: rootChrome - shellSurface: WlShellSurface { - } - onSurfaceDestroyed: { view.bufferLock = true; destroyAnimation.start(); diff --git a/examples/wayland/pure-qml/pure-qml.pro b/examples/wayland/pure-qml/pure-qml.pro index f0a10260..20fc529e 100644 --- a/examples/wayland/pure-qml/pure-qml.pro +++ b/examples/wayland/pure-qml/pure-qml.pro @@ -8,7 +8,6 @@ OTHER_FILES = \ qml/Screen.qml \ qml/Chrome.qml \ qml/Keyboard.qml \ - qml/XdgChrome.qml \ images/background.jpg \ RESOURCES += pure-qml.qrc diff --git a/examples/wayland/pure-qml/pure-qml.qrc b/examples/wayland/pure-qml/pure-qml.qrc index 333f5e61..8c95434d 100644 --- a/examples/wayland/pure-qml/pure-qml.qrc +++ b/examples/wayland/pure-qml/pure-qml.qrc @@ -5,6 +5,5 @@ <file>qml/Screen.qml</file> <file>qml/Chrome.qml</file> <file>qml/Keyboard.qml</file> - <file>qml/XdgChrome.qml</file> </qresource> </RCC> diff --git a/examples/wayland/pure-qml/qml/Chrome.qml b/examples/wayland/pure-qml/qml/Chrome.qml index 1dc90647..1c9066ef 100644 --- a/examples/wayland/pure-qml/qml/Chrome.qml +++ b/examples/wayland/pure-qml/qml/Chrome.qml @@ -41,17 +41,27 @@ import QtQuick 2.0 import QtWayland.Compositor 1.0 -WlShellSurfaceItem { +ShellSurfaceItem { id: rootChrome - shellSurface: WlShellSurface { - } - onSurfaceDestroyed: { view.bufferLock = true; destroyAnimation.start(); } + Connections { + target: shellSurface + + // some signals are not available on wl_shell, so let's ignore them + ignoreUnknownSignals: true + + onActivatedChanged: { // xdg_shell only + if (shellSurface.activated) { + receivedFocusAnimation.start(); + } + } + } + SequentialAnimation { id: destroyAnimation ParallelAnimation { @@ -62,12 +72,23 @@ WlShellSurfaceItem { ScriptAction { script: { rootChrome.destroy(); } } } + SequentialAnimation { + id: receivedFocusAnimation + ParallelAnimation { + NumberAnimation { target: scaleTransform; property: "yScale"; to: 1.02; duration: 100; easing.type: Easing.OutQuad } + NumberAnimation { target: scaleTransform; property: "xScale"; to: 1.02; duration: 100; easing.type: Easing.OutQuad } + } + ParallelAnimation { + NumberAnimation { target: scaleTransform; property: "yScale"; to: 1; duration: 100; easing.type: Easing.InOutQuad } + NumberAnimation { target: scaleTransform; property: "xScale"; to: 1; duration: 100; easing.type: Easing.InOutQuad } + } + } + transform: [ Scale { id:scaleTransform origin.x: rootChrome.width / 2 origin.y: rootChrome.height / 2 - } ] } diff --git a/examples/wayland/pure-qml/qml/XdgChrome.qml b/examples/wayland/pure-qml/qml/XdgChrome.qml deleted file mode 100644 index afe137c6..00000000 --- a/examples/wayland/pure-qml/qml/XdgChrome.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt-project.org/legal -** -** 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.0 -import QtWayland.Compositor 1.0 - -XdgSurfaceItem { - id: rootChrome - - xdgSurface: XdgSurface { - id: xdgSurface - onActivatedChanged: { - if (xdgSurface.activated) { - receivedFocusAnimation.start(); - } - } - } - - onSurfaceDestroyed: { - view.bufferLock = true; - destroyAnimation.start(); - } - - SequentialAnimation { - id: receivedFocusAnimation - ParallelAnimation { - NumberAnimation { target: scaleTransform; property: "yScale"; to: 1.02; duration: 100; easing.type: Easing.OutQuad } - NumberAnimation { target: scaleTransform; property: "xScale"; to: 1.02; duration: 100; easing.type: Easing.OutQuad } - } - ParallelAnimation { - NumberAnimation { target: scaleTransform; property: "yScale"; to: 1; duration: 100; easing.type: Easing.InOutQuad } - NumberAnimation { target: scaleTransform; property: "xScale"; to: 1; duration: 100; easing.type: Easing.InOutQuad } - } - } - - SequentialAnimation { - id: destroyAnimation - ParallelAnimation { - NumberAnimation { target: scaleTransform; property: "yScale"; to: 2/height; duration: 150 } - NumberAnimation { target: scaleTransform; property: "xScale"; to: 0.4; duration: 150 } - } - NumberAnimation { target: scaleTransform; property: "xScale"; to: 0; duration: 150 } - ScriptAction { script: { rootChrome.destroy(); } } - } - - transform: [ - Scale { - id: scaleTransform - origin.x: rootChrome.width / 2 - origin.y: rootChrome.height / 2 - } - ] -} diff --git a/examples/wayland/pure-qml/qml/main.qml b/examples/wayland/pure-qml/qml/main.qml index c50d4b67..6ee09f80 100644 --- a/examples/wayland/pure-qml/qml/main.qml +++ b/examples/wayland/pure-qml/qml/main.qml @@ -57,12 +57,6 @@ WaylandCompositor { } Component { - id: xdgChromeComponent - XdgChrome { - } - } - - Component { id: surfaceComponent WaylandSurface { } @@ -74,17 +68,13 @@ WaylandCompositor { onShowIsFullScreenChanged: console.debug("Show is fullscreen hint for Qt applications:", showIsFullScreen) }, WlShell { - id: defaultShell - onShellSurfaceCreated: { chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": shellSurface } ); } }, XdgShell { - id: xdgShell - onXdgSurfaceCreated: { - xdgChromeComponent.createObject(defaultOutput.surfaceArea, { "xdgSurface": xdgSurface } ); + chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": xdgSurface } ); } }, TextInputManager { diff --git a/examples/wayland/qwindow-compositor/compositorwindow.cpp b/examples/wayland/qwindow-compositor/compositorwindow.cpp index 7e10a173..537a3d08 100644 --- a/examples/wayland/qwindow-compositor/compositorwindow.cpp +++ b/examples/wayland/qwindow-compositor/compositorwindow.cpp @@ -116,10 +116,18 @@ void CompositorWindow::paintGL() functions->glEnable(GL_BLEND); functions->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + GLenum currentTarget = GL_TEXTURE_2D; Q_FOREACH (WindowCompositorView *view, m_compositor->views()) { if (view->isCursor()) continue; - GLuint textureId = view->getTexture(); + GLenum target; + GLuint textureId = view->getTexture(&target); + if (!textureId || !target) + continue; + if (target != currentTarget) { + currentTarget = target; + m_textureBlitter.bind(currentTarget); + } QWaylandSurface *surface = view->surface(); if (surface && surface->isMapped()) { QSize s = surface->size(); diff --git a/examples/wayland/qwindow-compositor/qwindow-compositor.pro b/examples/wayland/qwindow-compositor/qwindow-compositor.pro index 994276d9..6e23dc82 100644 --- a/examples/wayland/qwindow-compositor/qwindow-compositor.pro +++ b/examples/wayland/qwindow-compositor/qwindow-compositor.pro @@ -17,6 +17,4 @@ INCLUDEPATH += $$PWD/../../include RESOURCES += qwindow-compositor.qrc target.path = $$[QT_INSTALL_EXAMPLES]/wayland/qwindow-compositor -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS qwindow-compositor.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/wayland/qwindow-compositor -INSTALLS += target sources +INSTALLS += target diff --git a/examples/wayland/qwindow-compositor/windowcompositor.cpp b/examples/wayland/qwindow-compositor/windowcompositor.cpp index bd39908e..ecbbc504 100644 --- a/examples/wayland/qwindow-compositor/windowcompositor.cpp +++ b/examples/wayland/qwindow-compositor/windowcompositor.cpp @@ -50,25 +50,42 @@ #include <QtWaylandCompositor/qwaylanddrag.h> #include <QDebug> +#include <QOpenGLContext> + +#ifndef GL_TEXTURE_EXTERNAL_OES +#define GL_TEXTURE_EXTERNAL_OES 0x8D65 +#endif WindowCompositorView::WindowCompositorView() - : m_texture(0) + : m_textureTarget(GL_TEXTURE_2D) + , m_texture(0) , m_wlShellSurface(nullptr) , m_xdgSurface(nullptr) , m_xdgPopup(nullptr) , m_parentView(nullptr) {} -GLuint WindowCompositorView::getTexture() { +GLuint WindowCompositorView::getTexture(GLenum *target) +{ + QWaylandBufferRef buf = currentBuffer(); + m_texture = buf.textureForPlane(0); + + if (buf.bufferFormatEgl() == QWaylandBufferRef::BufferFormatEgl_EXTERNAL_OES) + m_textureTarget = GL_TEXTURE_EXTERNAL_OES; + if (advance()) { - if (m_texture) - glDeleteTextures(1, &m_texture); + if (!m_texture) + glGenTextures(1, &m_texture); - glGenTextures(1, &m_texture); - glBindTexture(GL_TEXTURE_2D, m_texture); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - currentBuffer().bindToTexture(); + glBindTexture(m_textureTarget, m_texture); + buf.bindToTexture(); } + + buf.updateTexture(); + + if (target) + *target = m_textureTarget; + return m_texture; } diff --git a/examples/wayland/qwindow-compositor/windowcompositor.h b/examples/wayland/qwindow-compositor/windowcompositor.h index 5290d7c8..80a7bebe 100644 --- a/examples/wayland/qwindow-compositor/windowcompositor.h +++ b/examples/wayland/qwindow-compositor/windowcompositor.h @@ -59,7 +59,7 @@ class WindowCompositorView : public QWaylandView Q_OBJECT public: WindowCompositorView(); - GLuint getTexture(); + GLuint getTexture(GLenum *target = 0); QPointF position() const { return m_position; } void setPosition(const QPointF &pos) { m_position = pos; } bool isCursor() const; @@ -72,6 +72,7 @@ public: private: friend class WindowCompositor; + GLenum m_textureTarget; GLuint m_texture; QPointF m_position; QWaylandWlShellSurface *m_wlShellSurface; diff --git a/examples/wayland/server-buffer/client/client.pro b/examples/wayland/server-buffer/client/client.pro index 6c2c9285..6e5cc87e 100644 --- a/examples/wayland/server-buffer/client/client.pro +++ b/examples/wayland/server-buffer/client/client.pro @@ -20,3 +20,6 @@ SOURCES += \ HEADERS += \ serverbufferrenderer.h + +target.path = $$[QT_INSTALL_EXAMPLES]/wayland/server-buffer/client +INSTALLS += target diff --git a/examples/wayland/server-buffer/compositor/compositor.pro b/examples/wayland/server-buffer/compositor/compositor.pro index f391d3a1..28a781bd 100644 --- a/examples/wayland/server-buffer/compositor/compositor.pro +++ b/examples/wayland/server-buffer/compositor/compositor.pro @@ -12,7 +12,8 @@ SOURCES += \ serverbufferitem.cpp HEADERS += \ - serverbufferitem.h + serverbufferitem.h \ + serverbuffertextureprovider.h OTHER_FILES = \ images/background.jpg @@ -21,3 +22,6 @@ RESOURCES += compositor.qrc CONFIG += wayland-scanner WAYLANDSERVERSOURCES += ../share-buffer.xml + +target.path = $$[QT_INSTALL_EXAMPLES]/wayland/server-buffer/compositor +INSTALLS += target diff --git a/examples/wayland/server-buffer/server-buffer.pro b/examples/wayland/server-buffer/server-buffer.pro index 16c55625..2f5f32b6 100644 --- a/examples/wayland/server-buffer/server-buffer.pro +++ b/examples/wayland/server-buffer/server-buffer.pro @@ -1,3 +1,6 @@ TEMPLATE=subdirs SUBDIRS += client compositor + +EXAMPLE_FILES += \ + share-buffer.xml diff --git a/src/client/client.pro b/src/client/client.pro index 61404eeb..994cf544 100644 --- a/src/client/client.pro +++ b/src/client/client.pro @@ -99,9 +99,6 @@ HEADERS += qwaylandintegration_p.h \ qwaylandsubsurface_p.h \ qwaylandtouch_p.h \ qwaylandqtkey_p.h \ - ../shared/qwaylandmimehelper.h \ - ../shared/qwaylandxkb.h \ - ../shared/qwaylandinputmethodeventbuilder.h \ qwaylandabstractdecoration_p.h \ qwaylanddecorationfactory_p.h \ qwaylanddecorationplugin_p.h \ @@ -109,6 +106,11 @@ HEADERS += qwaylandintegration_p.h \ qwaylandinputcontext_p.h \ qwaylanddatadevice_p.h \ qwaylandshm_p.h \ + qwaylandclientexport.h \ + ../shared/qwaylandinputmethodeventbuilder_p.h \ + ../shared/qwaylandmimehelper_p.h \ + ../shared/qwaylandxkb_p.h \ + ../shared/qwaylandshmformathelper_p.h include(hardwareintegration/hardwareintegration.pri) include(shellintegration/shellintegration.pri) diff --git a/src/client/global/qwaylandclientextension.cpp b/src/client/global/qwaylandclientextension.cpp index b71c41d1..04aca8c2 100644 --- a/src/client/global/qwaylandclientextension.cpp +++ b/src/client/global/qwaylandclientextension.cpp @@ -43,8 +43,6 @@ QT_BEGIN_NAMESPACE -namespace QtWaylandClient { - QWaylandClientExtensionPrivate::QWaylandClientExtensionPrivate() : QObjectPrivate() , waylandIntegration(NULL) @@ -57,7 +55,7 @@ QWaylandClientExtensionPrivate::QWaylandClientExtensionPrivate() if (QGuiApplication::platformNativeInterface()) { waylandDisplay = static_cast<struct ::wl_display*>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("wl_display")); } else { - waylandIntegration = new QWaylandIntegration(); + waylandIntegration = new QtWaylandClient::QWaylandIntegration(); waylandDisplay = waylandIntegration->display()->wl_display(); } @@ -84,7 +82,7 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver) d->version = ver; } -QWaylandIntegration *QWaylandClientExtension::integration() const +QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const { Q_D(const QWaylandClientExtension); return d->waylandIntegration; @@ -105,12 +103,10 @@ void QWaylandClientExtension::setVersion(const int ver) } } -bool QWaylandClientExtension::active() const +bool QWaylandClientExtension::isActive() const { Q_D(const QWaylandClientExtension); return d->active; } -} - QT_END_NAMESPACE diff --git a/src/client/global/qwaylandclientextension.h b/src/client/global/qwaylandclientextension.h index aee03eb2..a3de0aa4 100644 --- a/src/client/global/qwaylandclientextension.h +++ b/src/client/global/qwaylandclientextension.h @@ -39,13 +39,14 @@ #include <QObject> #include <qpa/qwindowsysteminterface.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtWaylandClient/private/qwayland-wayland.h> QT_BEGIN_NAMESPACE namespace QtWaylandClient { - class QWaylandIntegration; +} + class QWaylandClientExtensionPrivate; class QWaylandClientExtensionTemplatePrivate; @@ -54,13 +55,13 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject Q_OBJECT Q_DECLARE_PRIVATE(QWaylandClientExtension) Q_PROPERTY(int protocolVersion READ version NOTIFY versionChanged) - Q_PROPERTY(bool active READ active NOTIFY activeChanged) + Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) public: QWaylandClientExtension(const int version); - QWaylandIntegration *integration() const; + QtWaylandClient::QWaylandIntegration *integration() const; int version() const; - bool active() const; + bool isActive() const; virtual const struct wl_interface *extensionInterface() const = 0; virtual void bind(struct ::wl_registry *registry, int id, int version) = 0; @@ -101,8 +102,6 @@ public: } }; -} - QT_END_NAMESPACE #endif // QWAYLANDCLIENTEXTENSION_H diff --git a/src/client/global/qwaylandclientextension_p.h b/src/client/global/qwaylandclientextension_p.h index 9287ee95..70cf36c3 100644 --- a/src/client/global/qwaylandclientextension_p.h +++ b/src/client/global/qwaylandclientextension_p.h @@ -55,15 +55,13 @@ QT_BEGIN_NAMESPACE -namespace QtWaylandClient { - class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionPrivate : public QObjectPrivate, public QtWayland::wl_registry { Q_DECLARE_PUBLIC(QWaylandClientExtension) public: QWaylandClientExtensionPrivate(); - QWaylandIntegration *waylandIntegration; + QtWaylandClient::QWaylandIntegration *waylandIntegration; int version; bool active; @@ -79,8 +77,6 @@ public: { } }; -} - QT_END_NAMESPACE #endif /*QWAYLANDCLIENTEXTENSION_P_H*/ diff --git a/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h b/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h index 342742c3..adaf2902 100644 --- a/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h +++ b/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h @@ -52,7 +52,7 @@ // #include <QtCore/qglobal.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> QT_BEGIN_NAMESPACE diff --git a/src/client/hardwareintegration/qwaylandclientbufferintegrationfactory_p.h b/src/client/hardwareintegration/qwaylandclientbufferintegrationfactory_p.h index 0a5d3561..c70a2bd5 100644 --- a/src/client/hardwareintegration/qwaylandclientbufferintegrationfactory_p.h +++ b/src/client/hardwareintegration/qwaylandclientbufferintegrationfactory_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtCore/QStringList> QT_BEGIN_NAMESPACE diff --git a/src/client/hardwareintegration/qwaylandclientbufferintegrationplugin_p.h b/src/client/hardwareintegration/qwaylandclientbufferintegrationplugin_p.h index 39a03796..2830f95f 100644 --- a/src/client/hardwareintegration/qwaylandclientbufferintegrationplugin_p.h +++ b/src/client/hardwareintegration/qwaylandclientbufferintegrationplugin_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/client/hardwareintegration/qwaylandhardwareintegration_p.h b/src/client/hardwareintegration/qwaylandhardwareintegration_p.h index 3b8028ea..92748c9f 100644 --- a/src/client/hardwareintegration/qwaylandhardwareintegration_p.h +++ b/src/client/hardwareintegration/qwaylandhardwareintegration_p.h @@ -52,7 +52,7 @@ // #include <QtWaylandClient/private/qwayland-hardware-integration.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> QT_BEGIN_NAMESPACE diff --git a/src/client/hardwareintegration/qwaylandserverbufferintegration_p.h b/src/client/hardwareintegration/qwaylandserverbufferintegration_p.h index 11ea36bc..e3943da8 100644 --- a/src/client/hardwareintegration/qwaylandserverbufferintegration_p.h +++ b/src/client/hardwareintegration/qwaylandserverbufferintegration_p.h @@ -55,7 +55,7 @@ #include <QtGui/qopengl.h> #include <QtWaylandClient/private/qwayland-server-buffer-extension.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> QT_BEGIN_NAMESPACE diff --git a/src/client/hardwareintegration/qwaylandserverbufferintegrationfactory_p.h b/src/client/hardwareintegration/qwaylandserverbufferintegrationfactory_p.h index 91871fad..f1785620 100644 --- a/src/client/hardwareintegration/qwaylandserverbufferintegrationfactory_p.h +++ b/src/client/hardwareintegration/qwaylandserverbufferintegrationfactory_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtCore/QStringList> QT_BEGIN_NAMESPACE diff --git a/src/client/hardwareintegration/qwaylandserverbufferintegrationplugin_p.h b/src/client/hardwareintegration/qwaylandserverbufferintegrationplugin_p.h index 8a074fb2..7eaaa170 100644 --- a/src/client/hardwareintegration/qwaylandserverbufferintegrationplugin_p.h +++ b/src/client/hardwareintegration/qwaylandserverbufferintegrationplugin_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/client/inputdeviceintegration/qwaylandinputdeviceintegration_p.h b/src/client/inputdeviceintegration/qwaylandinputdeviceintegration_p.h index 21d0c8bd..ada63b71 100644 --- a/src/client/inputdeviceintegration/qwaylandinputdeviceintegration_p.h +++ b/src/client/inputdeviceintegration/qwaylandinputdeviceintegration_p.h @@ -52,7 +52,7 @@ // #include <QtCore/qglobal.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <stdint.h> diff --git a/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory_p.h b/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory_p.h index 4431529f..d6d0e843 100644 --- a/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory_p.h +++ b/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtCore/QStringList> QT_BEGIN_NAMESPACE diff --git a/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationplugin_p.h b/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationplugin_p.h index cea178c4..c4a578d2 100644 --- a/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationplugin_p.h +++ b/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationplugin_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/client/qwaylandabstractdecoration_p.h b/src/client/qwaylandabstractdecoration_p.h index 6e4113ef..3220dab9 100644 --- a/src/client/qwaylandabstractdecoration_p.h +++ b/src/client/qwaylandabstractdecoration_p.h @@ -59,7 +59,7 @@ #include <QtGui/QColor> #include <QtGui/QStaticText> #include <QtGui/QImage> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <wayland-client.h> diff --git a/src/client/qwaylandbuffer_p.h b/src/client/qwaylandbuffer_p.h index 7dd920ac..8d651f82 100644 --- a/src/client/qwaylandbuffer_p.h +++ b/src/client/qwaylandbuffer_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtCore/QSize> #include <QtCore/QRect> diff --git a/src/client/qwaylandclientexport_p.h b/src/client/qwaylandclientexport.h index f49f1aee..f49f1aee 100644 --- a/src/client/qwaylandclientexport_p.h +++ b/src/client/qwaylandclientexport.h diff --git a/src/client/qwaylandclipboard_p.h b/src/client/qwaylandclipboard_p.h index 08d4baab..aa008eef 100644 --- a/src/client/qwaylandclipboard_p.h +++ b/src/client/qwaylandclipboard_p.h @@ -54,7 +54,7 @@ #include <qpa/qplatformclipboard.h> #include <QtCore/QVariant> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandcursor_p.h b/src/client/qwaylandcursor_p.h index a54841a2..4154ee19 100644 --- a/src/client/qwaylandcursor_p.h +++ b/src/client/qwaylandcursor_p.h @@ -53,7 +53,7 @@ #include <qpa/qplatformcursor.h> #include <QtCore/QMap> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> struct wl_cursor; struct wl_cursor_image; diff --git a/src/client/qwaylanddatadevicemanager_p.h b/src/client/qwaylanddatadevicemanager_p.h index 36060529..0c1d95d8 100644 --- a/src/client/qwaylanddatadevicemanager_p.h +++ b/src/client/qwaylanddatadevicemanager_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtWaylandClient/private/qwayland-wayland.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylanddataoffer_p.h b/src/client/qwaylanddataoffer_p.h index 534d79d7..5e635c1a 100644 --- a/src/client/qwaylanddataoffer_p.h +++ b/src/client/qwaylanddataoffer_p.h @@ -53,7 +53,7 @@ #include <QtGui/private/qdnd_p.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtWaylandClient/private/qwayland-wayland.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylanddatasource.cpp b/src/client/qwaylanddatasource.cpp index 32aab082..40beea31 100644 --- a/src/client/qwaylanddatasource.cpp +++ b/src/client/qwaylanddatasource.cpp @@ -41,7 +41,7 @@ #include "qwaylanddataoffer_p.h" #include "qwaylanddatadevicemanager_p.h" #include "qwaylandinputdevice_p.h" -#include "qwaylandmimehelper.h" +#include "qwaylandmimehelper_p.h" #include <QtCore/QFile> diff --git a/src/client/qwaylanddatasource_p.h b/src/client/qwaylanddatasource_p.h index ec3f0aac..c099ff62 100644 --- a/src/client/qwaylanddatasource_p.h +++ b/src/client/qwaylanddatasource_p.h @@ -54,7 +54,7 @@ #include <QObject> #include <QtWaylandClient/private/qwayland-wayland.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylanddecorationfactory_p.h b/src/client/qwaylanddecorationfactory_p.h index 4797f233..9d4e7a9f 100644 --- a/src/client/qwaylanddecorationfactory_p.h +++ b/src/client/qwaylanddecorationfactory_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtCore/QStringList> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylanddecorationplugin_p.h b/src/client/qwaylanddecorationplugin_p.h index c5baa83f..dd33f341 100644 --- a/src/client/qwaylanddecorationplugin_p.h +++ b/src/client/qwaylanddecorationplugin_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h index 618e57c5..59b00574 100644 --- a/src/client/qwaylanddisplay_p.h +++ b/src/client/qwaylanddisplay_p.h @@ -60,7 +60,7 @@ #include <wayland-client.h> #include <QtWaylandClient/private/qwayland-wayland.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtWaylandClient/private/qwayland-xdg-shell.h> #include <QtWaylandClient/private/qwaylandshm_p.h> diff --git a/src/client/qwaylanddnd_p.h b/src/client/qwaylanddnd_p.h index 29424375..2ff00b9f 100644 --- a/src/client/qwaylanddnd_p.h +++ b/src/client/qwaylanddnd_p.h @@ -57,7 +57,7 @@ #include <QtGui/QDrag> #include <QtCore/QMimeData> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandextendedsurface_p.h b/src/client/qwaylandextendedsurface_p.h index c004a9f7..39b85438 100644 --- a/src/client/qwaylandextendedsurface_p.h +++ b/src/client/qwaylandextendedsurface_p.h @@ -54,7 +54,7 @@ #include <QtCore/QString> #include <QtCore/QVariant> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <wayland-client.h> #include <QtWaylandClient/private/qwayland-surface-extension.h> diff --git a/src/client/qwaylandinputcontext.cpp b/src/client/qwaylandinputcontext.cpp index af8e6f81..509965d2 100644 --- a/src/client/qwaylandinputcontext.cpp +++ b/src/client/qwaylandinputcontext.cpp @@ -48,9 +48,9 @@ #include "qwaylanddisplay_p.h" #include "qwaylandinputdevice_p.h" -#include "qwaylandinputmethodeventbuilder.h" +#include "qwaylandinputmethodeventbuilder_p.h" #include "qwaylandwindow_p.h" -#include "qwaylandxkb.h" +#include "qwaylandxkb_p.h" QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandinputcontext_p.h b/src/client/qwaylandinputcontext_p.h index 8b789e34..53eab994 100644 --- a/src/client/qwaylandinputcontext_p.h +++ b/src/client/qwaylandinputcontext_p.h @@ -60,7 +60,7 @@ #include <QVector> #include <QtWaylandClient/private/qwayland-text-input-unstable-v2.h> -#include <qwaylandinputmethodeventbuilder.h> +#include <qwaylandinputmethodeventbuilder_p.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index cf1c7ac4..e85a8d98 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -49,7 +49,7 @@ #include "qwaylandcursor_p.h" #include "qwaylanddisplay_p.h" #include "qwaylandshmbackingstore_p.h" -#include "../shared/qwaylandxkb.h" +#include "../shared/qwaylandxkb_p.h" #include "qwaylandinputcontext_p.h" #include <QtGui/private/qpixmap_raster_p.h> diff --git a/src/client/qwaylandintegration_p.h b/src/client/qwaylandintegration_p.h index 630ac090..4ee6fac8 100644 --- a/src/client/qwaylandintegration_p.h +++ b/src/client/qwaylandintegration_p.h @@ -53,7 +53,7 @@ #include <qpa/qplatformintegration.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> QT_BEGIN_NAMESPACE namespace QtWaylandClient { diff --git a/src/client/qwaylandnativeinterface_p.h b/src/client/qwaylandnativeinterface_p.h index 71194da3..61c5e59d 100644 --- a/src/client/qwaylandnativeinterface_p.h +++ b/src/client/qwaylandnativeinterface_p.h @@ -54,7 +54,7 @@ #include <QVariantMap> #include <qpa/qplatformnativeinterface.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandqtkey_p.h b/src/client/qwaylandqtkey_p.h index c746dc92..b749bd5f 100644 --- a/src/client/qwaylandqtkey_p.h +++ b/src/client/qwaylandqtkey_p.h @@ -53,7 +53,7 @@ #include <qpa/qwindowsysteminterface.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtWaylandClient/private/qwayland-qtkey-extension.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandscreen_p.h b/src/client/qwaylandscreen_p.h index b4fa12e4..12b68064 100644 --- a/src/client/qwaylandscreen_p.h +++ b/src/client/qwaylandscreen_p.h @@ -52,7 +52,7 @@ // #include <qpa/qplatformscreen.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtWaylandClient/private/qwayland-wayland.h> diff --git a/src/client/qwaylandshellsurface_p.h b/src/client/qwaylandshellsurface_p.h index 053be3b5..63b77ab3 100644 --- a/src/client/qwaylandshellsurface_p.h +++ b/src/client/qwaylandshellsurface_p.h @@ -57,7 +57,7 @@ #include <wayland-client.h> #include <QtWaylandClient/private/qwayland-wayland.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandshm.cpp b/src/client/qwaylandshm.cpp index 13778967..790a0e1b 100644 --- a/src/client/qwaylandshm.cpp +++ b/src/client/qwaylandshm.cpp @@ -39,7 +39,7 @@ #include <QtWaylandClient/private/qwaylandshm_p.h> #include <QtWaylandClient/private/qwaylanddisplay_p.h> -#include "qwaylandshmformathelper.h" +#include "qwaylandshmformathelper_p.h" QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandshm_p.h b/src/client/qwaylandshm_p.h index 80d2b949..aafe4463 100644 --- a/src/client/qwaylandshm_p.h +++ b/src/client/qwaylandshm_p.h @@ -54,7 +54,7 @@ #include <QVector> #include <QImage> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtWaylandClient/private/qwayland-wayland.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandsubsurface.cpp b/src/client/qwaylandsubsurface.cpp index 40938053..36fdd1c7 100644 --- a/src/client/qwaylandsubsurface.cpp +++ b/src/client/qwaylandsubsurface.cpp @@ -60,6 +60,7 @@ QWaylandSubSurface::QWaylandSubSurface(QWaylandWindow *window, QWaylandWindow *p QWaylandSubSurface::~QWaylandSubSurface() { m_parent->mChildren.removeOne(this); + destroy(); } void QWaylandSubSurface::setSync() diff --git a/src/client/qwaylandsubsurface_p.h b/src/client/qwaylandsubsurface_p.h index b5f869bf..0abd168b 100644 --- a/src/client/qwaylandsubsurface_p.h +++ b/src/client/qwaylandsubsurface_p.h @@ -56,7 +56,7 @@ #include <QtCore/qglobal.h> #include <QtCore/qmutex.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtWaylandClient/private/qwayland-wayland.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandtouch_p.h b/src/client/qwaylandtouch_p.h index 8aa06d3e..dc32b84a 100644 --- a/src/client/qwaylandtouch_p.h +++ b/src/client/qwaylandtouch_p.h @@ -54,7 +54,7 @@ #include <qpa/qwindowsysteminterface.h> #include <QtWaylandClient/private/qwayland-touch-extension.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index da067dc9..51cf20a7 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -207,7 +207,7 @@ bool QWaylandWindow::shouldCreateShellSurface() const return false; if (qEnvironmentVariableIsSet("QT_WAYLAND_USE_BYPASSWINDOWMANAGERHINT")) - return window()->flags() & Qt::BypassWindowManagerHint; + return !(window()->flags() & Qt::BypassWindowManagerHint); return true; } diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index f36f0833..100c068f 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -59,7 +59,7 @@ #include <qpa/qplatformwindow.h> #include <QtWaylandClient/private/qwayland-wayland.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> struct wl_egl_window; diff --git a/src/client/qwaylandwindowmanagerintegration_p.h b/src/client/qwaylandwindowmanagerintegration_p.h index 344960d5..80513af3 100644 --- a/src/client/qwaylandwindowmanagerintegration_p.h +++ b/src/client/qwaylandwindowmanagerintegration_p.h @@ -58,7 +58,7 @@ #include <QtPlatformSupport/private/qgenericunixservices_p.h> #include <QtWaylandClient/private/qwayland-windowmanager.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandwlshellsurface_p.h b/src/client/qwaylandwlshellsurface_p.h index 1da64e9d..c319cd98 100644 --- a/src/client/qwaylandwlshellsurface_p.h +++ b/src/client/qwaylandwlshellsurface_p.h @@ -56,7 +56,7 @@ #include <wayland-client.h> #include <QtWaylandClient/private/qwayland-wayland.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include "qwaylandshellsurface_p.h" QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandxdgshell_p.h b/src/client/qwaylandxdgshell_p.h index 2b5a8eb8..bce8345d 100644 --- a/src/client/qwaylandxdgshell_p.h +++ b/src/client/qwaylandxdgshell_p.h @@ -56,7 +56,7 @@ #include <wayland-client.h> #include <QtWaylandClient/private/qwayland-xdg-shell.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include "qwaylandshellsurface_p.h" QT_BEGIN_NAMESPACE diff --git a/src/client/qwaylandxdgsurface_p.h b/src/client/qwaylandxdgsurface_p.h index 9d6c8c41..342dff75 100644 --- a/src/client/qwaylandxdgsurface_p.h +++ b/src/client/qwaylandxdgsurface_p.h @@ -57,7 +57,7 @@ #include <wayland-client.h> #include <QtWaylandClient/private/qwayland-xdg-shell.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include "qwaylandshellsurface_p.h" QT_BEGIN_NAMESPACE diff --git a/src/client/shellintegration/qwaylandshellintegration_p.h b/src/client/shellintegration/qwaylandshellintegration_p.h index 8395c868..e8e46eca 100644 --- a/src/client/shellintegration/qwaylandshellintegration_p.h +++ b/src/client/shellintegration/qwaylandshellintegration_p.h @@ -52,7 +52,7 @@ // #include <QtCore/qglobal.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> QT_BEGIN_NAMESPACE diff --git a/src/client/shellintegration/qwaylandshellintegrationfactory_p.h b/src/client/shellintegration/qwaylandshellintegrationfactory_p.h index 6e595b06..0783465a 100644 --- a/src/client/shellintegration/qwaylandshellintegrationfactory_p.h +++ b/src/client/shellintegration/qwaylandshellintegrationfactory_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtCore/QStringList> QT_BEGIN_NAMESPACE diff --git a/src/client/shellintegration/qwaylandshellintegrationplugin_p.h b/src/client/shellintegration/qwaylandshellintegrationplugin_p.h index 5566843b..be511bfc 100644 --- a/src/client/shellintegration/qwaylandshellintegrationplugin_p.h +++ b/src/client/shellintegration/qwaylandshellintegrationplugin_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtWaylandClient/private/qwaylandclientexport_p.h> +#include <QtWaylandClient/qwaylandclientexport.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/compositor/compositor.pro b/src/compositor/compositor.pro index e6050641..fe58df7e 100644 --- a/src/compositor/compositor.pro +++ b/src/compositor/compositor.pro @@ -20,8 +20,14 @@ QMAKE_DOCS = $$PWD/doc/qtwaylandcompositor.qdocconf } INCLUDEPATH += ../shared -HEADERS += ../shared/qwaylandmimehelper.h ../shared/qwaylandinputmethodeventbuilder.h -SOURCES += ../shared/qwaylandmimehelper.cpp ../shared/qwaylandinputmethodeventbuilder.cpp + +HEADERS += ../shared/qwaylandmimehelper_p.h \ + ../shared/qwaylandinputmethodeventbuilder_p.h \ + ../shared/qwaylandshmformathelper_p.h + +SOURCES += ../shared/qwaylandmimehelper.cpp \ + ../shared/qwaylandinputmethodeventbuilder.cpp + RESOURCES += compositor.qrc include ($$PWD/global/global.pri) diff --git a/src/compositor/compositor_api/qwaylandbufferref.cpp b/src/compositor/compositor_api/qwaylandbufferref.cpp index 929503b4..e9fbcfbd 100644 --- a/src/compositor/compositor_api/qwaylandbufferref.cpp +++ b/src/compositor/compositor_api/qwaylandbufferref.cpp @@ -241,6 +241,16 @@ QImage QWaylandBufferRef::image() const return d->buffer->image(); } +#ifdef QT_COMPOSITOR_WAYLAND_GL +GLuint QWaylandBufferRef::textureForPlane(int plane) const +{ + if (d->nullOrDestroyed()) + return 0; + + return d->buffer->textureForPlane(plane); +} +#endif + /*! * Binds the buffer to the current OpenGL texture. This may * perform a copy of the buffer data, depending on the platform diff --git a/src/compositor/compositor_api/qwaylandbufferref.h b/src/compositor/compositor_api/qwaylandbufferref.h index 4ded8f17..50c85b96 100644 --- a/src/compositor/compositor_api/qwaylandbufferref.h +++ b/src/compositor/compositor_api/qwaylandbufferref.h @@ -96,6 +96,9 @@ public: bool isShm() const; QImage image() const; +#ifdef QT_COMPOSITOR_WAYLAND_GL + GLuint textureForPlane(int plane) const; +#endif void bindToTexture() const; void updateTexture() const; diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index 696ee772..41de5b45 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -62,8 +62,8 @@ #include "extensions/qwaylandwindowmanagerextension.h" -#include "qwaylandxkb.h" -#include "qwaylandshmformathelper.h" +#include "qwaylandxkb_p.h" +#include "qwaylandshmformathelper_p.h" #include <QtCore/QCoreApplication> #include <QtCore/QStringList> diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h index c03bcc5d..9b445239 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.h +++ b/src/compositor/compositor_api/qwaylandcompositor.h @@ -38,7 +38,7 @@ #define QWAYLANDCOMPOSITOR_H #include <QtWaylandCompositor/qwaylandexport.h> -#include <QtWaylandCompositor/qwaylandextension.h> +#include <QtWaylandCompositor/qwaylandcompositorextension.h> #include <QtWaylandCompositor/QWaylandOutput> #include <QObject> diff --git a/src/compositor/compositor_api/qwaylandinput.h b/src/compositor/compositor_api/qwaylandinput.h index 7384e1e5..d1cb922b 100644 --- a/src/compositor/compositor_api/qwaylandinput.h +++ b/src/compositor/compositor_api/qwaylandinput.h @@ -42,7 +42,7 @@ #include <QtCore/QString> #include <QtWaylandCompositor/qwaylandexport.h> -#include <QtWaylandCompositor/qwaylandextension.h> +#include <QtWaylandCompositor/qwaylandcompositorextension.h> #include <QtWaylandCompositor/qwaylandkeyboard.h> QT_BEGIN_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandkeyboard.h b/src/compositor/compositor_api/qwaylandkeyboard.h index e327cd3d..cee32f4e 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.h +++ b/src/compositor/compositor_api/qwaylandkeyboard.h @@ -40,7 +40,7 @@ #include <QtCore/QObject> -#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtWaylandCompositor/QWaylandSurface> QT_BEGIN_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandoutput.h b/src/compositor/compositor_api/qwaylandoutput.h index 46c5ff97..e4cbb610 100644 --- a/src/compositor/compositor_api/qwaylandoutput.h +++ b/src/compositor/compositor_api/qwaylandoutput.h @@ -38,7 +38,7 @@ #ifndef QWAYLANDOUTPUT_H #define QWAYLANDOUTPUT_H -#include <QtWaylandCompositor/qwaylandextension.h> +#include <QtWaylandCompositor/qwaylandcompositorextension.h> #include <QtCore/QObject> #include <QObject> diff --git a/src/compositor/compositor_api/qwaylandpointer.h b/src/compositor/compositor_api/qwaylandpointer.h index 6aa31bd5..2032b9a2 100644 --- a/src/compositor/compositor_api/qwaylandpointer.h +++ b/src/compositor/compositor_api/qwaylandpointer.h @@ -37,7 +37,7 @@ #ifndef QWAYLANDPOINTER_H #define QWAYLANDPOINTER_H -#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandCompositorExtension> QT_BEGIN_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index 9fa81cfb..ab11ff4f 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -179,17 +179,6 @@ QWaylandBufferMaterial::QWaylandBufferMaterial(QWaylandBufferRef::BufferFormatEg { QOpenGLFunctions *gl = QOpenGLContext::currentContext()->functions(); - for (int i = 0; i < bufferTypes[m_format].planeCount; i++) { - GLuint texture; - gl->glGenTextures(1, &texture); - gl->glBindTexture(bufferTypes[m_format].textureTarget, texture); - gl->glTexParameteri(bufferTypes[m_format].textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - gl->glTexParameteri(bufferTypes[m_format].textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - gl->glTexParameteri(bufferTypes[m_format].textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - gl->glTexParameteri(bufferTypes[m_format].textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - m_textures << texture; - } - gl->glBindTexture(bufferTypes[m_format].textureTarget, 0); setFlag(bufferTypes[m_format].materialFlags); } @@ -202,11 +191,36 @@ QWaylandBufferMaterial::~QWaylandBufferMaterial() gl->glDeleteTextures(1, &texture); } +void QWaylandBufferMaterial::setTextureForPlane(int plane, uint texture) +{ + if (plane < 0 || plane >= bufferTypes[m_format].planeCount) { + qWarning("plane index is out of range"); + return; + } + + QOpenGLFunctions *gl = QOpenGLContext::currentContext()->functions(); + const GLenum target = bufferTypes[m_format].textureTarget; + + gl->glBindTexture(target, texture); + setTextureParameters(target); + + ensureTextures(plane - 1); + + if (m_textures.size() <= plane) { + m_textures << texture; + } else { + std::swap(m_textures[plane], texture); + gl->glDeleteTextures(1, &texture); + } +} + void QWaylandBufferMaterial::bind() { QOpenGLFunctions *gl = QOpenGLContext::currentContext()->functions(); const GLenum target = bufferTypes[m_format].textureTarget; + ensureTextures(bufferTypes[m_format].planeCount); + switch (m_textures.size()) { case 3: gl->glActiveTexture(GL_TEXTURE2); @@ -230,6 +244,31 @@ QSGMaterialShader *QWaylandBufferMaterial::createShader() const return new QWaylandBufferMaterialShader(m_format); } + +void QWaylandBufferMaterial::setTextureParameters(GLenum target) +{ + QOpenGLFunctions *gl = QOpenGLContext::currentContext()->functions(); + gl->glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + gl->glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + gl->glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl->glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); +} + +//TODO move this into a separate centralized texture management class +void QWaylandBufferMaterial::ensureTextures(int count) +{ + QOpenGLFunctions *gl = QOpenGLContext::currentContext()->functions(); + const GLenum target = bufferTypes[m_format].textureTarget; + GLuint texture; + + for (int plane = m_textures.size(); plane < count; plane++) { + gl->glGenTextures(1, &texture); + gl->glBindTexture(target, texture); + setTextureParameters(target); + m_textures << texture; + } +} + QMutex *QWaylandQuickItemPrivate::mutex = 0; class QWaylandSurfaceTextureProvider : public QSGTextureProvider @@ -1047,6 +1086,9 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat if (d->newTexture) { d->newTexture = false; + for (int plane = 0; plane < bufferTypes[ref.bufferFormatEgl()].planeCount; plane++) + if (uint texture = ref.textureForPlane(plane)) + material->setTextureForPlane(plane, texture); material->bind(); ref.bindToTexture(); } diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h index 679d218e..b529ba95 100644 --- a/src/compositor/compositor_api/qwaylandquickitem_p.h +++ b/src/compositor/compositor_api/qwaylandquickitem_p.h @@ -85,12 +85,17 @@ public: QWaylandBufferMaterial(QWaylandBufferRef::BufferFormatEgl format); ~QWaylandBufferMaterial(); + void setTextureForPlane(int plane, uint texture); + void bind(); QSGMaterialType *type() const Q_DECL_OVERRIDE; QSGMaterialShader *createShader() const Q_DECL_OVERRIDE; private: + void setTextureParameters(GLenum target); + void ensureTextures(int count); + const QWaylandBufferRef::BufferFormatEgl m_format; QVarLengthArray<GLuint, 3> m_textures; }; diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h index 4abe9e74..816b5c98 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -39,7 +39,7 @@ #define QWAYLANDSURFACE_H #include <QtWaylandCompositor/qwaylandexport.h> -#include <QtWaylandCompositor/qwaylandextension.h> +#include <QtWaylandCompositor/qwaylandcompositorextension.h> #include <QtWaylandCompositor/qwaylandclient.h> #include <QtCore/QScopedPointer> diff --git a/src/compositor/compositor_api/qwaylandtouch.h b/src/compositor/compositor_api/qwaylandtouch.h index 9c235e4c..b93b6d21 100644 --- a/src/compositor/compositor_api/qwaylandtouch.h +++ b/src/compositor/compositor_api/qwaylandtouch.h @@ -37,7 +37,7 @@ #ifndef QWAYLANDTOUCH_H #define QWAYLANDTOUCH_H -#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtCore/QObject> #include <QtGui/QTouchEvent> diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri index 71716243..4ab26727 100644 --- a/src/compositor/extensions/extensions.pri +++ b/src/compositor/extensions/extensions.pri @@ -21,6 +21,7 @@ HEADERS += \ extensions/qwaylandwindowmanagerextension_p.h \ extensions/qwaylandxdgshell.h \ extensions/qwaylandxdgshell_p.h \ + extensions/qwaylandshellsurface.h \ SOURCES += \ extensions/qwlextendedsurface.cpp \ @@ -34,14 +35,15 @@ SOURCES += \ qtHaveModule(quick) { HEADERS += \ - extensions/qwaylandquickwlshellsurfaceitem.h \ - extensions/qwaylandquickwlshellsurfaceitem_p.h \ - extensions/qwaylandquickxdgsurfaceitem.h \ - extensions/qwaylandquickxdgsurfaceitem_p.h \ + extensions/qwaylandquickshellsurfaceitem.h \ + extensions/qwaylandquickshellsurfaceitem_p.h \ + extensions/qwaylandwlshellintegration_p.h \ + extensions/qwaylandxdgshellintegration_p.h \ SOURCES += \ - extensions/qwaylandquickwlshellsurfaceitem.cpp \ - extensions/qwaylandquickxdgsurfaceitem.cpp \ + extensions/qwaylandquickshellsurfaceitem.cpp \ + extensions/qwaylandwlshellintegration.cpp \ + extensions/qwaylandxdgshellintegration.cpp \ } diff --git a/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp new file mode 100644 index 00000000..4b087183 --- /dev/null +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandquickshellsurfaceitem.h" +#include "qwaylandquickshellsurfaceitem_p.h" + +#include <QtWaylandCompositor/QWaylandShellSurface> + +QT_BEGIN_NAMESPACE + +/*! + * \qmltype ShellSurfaceItem + * \inqmlmodule QtWayland.Compositor + * \preliminary + * \brief An item representing a WlShellSurface. + * + * This type is used to render wl_shell or xdg_shell surfaces as part of a Qt Quick + * scene. It handles moving and resizing triggered by clicking on the window decorations. + */ + +/*! + * \class QWaylandQuickShellSurfaceItem + * \inmodule QtWaylandCompositor + * \preliminary + * \brief A Qt Quick item for QWaylandShellSurface. + * + * This class is used to render wl_shell or xdg_shell surfaces as part of a Qt Quick + * scene. It handles moving and resizing triggered by clicking on the window decorations. + * + * \sa QWaylandQuickItem + */ + +/*! + * Constructs a QWaylandQuickWlShellSurfaceItem with the given \a parent. + */ +QWaylandQuickShellSurfaceItem::QWaylandQuickShellSurfaceItem(QQuickItem *parent) + : QWaylandQuickItem(*new QWaylandQuickShellSurfaceItemPrivate(), parent) +{ +} + +/*! + * \internal + */ +QWaylandQuickShellSurfaceItem::QWaylandQuickShellSurfaceItem(QWaylandQuickShellSurfaceItemPrivate &dd, QQuickItem *parent) + : QWaylandQuickItem(dd, parent) +{ +} + +/*! + * \qmlproperty object QtWaylandCompositor::ShellSurfaceItem::shellSurface + * + * This property holds the shell surface rendered by this ShellSurfaceItem. + * It may either be an XdgSurface or a WlShellSurface depending on which + * shell protocol is in use. + */ + +/*! + * \property QWaylandQuickShellSurfaceItem::shellSurface + * + * This property holds the shell surface rendered by this + * QWaylandQuickShellSurfaceItem. It may either be a QWaylandXdgSurface or a + * QWaylandWlShellSurface depending on which shell protocol is in use. + * + */ +QWaylandShellSurface *QWaylandQuickShellSurfaceItem::shellSurface() const +{ + Q_D(const QWaylandQuickShellSurfaceItem); + return d->m_shellSurface; +} + +void QWaylandQuickShellSurfaceItem::setShellSurface(QWaylandShellSurface *shellSurface) +{ + Q_D(QWaylandQuickShellSurfaceItem); + if (d->m_shellSurface == shellSurface) + return; + + d->m_shellSurface = shellSurface; + + d->m_shellIntegration = shellSurface->createIntegration(this); + emit shellSurfaceChanged(); +} + +/*! + * \property QWaylandQuickShellSurfaceItem::moveItem + * + * This property holds the move item for this QWaylandQuickShellSurfaceItem. + */ +QQuickItem *QWaylandQuickShellSurfaceItem::moveItem() const +{ + Q_D(const QWaylandQuickShellSurfaceItem); + return d->m_moveItem ? d->m_moveItem : const_cast<QWaylandQuickShellSurfaceItem *>(this); +} + +void QWaylandQuickShellSurfaceItem::setMoveItem(QQuickItem *moveItem) +{ + Q_D(QWaylandQuickShellSurfaceItem); + moveItem = moveItem ? moveItem : this; + if (this->moveItem() == moveItem) + return; + d->m_moveItem = moveItem; + moveItemChanged(); +} + +void QWaylandQuickShellSurfaceItem::mouseMoveEvent(QMouseEvent *event) +{ + Q_D(QWaylandQuickShellSurfaceItem); + if (!d->m_shellIntegration->mouseMoveEvent(event)) + QWaylandQuickItem::mouseMoveEvent(event); +} + +void QWaylandQuickShellSurfaceItem::mouseReleaseEvent(QMouseEvent *event) +{ + Q_D(QWaylandQuickShellSurfaceItem); + if (!d->m_shellIntegration->mouseReleaseEvent(event)) + QWaylandQuickItem::mouseReleaseEvent(event); +} + +QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandquickxdgsurfaceitem.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h index d19d03c2..e233c99e 100644 --- a/src/compositor/extensions/qwaylandquickxdgsurfaceitem.h +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem.h @@ -34,54 +34,43 @@ ** ****************************************************************************/ -#ifndef QWAYLANDQUICKXDGSURFACEITEM_H -#define QWAYLANDQUICKXDGSURFACEITEM_H +#ifndef QWAYLANDQUICKSHELLSURFACEITEM_H +#define QWAYLANDQUICKSHELLSURFACEITEM_H +#include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtWaylandCompositor/QWaylandQuickItem> -#include <QtWaylandCompositor/QWaylandXdgSurface> QT_BEGIN_NAMESPACE -class QWaylandQuickXdgSurfaceItemPrivate; +class QWaylandQuickShellSurfaceItemPrivate; +class QWaylandShellSurface; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickXdgSurfaceItem : public QWaylandQuickItem +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellSurfaceItem : public QWaylandQuickItem { Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandQuickXdgSurfaceItem) - Q_PROPERTY(QWaylandXdgSurface *xdgSurface READ xdgSurface WRITE setXdgSurface NOTIFY xdgSurfaceChanged) + Q_DECLARE_PRIVATE(QWaylandQuickShellSurfaceItem) + Q_PROPERTY(QWaylandShellSurface *shellSurface READ shellSurface WRITE setShellSurface NOTIFY shellSurfaceChanged) Q_PROPERTY(QQuickItem *moveItem READ moveItem WRITE setMoveItem NOTIFY moveItemChanged) + QWaylandQuickShellSurfaceItem(QWaylandQuickShellSurfaceItemPrivate &dd, QQuickItem *parent); public: - QWaylandQuickXdgSurfaceItem(QQuickItem *parent = nullptr); + QWaylandQuickShellSurfaceItem(QQuickItem *parent = nullptr); - QWaylandXdgSurface *xdgSurface() const; - void setXdgSurface(QWaylandXdgSurface *xdgSurface); + QWaylandShellSurface *shellSurface() const; + void setShellSurface(QWaylandShellSurface *shellSurface); QQuickItem *moveItem() const; void setMoveItem(QQuickItem *moveItem); Q_SIGNALS: - void xdgSurfaceChanged(); + void shellSurfaceChanged(); void moveItemChanged(); -private Q_SLOTS: - void handleStartMove(QWaylandInputDevice *inputDevice); - void handleStartResize(QWaylandInputDevice *inputDevice, QWaylandXdgSurface::ResizeEdge edges); - void handleSetMaximized(); - void handleUnsetMaximized(); - void handleMaximizedChanged(); - void handleActivatedChanged(); - void handleSurfaceSizeChanged(); - protected: - QWaylandQuickXdgSurfaceItem(QWaylandQuickXdgSurfaceItemPrivate &dd, QQuickItem *parent); - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - - void surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface) Q_DECL_OVERRIDE; }; QT_END_NAMESPACE -#endif /*QWAYLANDQUICKXDGSURFACEITEM_H*/ +#endif // QWAYLANDQUICKSHELLSURFACEITEM_H diff --git a/src/compositor/extensions/qwaylandquickwlshellsurfaceitem_p.h b/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h index 3e683477..34771037 100644 --- a/src/compositor/extensions/qwaylandquickwlshellsurfaceitem_p.h +++ b/src/compositor/extensions/qwaylandquickshellsurfaceitem_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtWaylandCompositor module of the Qt Toolkit. @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#ifndef QWAYLANDQUICKWLSHELLSURFACEITEM_P_H -#define QWAYLANDQUICKWLSHELLSURFACEITEM_P_H +#ifndef QWAYLANDQUICKSHELLSURFACEITEM_P_H +#define QWAYLANDQUICKSHELLSURFACEITEM_P_H #include <QtWaylandCompositor/private/qwaylandquickitem_p.h> @@ -52,41 +52,30 @@ QT_BEGIN_NAMESPACE // We mean it. // -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickWlShellSurfaceItemPrivate : public QWaylandQuickItemPrivate +class QWaylandQuickShellIntegration; +class QWaylandShellSurface; + +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickShellSurfaceItemPrivate : public QWaylandQuickItemPrivate { public: - enum GrabberState { - DefaultState, - ResizeState, - MoveState - }; - - QWaylandQuickWlShellSurfaceItemPrivate() + QWaylandQuickShellSurfaceItemPrivate() : QWaylandQuickItemPrivate() - , shellSurface(Q_NULLPTR) - , moveItem(Q_NULLPTR) - , grabberState(DefaultState) + , m_shellIntegration(nullptr) + , m_shellSurface(nullptr) + , m_moveItem(nullptr) {} - - QWaylandWlShellSurface *shellSurface; - QQuickItem *moveItem; - - GrabberState grabberState; - struct { - QWaylandInputDevice *inputDevice; - QPointF initialOffset; - bool initialized; - } moveState; - - struct { - QWaylandInputDevice *inputDevice; - QWaylandWlShellSurface::ResizeEdge resizeEdges; - QSizeF initialSize; - QPointF initialMousePos; - bool initialized; - } resizeState; + QWaylandQuickShellIntegration *m_shellIntegration; + QWaylandShellSurface *m_shellSurface; + QQuickItem *m_moveItem; }; -QT_END_NAMESPACE +class QWaylandQuickShellIntegration : public QObject +{ + Q_OBJECT +public: + QWaylandQuickShellIntegration(QObject *parent = nullptr) : QObject(parent) {} + virtual bool mouseMoveEvent(QMouseEvent *) { return false; } + virtual bool mouseReleaseEvent(QMouseEvent *) { return false; } +}; -#endif /*QWAYLANDQUICKWLSHELLSURFACEITEM_P_H*/ +#endif // QWAYLANDQUICKSHELLSURFACEITEM_P_H diff --git a/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.cpp deleted file mode 100644 index 21b5c75a..00000000 --- a/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later 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 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandquickwlshellsurfaceitem.h" -#include "qwaylandquickwlshellsurfaceitem_p.h" - -#include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandInputDevice> - -QT_BEGIN_NAMESPACE - -/*! - * \qmltype WlShellSurfaceItem - * \inqmlmodule QtWayland.Compositor - * \preliminary - * \preliminary - * \brief An item representing a WlShellSurface. - * - * This type can be used to render wl_shell_surfaces as part of a Qt Quick scene. - * It handles moving and resizing triggered by clicking on the window decorations. - */ - -/*! - * \class QWaylandQuickWlShellSurfaceItem - * \inmodule QtWaylandCompositor - * \preliminary - * \preliminary - * \brief A Qt Quick item for QWaylandWlShellSurface. - * - * This class can be used to create Qt Quick items representing wl_shell_surfaces. - * It handles moving and resizing triggered by clicking on the window decorations. - * - * \sa QWaylandQuickItem - */ - -/*! - * Constructs a QWaylandQuickWlShellSurfaceItem with the given \a parent. - */ -QWaylandQuickWlShellSurfaceItem::QWaylandQuickWlShellSurfaceItem(QQuickItem *parent) - : QWaylandQuickItem(*new QWaylandQuickWlShellSurfaceItemPrivate(), parent) -{ -} - -/*! - * \internal - */ -QWaylandQuickWlShellSurfaceItem::QWaylandQuickWlShellSurfaceItem(QWaylandQuickWlShellSurfaceItemPrivate &dd, QQuickItem *parent) - : QWaylandQuickItem(dd, parent) -{ -} - -/*! - * \qmlproperty object QtWaylandCompositor::WlShellSurfaceItem::shellSurface - * - * This property holds the wl_shell_surface rendered by this WlShellSurfaceItem. - */ - -/*! - * \property QWaylandQuickWlShellSurfaceItem::shellSurface - * - * This property holds the wl_shell_surface rendered by this QWaylandQuickWlShellSurfaceItem. - */ -QWaylandWlShellSurface *QWaylandQuickWlShellSurfaceItem::shellSurface() const -{ - Q_D(const QWaylandQuickWlShellSurfaceItem); - return d->shellSurface; -} - -void QWaylandQuickWlShellSurfaceItem::setShellSurface(QWaylandWlShellSurface *shellSurface) -{ - Q_D(QWaylandQuickWlShellSurfaceItem); - if (shellSurface == d->shellSurface) - return; - - if (d->shellSurface) { - disconnect(d->shellSurface, &QWaylandWlShellSurface::startMove, this, &QWaylandQuickWlShellSurfaceItem::handleStartMove); - disconnect(d->shellSurface, &QWaylandWlShellSurface::startResize, this, &QWaylandQuickWlShellSurfaceItem::handleStartResize); - } - d->shellSurface = shellSurface; - if (d->shellSurface) { - connect(d->shellSurface, &QWaylandWlShellSurface::startMove, this, &QWaylandQuickWlShellSurfaceItem::handleStartMove); - connect(d->shellSurface, &QWaylandWlShellSurface::startResize, this, &QWaylandQuickWlShellSurfaceItem::handleStartResize); - } - setSurface(shellSurface ? shellSurface->surface() : nullptr); - emit shellSurfaceChanged(); -} - -/*! - * \internal - * \property QWaylandQuickWlShellSurfaceItem::moveItem - * - * This property holds the move item for this QWaylandQuickWlShellSurfaceItem. - */ -QQuickItem *QWaylandQuickWlShellSurfaceItem::moveItem() const -{ - Q_D(const QWaylandQuickWlShellSurfaceItem); - return d->moveItem; -} - -void QWaylandQuickWlShellSurfaceItem::setMoveItem(QQuickItem *moveItem) -{ - Q_D(QWaylandQuickWlShellSurfaceItem); - if (d->moveItem == moveItem) - return; - d->moveItem = moveItem; - moveItemChanged(); -} - -/*! - * \internal - */ -void QWaylandQuickWlShellSurfaceItem::handleStartMove(QWaylandInputDevice *inputDevice) -{ - Q_D(QWaylandQuickWlShellSurfaceItem); - d->grabberState = QWaylandQuickWlShellSurfaceItemPrivate::MoveState; - d->moveState.inputDevice = inputDevice; - d->moveState.initialized = false; -} - -/*! - * \internal - */ -void QWaylandQuickWlShellSurfaceItem::handleStartResize(QWaylandInputDevice *inputDevice, QWaylandWlShellSurface::ResizeEdge edges) -{ - Q_D(QWaylandQuickWlShellSurfaceItem); - d->grabberState = QWaylandQuickWlShellSurfaceItemPrivate::ResizeState; - d->resizeState.inputDevice = inputDevice; - d->resizeState.resizeEdges = edges; - d->resizeState.initialSize = surface()->size() / d->scaleFactor(); - d->resizeState.initialized = false; -} - -/*! - * \internal - */ -void QWaylandQuickWlShellSurfaceItem::adjustOffsetForNextFrame(const QPointF &offset) -{ - Q_D(QWaylandQuickWlShellSurfaceItem); - QQuickItem *moveItem = d->moveItem ? d->moveItem : this; - moveItem->setPosition(moveItem->position() + offset * d->scaleFactor()); -} - -/*! - * \internal - */ -void QWaylandQuickWlShellSurfaceItem::mouseMoveEvent(QMouseEvent *event) -{ - Q_D(QWaylandQuickWlShellSurfaceItem); - if (d->grabberState == QWaylandQuickWlShellSurfaceItemPrivate::ResizeState) { - Q_ASSERT(d->resizeState.inputDevice == compositor()->inputDeviceFor(event)); - if (!d->resizeState.initialized) { - d->resizeState.initialMousePos = event->windowPos(); - d->resizeState.initialized = true; - return; - } - QPointF delta = (event->windowPos() - d->resizeState.initialMousePos) / d->scaleFactor(); - QSize newSize = shellSurface()->sizeForResize(d->resizeState.initialSize, delta, d->resizeState.resizeEdges); - shellSurface()->sendConfigure(newSize, d->resizeState.resizeEdges); - } else if (d->grabberState == QWaylandQuickWlShellSurfaceItemPrivate::MoveState) { - Q_ASSERT(d->moveState.inputDevice == compositor()->inputDeviceFor(event)); - QQuickItem *moveItem = d->moveItem ? d->moveItem : this; - if (!d->moveState.initialized) { - d->moveState.initialOffset = moveItem->mapFromItem(Q_NULLPTR, event->windowPos()); - d->moveState.initialized = true; - return; - } - if (!moveItem->parentItem()) - return; - QPointF parentPos = moveItem->parentItem()->mapFromItem(Q_NULLPTR, event->windowPos()); - moveItem->setPosition(parentPos - d->moveState.initialOffset); - } else { - QWaylandQuickItem::mouseMoveEvent(event); - } -} - -/*! - * \internal - */ -void QWaylandQuickWlShellSurfaceItem::mouseReleaseEvent(QMouseEvent *event) -{ - Q_D(QWaylandQuickWlShellSurfaceItem); - if (d->grabberState != QWaylandQuickWlShellSurfaceItemPrivate::DefaultState) { - d->grabberState = QWaylandQuickWlShellSurfaceItemPrivate::DefaultState; - return; - } - QWaylandQuickItem::mouseReleaseEvent(event); -} - -/*! - * \internal - */ -void QWaylandQuickWlShellSurfaceItem::surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface) -{ - if (oldSurface) - disconnect(oldSurface, &QWaylandSurface::offsetForNextFrame, this, &QWaylandQuickWlShellSurfaceItem::adjustOffsetForNextFrame); - - if (newSurface) - connect(newSurface, &QWaylandSurface::offsetForNextFrame, this, &QWaylandQuickWlShellSurfaceItem::adjustOffsetForNextFrame); -} - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandquickxdgsurfaceitem.cpp b/src/compositor/extensions/qwaylandquickxdgsurfaceitem.cpp deleted file mode 100644 index e5d4cdbc..00000000 --- a/src/compositor/extensions/qwaylandquickxdgsurfaceitem.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later 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 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandquickxdgsurfaceitem.h" -#include "qwaylandquickxdgsurfaceitem_p.h" - -#include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandInputDevice> - -QT_BEGIN_NAMESPACE - -/*! - * \qmltype XdgSurfaceItem - * \inqmlmodule QtWayland.Compositor - * \preliminary - * \brief An item representing a XdgSurface. - * - * This type can be used to render xdg surfaces as part of a Qt Quick scene. - * It handles moving and resizing triggered by clicking on the window decorations. - */ - -/*! - * \class QWaylandQuickXdgSurfaceItem - * \inmodule QtWaylandCompositor - * \preliminary - * \brief A Qt Quick item for QWaylandXdgSurface. - * - * This class can be used to create Qt Quick items representing xdg surfaces. - * It handles moving and resizing triggered by clicking on the window decorations. - * - * \sa QWaylandQuickItem - */ - -/*! - * Constructs a QWaylandQuickXdgSurfaceItem with the given \a parent. - */ -QWaylandQuickXdgSurfaceItem::QWaylandQuickXdgSurfaceItem(QQuickItem *parent) - : QWaylandQuickItem(*new QWaylandQuickXdgSurfaceItemPrivate(), parent) -{ -} - -/*! - * \internal - */ -QWaylandQuickXdgSurfaceItem::QWaylandQuickXdgSurfaceItem(QWaylandQuickXdgSurfaceItemPrivate &dd, QQuickItem *parent) - : QWaylandQuickItem(dd, parent) -{ -} - -/*! - * \qmlproperty object QtWaylandCompositor::XdgSurfaceItem::xdgSurface - * - * This property holds the xdg surface rendered by this XdgSurfaceItem. - */ - -/*! - * \property QWaylandQuickXdgSurfaceItem::xdgSurface - * - * This property holds the xdg surface rendered by this QWaylandQuickXdgSurfaceItem. - */ -QWaylandXdgSurface *QWaylandQuickXdgSurfaceItem::xdgSurface() const -{ - Q_D(const QWaylandQuickXdgSurfaceItem); - return d->xdgSurface; -} - -void QWaylandQuickXdgSurfaceItem::setXdgSurface(QWaylandXdgSurface *xdgSurface) -{ - Q_D(QWaylandQuickXdgSurfaceItem); - if (xdgSurface == d->xdgSurface) - return; - - if (d->xdgSurface) { - disconnect(d->xdgSurface, &QWaylandXdgSurface::startMove, this, &QWaylandQuickXdgSurfaceItem::handleStartMove); - disconnect(d->xdgSurface, &QWaylandXdgSurface::startResize, this, &QWaylandQuickXdgSurfaceItem::handleStartResize); - disconnect(d->xdgSurface, &QWaylandXdgSurface::setMaximized, this, &QWaylandQuickXdgSurfaceItem::handleSetMaximized); - disconnect(d->xdgSurface, &QWaylandXdgSurface::unsetMaximized, this, &QWaylandQuickXdgSurfaceItem::handleUnsetMaximized); - disconnect(d->xdgSurface, &QWaylandXdgSurface::maximizedChanged, this, &QWaylandQuickXdgSurfaceItem::handleMaximizedChanged); - disconnect(d->xdgSurface, &QWaylandXdgSurface::activatedChanged, this, &QWaylandQuickXdgSurfaceItem::handleActivatedChanged); - } - d->xdgSurface = xdgSurface; - if (d->xdgSurface) { - connect(d->xdgSurface, &QWaylandXdgSurface::startMove, this, &QWaylandQuickXdgSurfaceItem::handleStartMove); - connect(d->xdgSurface, &QWaylandXdgSurface::startResize, this, &QWaylandQuickXdgSurfaceItem::handleStartResize); - connect(d->xdgSurface, &QWaylandXdgSurface::setMaximized, this, &QWaylandQuickXdgSurfaceItem::handleSetMaximized); - connect(d->xdgSurface, &QWaylandXdgSurface::unsetMaximized, this, &QWaylandQuickXdgSurfaceItem::handleUnsetMaximized); - connect(d->xdgSurface, &QWaylandXdgSurface::maximizedChanged, this, &QWaylandQuickXdgSurfaceItem::handleMaximizedChanged); - connect(d->xdgSurface, &QWaylandXdgSurface::activatedChanged, this, &QWaylandQuickXdgSurfaceItem::handleActivatedChanged); - } - setSurface(xdgSurface ? xdgSurface->surface() : nullptr); - emit xdgSurfaceChanged(); -} - -/*! - * \internal - * \property QWaylandQuickXdgSurfaceItem::moveItem - * - * This property holds the move item for this QWaylandQuickXdgSurfaceItem. - */ -QQuickItem *QWaylandQuickXdgSurfaceItem::moveItem() const -{ - Q_D(const QWaylandQuickXdgSurfaceItem); - return d->moveItem; -} - -void QWaylandQuickXdgSurfaceItem::setMoveItem(QQuickItem *moveItem) -{ - Q_D(QWaylandQuickXdgSurfaceItem); - if (d->moveItem == moveItem) - return; - d->moveItem = moveItem; - moveItemChanged(); -} - -/*! - * \internal - */ -void QWaylandQuickXdgSurfaceItem::handleStartMove(QWaylandInputDevice *inputDevice) -{ - Q_D(QWaylandQuickXdgSurfaceItem); - d->grabberState = QWaylandQuickXdgSurfaceItemPrivate::MoveState; - d->moveState.inputDevice = inputDevice; - d->moveState.initialized = false; -} - -/*! - * \internal - */ -void QWaylandQuickXdgSurfaceItem::handleStartResize(QWaylandInputDevice *inputDevice, QWaylandXdgSurface::ResizeEdge edges) -{ - Q_D(QWaylandQuickXdgSurfaceItem); - d->grabberState = QWaylandQuickXdgSurfaceItemPrivate::ResizeState; - d->resizeState.inputDevice = inputDevice; - d->resizeState.resizeEdges = edges; - d->resizeState.initialWindowSize = xdgSurface()->windowGeometry().size(); - d->resizeState.initialPosition = position(); - d->resizeState.initialSurfaceSize = surface()->size(); - d->resizeState.initialized = false; -} - -void QWaylandQuickXdgSurfaceItem::handleSetMaximized() -{ - Q_D(QWaylandQuickXdgSurfaceItem); - - d->maximizeState.initialWindowSize = xdgSurface()->windowGeometry().size(); - d->maximizeState.initialPosition = position(); - - QWaylandOutput *output = compositor()->outputs().first(); - xdgSurface()->requestMaximized(output->geometry().size() / output->scaleFactor()); -} - -void QWaylandQuickXdgSurfaceItem::handleUnsetMaximized() -{ - Q_D(QWaylandQuickXdgSurfaceItem); - xdgSurface()->requestUnMaximized(d->maximizeState.initialWindowSize); -} - -void QWaylandQuickXdgSurfaceItem::handleMaximizedChanged() -{ - Q_D(QWaylandQuickXdgSurfaceItem); - if (xdgSurface()->maximized()) { - QWaylandOutput *output = compositor()->outputs().first(); - setPosition(output->geometry().topLeft()); - } else { - setPosition(d->maximizeState.initialPosition); - } -} - -void QWaylandQuickXdgSurfaceItem::handleActivatedChanged() -{ - if (xdgSurface()->activated()) - raise(); -} - -void QWaylandQuickXdgSurfaceItem::handleSurfaceSizeChanged() -{ - Q_D(QWaylandQuickXdgSurfaceItem); - if (d->grabberState == QWaylandQuickXdgSurfaceItemPrivate::ResizeState) { - float x = d->resizeState.initialPosition.x(); - float y = d->resizeState.initialPosition.y(); - if (d->resizeState.resizeEdges & QWaylandXdgSurface::ResizeEdge::TopEdge) - y += d->resizeState.initialSurfaceSize.height() - surface()->size().height(); - - if (d->resizeState.resizeEdges & QWaylandXdgSurface::ResizeEdge::LeftEdge) - x += d->resizeState.initialSurfaceSize.width() - surface()->size().width(); - setPosition(QPoint(x,y)); - } -} - -/*! - * \internal - */ -void QWaylandQuickXdgSurfaceItem::mouseMoveEvent(QMouseEvent *event) -{ - Q_D(QWaylandQuickXdgSurfaceItem); - if (d->grabberState == QWaylandQuickXdgSurfaceItemPrivate::ResizeState) { - Q_ASSERT(d->resizeState.inputDevice == compositor()->inputDeviceFor(event)); - if (!d->resizeState.initialized) { - d->resizeState.initialMousePos = event->windowPos(); - d->resizeState.initialized = true; - return; - } - QPointF delta = (event->windowPos() - d->resizeState.initialMousePos) / d->scaleFactor(); - QSize newSize = xdgSurface()->sizeForResize(d->resizeState.initialWindowSize, delta, d->resizeState.resizeEdges); - xdgSurface()->requestResizing(newSize); - } else if (d->grabberState == QWaylandQuickXdgSurfaceItemPrivate::MoveState) { - Q_ASSERT(d->moveState.inputDevice == compositor()->inputDeviceFor(event)); - QQuickItem *moveItem = d->moveItem ? d->moveItem : this; - if (!d->moveState.initialized) { - d->moveState.initialOffset = moveItem->mapFromItem(Q_NULLPTR, event->windowPos()); - d->moveState.initialized = true; - return; - } - if (!moveItem->parentItem()) - return; - QPointF parentPos = moveItem->parentItem()->mapFromItem(Q_NULLPTR, event->windowPos()); - moveItem->setPosition(parentPos - d->moveState.initialOffset); - } else { - QWaylandQuickItem::mouseMoveEvent(event); - } -} - -/*! - * \internal - */ -void QWaylandQuickXdgSurfaceItem::mouseReleaseEvent(QMouseEvent *event) -{ - Q_D(QWaylandQuickXdgSurfaceItem); - if (d->grabberState == QWaylandQuickXdgSurfaceItemPrivate::ResizeState) { - QPointF delta = (event->windowPos() - d->resizeState.initialMousePos) / d->scaleFactor(); - QSize newSize = xdgSurface()->sizeForResize(d->resizeState.initialWindowSize, delta, d->resizeState.resizeEdges); - xdgSurface()->requestUnMaximized(newSize); - d->grabberState = QWaylandQuickXdgSurfaceItemPrivate::DefaultState; - return; - } else if (d->grabberState == QWaylandQuickXdgSurfaceItemPrivate::MoveState) { - d->grabberState = QWaylandQuickXdgSurfaceItemPrivate::DefaultState; - return; - } - QWaylandQuickItem::mouseReleaseEvent(event); -} - -/*! - * \internal - */ -void QWaylandQuickXdgSurfaceItem::surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface) -{ - if (oldSurface) - disconnect(oldSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickXdgSurfaceItem::handleSurfaceSizeChanged); - - if (newSurface) - connect(newSurface, &QWaylandSurface::sizeChanged, this, &QWaylandQuickXdgSurfaceItem::handleSurfaceSizeChanged); -} - -QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandshellsurface.h b/src/compositor/extensions/qwaylandshellsurface.h new file mode 100644 index 00000000..1e9fcb5a --- /dev/null +++ b/src/compositor/extensions/qwaylandshellsurface.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDSHELLSURFACE_H +#define QWAYLANDSHELLSURFACE_H + +#include <QtWaylandCompositor/QWaylandCompositorExtension> + +QT_BEGIN_NAMESPACE + +class QWaylandQuickShellIntegration; +class QWaylandQuickShellSurfaceItem; +class QWaylandShellSurfacePrivate; +class QWaylandShellSurfaceTemplatePrivate; + +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellSurface : public QWaylandCompositorExtension +{ + Q_OBJECT +public: + virtual QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) = 0; + QWaylandShellSurface(QWaylandObject *waylandObject) : QWaylandCompositorExtension(waylandObject) {} + +protected: + QWaylandShellSurface(QWaylandCompositorExtensionPrivate &dd) : QWaylandCompositorExtension(dd){} + QWaylandShellSurface(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) : QWaylandCompositorExtension(container, dd) {} +}; + +template <typename T> +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandShellSurfaceTemplate : public QWaylandShellSurface +{ +public: + QWaylandShellSurfaceTemplate(QWaylandObject *container) + : QWaylandShellSurface(container) + { } + + const struct wl_interface *extensionInterface() const Q_DECL_OVERRIDE + { + return T::interface(); + } + + static T *findIn(QWaylandObject *container) + { + if (!container) return nullptr; + return qobject_cast<T *>(container->extension(T::interfaceName())); + } + +protected: + QWaylandShellSurfaceTemplate(QWaylandCompositorExtensionPrivate &dd) + : QWaylandShellSurface(dd) + { } + + QWaylandShellSurfaceTemplate(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) + : QWaylandShellSurface(container,dd) + { } +}; + +QT_END_NAMESPACE + +#endif // QWAYLANDSHELLSURFACE_H diff --git a/src/compositor/extensions/qwaylandtextinput.cpp b/src/compositor/extensions/qwaylandtextinput.cpp index 5ec203c1..973308f2 100644 --- a/src/compositor/extensions/qwaylandtextinput.cpp +++ b/src/compositor/extensions/qwaylandtextinput.cpp @@ -42,8 +42,8 @@ #include "qwaylandsurface.h" #include "qwaylandview.h" -#include "qwaylandxkb.h" -#include "qwaylandinputmethodeventbuilder.h" +#include "qwaylandxkb_p.h" +#include "qwaylandinputmethodeventbuilder_p.h" #include <QGuiApplication> #include <QInputMethodEvent> @@ -118,7 +118,7 @@ Qt::InputMethodQueries QWaylandTextInputClientState::mergeChanged(const QWayland } QWaylandTextInputPrivate::QWaylandTextInputPrivate(QWaylandCompositor *compositor) - : QWaylandExtensionTemplatePrivate() + : QWaylandCompositorExtensionPrivate() , QtWaylandServer::zwp_text_input_v2() , compositor(compositor) , focus(nullptr) @@ -507,7 +507,7 @@ void QWaylandTextInputPrivate::zwp_text_input_v2_set_surrounding_text(Resource * } QWaylandTextInput::QWaylandTextInput(QWaylandObject *container, QWaylandCompositor *compositor) - : QWaylandExtensionTemplate(container, *new QWaylandTextInputPrivate(compositor)) + : QWaylandCompositorExtensionTemplate(container, *new QWaylandTextInputPrivate(compositor)) { connect(&d_func()->focusDestroyListener, &QWaylandDestroyListener::fired, this, &QWaylandTextInput::focusSurfaceDestroyed); diff --git a/src/compositor/extensions/qwaylandtextinput.h b/src/compositor/extensions/qwaylandtextinput.h index ef289f1b..f050ab1c 100644 --- a/src/compositor/extensions/qwaylandtextinput.h +++ b/src/compositor/extensions/qwaylandtextinput.h @@ -37,7 +37,7 @@ #ifndef QWAYLANDTEXTINPUT_H #define QWAYLANDTEXTINPUT_H -#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandCompositorExtension> struct wl_client; @@ -49,7 +49,7 @@ class QInputMethodEvent; class QKeyEvent; class QWaylandSurface; -class QWaylandTextInput : public QWaylandExtensionTemplate<QWaylandTextInput> +class QWaylandTextInput : public QWaylandCompositorExtensionTemplate<QWaylandTextInput> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandTextInput) diff --git a/src/compositor/extensions/qwaylandtextinput_p.h b/src/compositor/extensions/qwaylandtextinput_p.h index 79706a7e..da90cc90 100644 --- a/src/compositor/extensions/qwaylandtextinput_p.h +++ b/src/compositor/extensions/qwaylandtextinput_p.h @@ -37,7 +37,7 @@ #ifndef QWAYLANDTEXTINPUT_P_H #define QWAYLANDTEXTINPUT_P_H -#include <QtWaylandCompositor/private/qwaylandextension_p.h> +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> #include <QtWaylandCompositor/private/qwayland-server-text-input-unstable-v2.h> #include <QtWaylandCompositor/QWaylandDestroyListener> @@ -83,7 +83,7 @@ public: Qt::InputMethodQueries changedState; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputPrivate : public QWaylandExtensionTemplatePrivate, public QtWaylandServer::zwp_text_input_v2 +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_v2 { Q_DECLARE_PUBLIC(QWaylandTextInput) public: diff --git a/src/compositor/extensions/qwaylandtextinputmanager.cpp b/src/compositor/extensions/qwaylandtextinputmanager.cpp index 62e8ac88..9dd7ace8 100644 --- a/src/compositor/extensions/qwaylandtextinputmanager.cpp +++ b/src/compositor/extensions/qwaylandtextinputmanager.cpp @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE QWaylandTextInputManagerPrivate::QWaylandTextInputManagerPrivate() - : QWaylandExtensionTemplatePrivate() + : QWaylandCompositorExtensionPrivate() , QtWaylandServer::zwp_text_input_manager_v2() { } @@ -63,12 +63,12 @@ void QWaylandTextInputManagerPrivate::zwp_text_input_manager_v2_get_text_input(R } QWaylandTextInputManager::QWaylandTextInputManager() - : QWaylandExtensionTemplate<QWaylandTextInputManager>(*new QWaylandTextInputManagerPrivate) + : QWaylandCompositorExtensionTemplate<QWaylandTextInputManager>(*new QWaylandTextInputManagerPrivate) { } QWaylandTextInputManager::QWaylandTextInputManager(QWaylandCompositor *compositor) - : QWaylandExtensionTemplate<QWaylandTextInputManager>(compositor, *new QWaylandTextInputManagerPrivate) + : QWaylandCompositorExtensionTemplate<QWaylandTextInputManager>(compositor, *new QWaylandTextInputManagerPrivate) { } @@ -76,7 +76,7 @@ void QWaylandTextInputManager::initialize() { Q_D(QWaylandTextInputManager); - QWaylandExtensionTemplate::initialize(); + QWaylandCompositorExtensionTemplate::initialize(); QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); if (!compositor) { qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandTextInputManager"; diff --git a/src/compositor/extensions/qwaylandtextinputmanager.h b/src/compositor/extensions/qwaylandtextinputmanager.h index 6c250d58..805c61af 100644 --- a/src/compositor/extensions/qwaylandtextinputmanager.h +++ b/src/compositor/extensions/qwaylandtextinputmanager.h @@ -37,7 +37,7 @@ #ifndef QWAYLANDTEXTINPUTMANAGER_H #define QWAYLANDTEXTINPUTMANAGER_H -#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtCore/QSize> @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE class QWaylandTextInputManagerPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputManager : public QWaylandExtensionTemplate<QWaylandTextInputManager> +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputManager : public QWaylandCompositorExtensionTemplate<QWaylandTextInputManager> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandTextInputManager) diff --git a/src/compositor/extensions/qwaylandtextinputmanager_p.h b/src/compositor/extensions/qwaylandtextinputmanager_p.h index 8052301c..4af71709 100644 --- a/src/compositor/extensions/qwaylandtextinputmanager_p.h +++ b/src/compositor/extensions/qwaylandtextinputmanager_p.h @@ -37,7 +37,7 @@ #ifndef QWAYLANDTEXTINPUTMANAGER_P_H #define QWAYLANDTEXTINPUTMANAGER_P_H -#include <QtWaylandCompositor/private/qwaylandextension_p.h> +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> #include <QtWaylandCompositor/private/qwayland-server-text-input-unstable-v2.h> @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputManagerPrivate : public QWaylandExtensionTemplatePrivate, public QtWaylandServer::zwp_text_input_manager_v2 +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandTextInputManagerPrivate : public QWaylandCompositorExtensionPrivate, public QtWaylandServer::zwp_text_input_manager_v2 { Q_DECLARE_PUBLIC(QWaylandTextInputManager) public: diff --git a/src/compositor/extensions/qwaylandwindowmanagerextension.cpp b/src/compositor/extensions/qwaylandwindowmanagerextension.cpp index 3dcca427..1e7ed289 100644 --- a/src/compositor/extensions/qwaylandwindowmanagerextension.cpp +++ b/src/compositor/extensions/qwaylandwindowmanagerextension.cpp @@ -45,17 +45,17 @@ QT_BEGIN_NAMESPACE QWaylandWindowManagerExtension::QWaylandWindowManagerExtension() - : QWaylandExtensionTemplate<QWaylandWindowManagerExtension>(*new QWaylandWindowManagerExtensionPrivate) + : QWaylandCompositorExtensionTemplate<QWaylandWindowManagerExtension>(*new QWaylandWindowManagerExtensionPrivate) { } QWaylandWindowManagerExtension::QWaylandWindowManagerExtension(QWaylandCompositor *compositor) - : QWaylandExtensionTemplate<QWaylandWindowManagerExtension>(compositor, *new QWaylandWindowManagerExtensionPrivate) + : QWaylandCompositorExtensionTemplate<QWaylandWindowManagerExtension>(compositor, *new QWaylandWindowManagerExtensionPrivate) { } QWaylandWindowManagerExtensionPrivate::QWaylandWindowManagerExtensionPrivate() - : QWaylandExtensionTemplatePrivate() + : QWaylandCompositorExtensionPrivate() , QtWaylandServer::qt_windowmanager() , showIsFullScreen(false) { @@ -94,7 +94,7 @@ void QWaylandWindowManagerExtension::initialize() { Q_D(QWaylandWindowManagerExtension); - QWaylandExtensionTemplate::initialize(); + QWaylandCompositorExtensionTemplate::initialize(); QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); if (!compositor) { qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandWindowManagerExtension"; diff --git a/src/compositor/extensions/qwaylandwindowmanagerextension.h b/src/compositor/extensions/qwaylandwindowmanagerextension.h index b365ff20..184bcc3c 100644 --- a/src/compositor/extensions/qwaylandwindowmanagerextension.h +++ b/src/compositor/extensions/qwaylandwindowmanagerextension.h @@ -37,7 +37,7 @@ #ifndef WAYLANDWINDOWMANAGERINTEGRATION_H #define WAYLANDWINDOWMANAGERINTEGRATION_H -#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtWaylandCompositor/QWaylandClient> #include <QtCore/QUrl> @@ -48,7 +48,7 @@ class QWaylandCompositor; class QWaylandWindowManagerExtensionPrivate; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWindowManagerExtension : public QWaylandExtensionTemplate<QWaylandWindowManagerExtension> +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWindowManagerExtension : public QWaylandCompositorExtensionTemplate<QWaylandWindowManagerExtension> { Q_OBJECT Q_PROPERTY(bool showIsFullScreen READ showIsFullScreen WRITE setShowIsFullScreen NOTIFY showIsFullScreenChanged) diff --git a/src/compositor/extensions/qwaylandwindowmanagerextension_p.h b/src/compositor/extensions/qwaylandwindowmanagerextension_p.h index 79e2256e..9573855d 100644 --- a/src/compositor/extensions/qwaylandwindowmanagerextension_p.h +++ b/src/compositor/extensions/qwaylandwindowmanagerextension_p.h @@ -48,7 +48,7 @@ // We mean it. // -#include <QtWaylandCompositor/private/qwaylandextension_p.h> +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> #include <QtWaylandCompositor/private/qwayland-server-windowmanager.h> @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWindowManagerExtensionPrivate - : public QWaylandExtensionTemplatePrivate + : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::qt_windowmanager { Q_DECLARE_PUBLIC(QWaylandWindowManagerExtension) diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp index 6953f72b..4e993768 100644 --- a/src/compositor/extensions/qwaylandwlshell.cpp +++ b/src/compositor/extensions/qwaylandwlshell.cpp @@ -38,6 +38,8 @@ #include "qwaylandwlshell.h" #include "qwaylandwlshell_p.h" +#include "qwaylandwlshellintegration_p.h" + #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/QWaylandView> #include <QtWaylandCompositor/QWaylandOutput> @@ -51,7 +53,7 @@ QT_BEGIN_NAMESPACE QWaylandSurfaceRole QWaylandWlShellSurfacePrivate::s_role("wl_shell_surface"); QWaylandWlShellPrivate::QWaylandWlShellPrivate() - : QWaylandExtensionTemplatePrivate() + : QWaylandCompositorExtensionPrivate() , wl_shell() { } @@ -88,7 +90,7 @@ void QWaylandWlShellPrivate::shell_get_shell_surface(Resource *resource, uint32_ } QWaylandWlShellSurfacePrivate::QWaylandWlShellSurfacePrivate() - : QWaylandExtensionTemplatePrivate() + : QWaylandCompositorExtensionPrivate() , wl_shell_surface() , m_shell(Q_NULLPTR) , m_surface(Q_NULLPTR) @@ -280,14 +282,14 @@ void QWaylandWlShellSurfacePrivate::shell_surface_set_class(Resource *resource, * Constructs a QWaylandWlShell object. */ QWaylandWlShell::QWaylandWlShell() - : QWaylandExtensionTemplate<QWaylandWlShell>(*new QWaylandWlShellPrivate()) + : QWaylandCompositorExtensionTemplate<QWaylandWlShell>(*new QWaylandWlShellPrivate()) { } /*! * Constructs a QWaylandWlShell object for the provided \a compositor. */ QWaylandWlShell::QWaylandWlShell(QWaylandCompositor *compositor) - : QWaylandExtensionTemplate<QWaylandWlShell>(compositor, *new QWaylandWlShellPrivate()) + : QWaylandCompositorExtensionTemplate<QWaylandWlShell>(compositor, *new QWaylandWlShellPrivate()) { } @@ -297,7 +299,7 @@ QWaylandWlShell::QWaylandWlShell(QWaylandCompositor *compositor) void QWaylandWlShell::initialize() { Q_D(QWaylandWlShell); - QWaylandExtensionTemplate::initialize(); + QWaylandCompositorExtensionTemplate::initialize(); QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); if (!compositor) { qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandWlShell"; @@ -370,7 +372,7 @@ QByteArray QWaylandWlShell::interfaceName() * Constructs a QWaylandWlShellSurface. */ QWaylandWlShellSurface::QWaylandWlShellSurface() - : QWaylandExtensionTemplate<QWaylandWlShellSurface>(*new QWaylandWlShellSurfacePrivate) + : QWaylandShellSurfaceTemplate<QWaylandWlShellSurface>(*new QWaylandWlShellSurfacePrivate) { } @@ -378,7 +380,7 @@ QWaylandWlShellSurface::QWaylandWlShellSurface() * Constructs a QWaylandWlShellSurface for \a surface and initializes it with the given \a shell and \a resource. */ QWaylandWlShellSurface::QWaylandWlShellSurface(QWaylandWlShell *shell, QWaylandSurface *surface, const QWaylandResource &res) - : QWaylandExtensionTemplate<QWaylandWlShellSurface>(*new QWaylandWlShellSurfacePrivate) + : QWaylandShellSurfaceTemplate<QWaylandWlShellSurface>(*new QWaylandWlShellSurfacePrivate) { initialize(shell, surface, res); } @@ -400,7 +402,7 @@ void QWaylandWlShellSurface::initialize(QWaylandWlShell *shell, QWaylandSurface d->init(resource.resource()); setExtensionContainer(surface); emit surfaceChanged(); - QWaylandExtension::initialize(); + QWaylandCompositorExtension::initialize(); } /*! @@ -408,7 +410,7 @@ void QWaylandWlShellSurface::initialize(QWaylandWlShell *shell, QWaylandSurface */ void QWaylandWlShellSurface::initialize() { - QWaylandExtensionTemplate::initialize(); + QWaylandCompositorExtension::initialize(); } const struct wl_interface *QWaylandWlShellSurface::interface() @@ -494,6 +496,11 @@ void QWaylandWlShellSurface::sendPopupDone() d->send_popup_done(); } +QWaylandQuickShellIntegration *QWaylandWlShellSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) +{ + return new QtWayland::WlShellIntegration(item); +} + /*! * \qmlproperty object QtWaylandCompositor::WlShellSurface::surface * diff --git a/src/compositor/extensions/qwaylandwlshell.h b/src/compositor/extensions/qwaylandwlshell.h index 12905549..441c5452 100644 --- a/src/compositor/extensions/qwaylandwlshell.h +++ b/src/compositor/extensions/qwaylandwlshell.h @@ -37,8 +37,9 @@ #ifndef QWAYLANDWLSHELL_H #define QWAYLANDWLSHELL_H -#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtWaylandCompositor/QWaylandResource> +#include <QtWaylandCompositor/QWaylandShellSurface> #include <QtCore/QSize> @@ -53,7 +54,7 @@ class QWaylandOutput; class QWaylandSurfaceRole; class QWaylandWlShellSurface; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShell : public QWaylandExtensionTemplate<QWaylandWlShell> +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShell : public QWaylandCompositorExtensionTemplate<QWaylandWlShell> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandWlShell) @@ -71,7 +72,7 @@ Q_SIGNALS: void shellSurfaceCreated(QWaylandWlShellSurface *shellSurface); }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellSurface : public QWaylandExtensionTemplate<QWaylandWlShellSurface> +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellSurface : public QWaylandShellSurfaceTemplate<QWaylandWlShellSurface> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandWlShellSurface) @@ -130,6 +131,8 @@ public: Q_INVOKABLE void sendConfigure(const QSize &size, ResizeEdge edges); Q_INVOKABLE void sendPopupDone(); + QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) Q_DECL_OVERRIDE; + public Q_SLOTS: void ping(); diff --git a/src/compositor/extensions/qwaylandwlshell_p.h b/src/compositor/extensions/qwaylandwlshell_p.h index 8d7129fa..39ed645c 100644 --- a/src/compositor/extensions/qwaylandwlshell_p.h +++ b/src/compositor/extensions/qwaylandwlshell_p.h @@ -39,7 +39,7 @@ #include <QtWaylandCompositor/qwaylandexport.h> #include <QtWaylandCompositor/qwaylandsurface.h> -#include <QtWaylandCompositor/private/qwaylandextension_p.h> +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> #include <QtWaylandCompositor/QWaylandWlShellSurface> #include <QtWaylandCompositor/QWaylandInputDevice> @@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellPrivate - : public QWaylandExtensionTemplatePrivate + : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::wl_shell { Q_DECLARE_PUBLIC(QWaylandWlShell) @@ -77,7 +77,7 @@ protected: }; class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlShellSurfacePrivate - : public QWaylandExtensionTemplatePrivate + : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::wl_shell_surface { Q_DECLARE_PUBLIC(QWaylandWlShellSurface) diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp new file mode 100644 index 00000000..8eb0ba3b --- /dev/null +++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp @@ -0,0 +1,249 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandwlshellintegration_p.h" + +#include <QtWaylandCompositor/QWaylandCompositor> +#include <QtWaylandCompositor/QWaylandWlShellSurface> +#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem> +#include <QtWaylandCompositor/QWaylandInputDevice> +#include <QGuiApplication> + +namespace QtWayland { + +WlShellIntegration::WlShellIntegration(QWaylandQuickShellSurfaceItem *item) + : QWaylandQuickShellIntegration(item) + , m_item(item) + , m_shellSurface(qobject_cast<QWaylandWlShellSurface *>(item->shellSurface())) + , grabberState(GrabberState::Default) + , isPopup(false) +{ + m_item->setSurface(m_shellSurface->surface()); + connect(m_shellSurface, &QWaylandWlShellSurface::startMove, this, &WlShellIntegration::handleStartMove); + connect(m_shellSurface, &QWaylandWlShellSurface::startResize, this, &WlShellIntegration::handleStartResize); + connect(m_shellSurface->surface(), &QWaylandSurface::offsetForNextFrame, this, &WlShellIntegration::adjustOffsetForNextFrame); + connect(m_shellSurface, &QWaylandWlShellSurface::setPopup, this, &WlShellIntegration::handleSetPopup); + connect(m_shellSurface, &QWaylandWlShellSurface::destroyed, this, &WlShellIntegration::handleShellSurfaceDestroyed); +} + +void WlShellIntegration::handleStartMove(QWaylandInputDevice *inputDevice) +{ + grabberState = GrabberState::Move; + moveState.inputDevice = inputDevice; + moveState.initialized = false; +} + +void WlShellIntegration::handleStartResize(QWaylandInputDevice *inputDevice, QWaylandWlShellSurface::ResizeEdge edges) +{ + grabberState = GrabberState::Resize; + resizeState.inputDevice = inputDevice; + resizeState.resizeEdges = edges; + float scaleFactor = m_item->view()->output()->scaleFactor(); + resizeState.initialSize = m_shellSurface->surface()->size() / scaleFactor; + resizeState.initialized = false; +} + +void WlShellIntegration::handleSetPopup(QWaylandInputDevice *inputDevice, QWaylandSurface *parent, const QPoint &relativeToParent) +{ + Q_UNUSED(inputDevice); + + QWaylandQuickShellSurfaceItem* parentItem = qobject_cast<QWaylandQuickShellSurfaceItem*>(parent->views().first()->renderObject()); + if (parentItem) { + // Clear all the transforms for this ShellSurfaceItem. They are not + // applicable when the item becomes a child to a surface that has its + // own transforms. Otherwise the transforms would be applied twice. + QQmlListProperty<QQuickTransform> t = m_item->transform(); + t.clear(&t); + m_item->setRotation(0); + m_item->setScale(1.0); + m_item->setX(relativeToParent.x()); + m_item->setY(relativeToParent.y()); + m_item->setParentItem(parentItem); + } + + setIsPopup(true); +} + +void WlShellIntegration::handleShellSurfaceDestroyed() { + setIsPopup(false); + m_shellSurface = nullptr; +} + +void WlShellIntegration::handleSurfaceUnmapped() +{ + if (!m_shellSurface || !m_shellSurface->surface()->size().isEmpty()) + return; + setIsPopup(false); +} + +void WlShellIntegration::adjustOffsetForNextFrame(const QPointF &offset) +{ + float scaleFactor = m_item->view()->output()->scaleFactor(); + QQuickItem *moveItem = m_item->moveItem(); + moveItem->setPosition(moveItem->position() + offset * scaleFactor); +} + +bool WlShellIntegration::mouseMoveEvent(QMouseEvent *event) +{ + if (grabberState == GrabberState::Resize) { + Q_ASSERT(resizeState.inputDevice == m_item->compositor()->inputDeviceFor(event)); + if (!resizeState.initialized) { + resizeState.initialMousePos = event->windowPos(); + resizeState.initialized = true; + return true; + } + float scaleFactor = m_item->view()->output()->scaleFactor(); + QPointF delta = (event->windowPos() - resizeState.initialMousePos) / scaleFactor; + QSize newSize = m_shellSurface->sizeForResize(resizeState.initialSize, delta, resizeState.resizeEdges); + m_shellSurface->sendConfigure(newSize, resizeState.resizeEdges); + } else if (grabberState == GrabberState::Move) { + Q_ASSERT(moveState.inputDevice == m_item->compositor()->inputDeviceFor(event)); + QQuickItem *moveItem = m_item->moveItem(); + if (!moveState.initialized) { + moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); + moveState.initialized = true; + return true; + } + if (!moveItem->parentItem()) + return true; + QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); + moveItem->setPosition(parentPos - moveState.initialOffset); + } + return false; +} + +bool WlShellIntegration::mouseReleaseEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + if (grabberState != GrabberState::Default) { + grabberState = GrabberState::Default; + return true; + } + return false; +} + +QVector<QWaylandWlShellSurface*> WlShellIntegration::popupShellSurfaces; +bool WlShellIntegration::eventFilterInstalled = false; +bool WlShellIntegration::waitForRelease = false; + +void WlShellIntegration::closePopups() +{ + if (!popupShellSurfaces.isEmpty()) { + Q_FOREACH (QWaylandWlShellSurface* shellSurface, popupShellSurfaces) { + shellSurface->sendPopupDone(); + } + popupShellSurfaces.clear(); + } +} + +bool WlShellIntegration::eventFilter(QObject *receiver, QEvent *e) +{ + if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease) { + QQuickItem *item = qobject_cast<QQuickItem*>(receiver); + if (!item) + return false; + + QMouseEvent *event = static_cast<QMouseEvent*>(e); + QWaylandQuickShellSurfaceItem *shellSurfaceItem = qobject_cast<QWaylandQuickShellSurfaceItem*>(item); + bool press = event->type() == QEvent::MouseButtonPress; + bool finalRelease = (event->type() == QEvent::MouseButtonRelease) && (event->buttons() == Qt::NoButton); + bool popupClient = shellSurfaceItem && shellSurfaceItem->surface()->client() == m_shellSurface->surface()->client(); + + if (waitForRelease) { + // We are eating events until all mouse buttons are released + if (finalRelease) { + waitForRelease = false; + setFilterEnabled(false); + } + return true; + } + + if (press && !popupClient) { + // The user clicked outside the active popup's client. The popups should + // be closed, but the event filter will stay to catch the release- + // event before removing itself. + waitForRelease = true; + closePopups(); + return true; + } else if (press) { + // There is a surface belonging to this client at this coordinate, so we can + // remove the event filter and let the normal event handler handle + // this event. + setFilterEnabled(false); + } + } + + return false; +} + +void WlShellIntegration::setIsPopup(bool popup) +{ + isPopup = popup; + if (popup) { + if (!eventFilterInstalled) + setFilterEnabled(true); + + if (!popupShellSurfaces.contains(m_shellSurface)) { + popupShellSurfaces.append(m_shellSurface); + QObject::connect(m_shellSurface->surface(), &QWaylandSurface::mappedChanged, + this, &WlShellIntegration::handleSurfaceUnmapped); + } + } else { + if (m_shellSurface) { + popupShellSurfaces.removeOne(m_shellSurface); + QObject::disconnect(m_shellSurface->surface(), &QWaylandSurface::mappedChanged, + this, &WlShellIntegration::handleSurfaceUnmapped); + } + if (!waitForRelease && eventFilterInstalled && popupShellSurfaces.isEmpty()) + setFilterEnabled(false); + } +} + +void WlShellIntegration::setFilterEnabled(bool enabled) +{ + static QPointer<QObject> filter; + + if (enabled && filter.isNull()) { + qGuiApp->installEventFilter(this); + filter = this; + } else if (!enabled && !filter.isNull()){ + qGuiApp->removeEventFilter(filter); + filter = nullptr; + } + eventFilterInstalled = enabled; +} + +} diff --git a/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.h b/src/compositor/extensions/qwaylandwlshellintegration_p.h index 7f32c9f3..48607720 100644 --- a/src/compositor/extensions/qwaylandquickwlshellsurfaceitem.h +++ b/src/compositor/extensions/qwaylandwlshellintegration_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtWaylandCompositor module of the Qt Toolkit. @@ -34,51 +34,81 @@ ** ****************************************************************************/ -#ifndef QWAYLANDQUICKWLSHELLSURFACEITEM_H -#define QWAYLANDQUICKWLSHELLSURFACEITEM_H +#ifndef QWAYLANDWLSHELLINTEGRATION_H +#define QWAYLANDWLSHELLINTEGRATION_H + +#include <QtWaylandCompositor/private/qwaylandquickshellsurfaceitem_p.h> -#include <QtWaylandCompositor/QWaylandExtension> -#include <QtWaylandCompositor/QWaylandQuickItem> #include <QtWaylandCompositor/QWaylandWlShellSurface> QT_BEGIN_NAMESPACE -class QWaylandQuickWlShellSurfaceItemPrivate; +// +// 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. +// + +namespace QtWayland { -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickWlShellSurfaceItem : public QWaylandQuickItem +class WlShellIntegration : public QWaylandQuickShellIntegration { Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandQuickWlShellSurfaceItem) - Q_PROPERTY(QWaylandWlShellSurface *shellSurface READ shellSurface WRITE setShellSurface NOTIFY shellSurfaceChanged) - Q_PROPERTY(QQuickItem *moveItem READ moveItem WRITE setMoveItem NOTIFY moveItemChanged) - public: - QWaylandQuickWlShellSurfaceItem(QQuickItem *parent = 0); - - static QWaylandQuickWlShellSurfaceItemPrivate *get(QWaylandQuickWlShellSurfaceItem *item) { return item->d_func(); } - - QWaylandWlShellSurface *shellSurface() const; - void setShellSurface(QWaylandWlShellSurface *shellSurface); - - QQuickItem *moveItem() const; - void setMoveItem(QQuickItem *moveItem); -Q_SIGNALS: - void shellSurfaceChanged(); - void moveItemChanged(); + WlShellIntegration(QWaylandQuickShellSurfaceItem *item); + bool mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + bool mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; private Q_SLOTS: void handleStartMove(QWaylandInputDevice *inputDevice); void handleStartResize(QWaylandInputDevice *inputDevice, QWaylandWlShellSurface::ResizeEdge edges); + void handleSetPopup(QWaylandInputDevice *inputDevice, QWaylandSurface *parent, const QPoint &relativeToParent); + void handleShellSurfaceDestroyed(); + void handleSurfaceUnmapped(); void adjustOffsetForNextFrame(const QPointF &offset); -protected: - QWaylandQuickWlShellSurfaceItem(QWaylandQuickWlShellSurfaceItemPrivate &dd, QQuickItem *parent); - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; +private: + enum class GrabberState { + Default, + Resize, + Move + }; + + bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; + + void setIsPopup(bool popup); + void setFilterEnabled(bool enabled); + static void closePopups(); - void surfaceChangedEvent(QWaylandSurface *newSurface, QWaylandSurface *oldSurface) Q_DECL_OVERRIDE; + QWaylandQuickShellSurfaceItem *m_item; + QWaylandWlShellSurface *m_shellSurface; + GrabberState grabberState; + struct { + QWaylandInputDevice *inputDevice; + QPointF initialOffset; + bool initialized; + } moveState; + struct { + QWaylandInputDevice *inputDevice; + QWaylandWlShellSurface::ResizeEdge resizeEdges; + QSizeF initialSize; + QPointF initialMousePos; + bool initialized; + } resizeState; + + static QVector<QWaylandWlShellSurface*> popupShellSurfaces; + static bool eventFilterInstalled; + static bool waitForRelease; + bool isPopup; }; +} + QT_END_NAMESPACE -#endif /*QWAYLANDQUICKWLSHELLSURFACEITEM_H*/ +#endif // QWAYLANDWLSHELLINTEGRATION_H diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp index c4371339..dfc68e25 100644 --- a/src/compositor/extensions/qwaylandxdgshell.cpp +++ b/src/compositor/extensions/qwaylandxdgshell.cpp @@ -36,6 +36,7 @@ #include "qwaylandxdgshell.h" #include "qwaylandxdgshell_p.h" +#include "qwaylandxdgshellintegration_p.h" #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/QWaylandSurface> @@ -53,7 +54,7 @@ QWaylandSurfaceRole QWaylandXdgSurfacePrivate::s_role("xdg_surface"); QWaylandSurfaceRole QWaylandXdgPopupPrivate::s_role("xdg_popup"); QWaylandXdgShellPrivate::QWaylandXdgShellPrivate() - : QWaylandExtensionTemplatePrivate() + : QWaylandCompositorExtensionPrivate() , xdg_shell() { } @@ -216,7 +217,7 @@ void QWaylandXdgShellPrivate::xdg_shell_pong(Resource *resource, uint32_t serial } QWaylandXdgSurfacePrivate::QWaylandXdgSurfacePrivate() - : QWaylandExtensionTemplatePrivate() + : QWaylandCompositorExtensionPrivate() , xdg_surface() , m_surface(nullptr) , m_parentSurface(nullptr) @@ -439,7 +440,7 @@ void QWaylandXdgSurfacePrivate::xdg_surface_set_window_geometry(Resource *resour } QWaylandXdgPopupPrivate::QWaylandXdgPopupPrivate() - : QWaylandExtensionTemplatePrivate() + : QWaylandCompositorExtensionPrivate() , xdg_popup() , m_surface(nullptr) , m_parentSurface(nullptr) @@ -465,14 +466,14 @@ void QWaylandXdgPopupPrivate::xdg_popup_destroy(Resource *resource) * Constructs a QWaylandXdgShell object. */ QWaylandXdgShell::QWaylandXdgShell() - : QWaylandExtensionTemplate<QWaylandXdgShell>(*new QWaylandXdgShellPrivate()) + : QWaylandCompositorExtensionTemplate<QWaylandXdgShell>(*new QWaylandXdgShellPrivate()) { } /*! * Constructs a QWaylandXdgShell object for the provided \a compositor. */ QWaylandXdgShell::QWaylandXdgShell(QWaylandCompositor *compositor) - : QWaylandExtensionTemplate<QWaylandXdgShell>(compositor, *new QWaylandXdgShellPrivate()) + : QWaylandCompositorExtensionTemplate<QWaylandXdgShell>(compositor, *new QWaylandXdgShellPrivate()) { } /*! @@ -481,7 +482,7 @@ QWaylandXdgShell::QWaylandXdgShell(QWaylandCompositor *compositor) void QWaylandXdgShell::initialize() { Q_D(QWaylandXdgShell); - QWaylandExtensionTemplate::initialize(); + QWaylandCompositorExtensionTemplate::initialize(); QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer()); if (!compositor) { qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandXdgShell"; @@ -592,7 +593,7 @@ void QWaylandXdgShell::handleFocusChanged(QWaylandSurface *newSurface, QWaylandS * Constructs a QWaylandXdgSurface. */ QWaylandXdgSurface::QWaylandXdgSurface() - : QWaylandExtensionTemplate<QWaylandXdgSurface>(*new QWaylandXdgSurfacePrivate) + : QWaylandShellSurfaceTemplate<QWaylandXdgSurface>(*new QWaylandXdgSurfacePrivate) { } @@ -601,7 +602,7 @@ QWaylandXdgSurface::QWaylandXdgSurface() * given \a xdgShell, \a surface and \a resource. */ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *xdgShell, QWaylandSurface *surface, const QWaylandResource &res) - : QWaylandExtensionTemplate<QWaylandXdgSurface>(*new QWaylandXdgSurfacePrivate) + : QWaylandShellSurfaceTemplate<QWaylandXdgSurface>(*new QWaylandXdgSurfacePrivate) { initialize(xdgShell, surface, res); } @@ -628,7 +629,7 @@ void QWaylandXdgSurface::initialize(QWaylandXdgShell *xdgShell, QWaylandSurface connect(surface, &QWaylandSurface::sizeChanged, this, &QWaylandXdgSurface::handleSurfaceSizeChanged); emit surfaceChanged(); emit windowGeometryChanged(); - QWaylandExtension::initialize(); + QWaylandCompositorExtension::initialize(); } /*! @@ -636,7 +637,7 @@ void QWaylandXdgSurface::initialize(QWaylandXdgShell *xdgShell, QWaylandSurface */ void QWaylandXdgSurface::initialize() { - QWaylandExtensionTemplate::initialize(); + QWaylandCompositorExtension::initialize(); } QList<int> QWaylandXdgSurface::statesAsInts() const @@ -722,9 +723,13 @@ QString QWaylandXdgSurface::appId() const } /*! - * \property QWaylandXdgSurface::appId + * \property QWaylandXdgSurface::windowGeometry * - * This property holds the window geometry of the QWaylandXdgSurface. + * This property holds the window geometry of the QWaylandXdgSurface. The window + * geometry describes the window's visible bounds from the user's perspective. + * The geometry includes title bars and borders if drawn by the client, but + * excludes drop shadows. It is meant to be used for aligning and tiling + * windows. */ QRect QWaylandXdgSurface::windowGeometry() const { @@ -913,6 +918,11 @@ uint QWaylandXdgSurface::requestResizing(const QSize &maxSize) return sendConfigure(maxSize, conf.states); } +QWaylandQuickShellIntegration *QWaylandXdgSurface::createIntegration(QWaylandQuickShellSurfaceItem *item) +{ + return new QtWayland::XdgShellIntegration(item); +} + /*! * \class QWaylandXdgPopup * \inmodule QtWaylandCompositor @@ -930,7 +940,7 @@ uint QWaylandXdgSurface::requestResizing(const QSize &maxSize) * Constructs a QWaylandXdgPopup. */ QWaylandXdgPopup::QWaylandXdgPopup() - : QWaylandExtensionTemplate<QWaylandXdgPopup>(*new QWaylandXdgPopupPrivate) + : QWaylandCompositorExtensionTemplate<QWaylandXdgPopup>(*new QWaylandXdgPopupPrivate) { } @@ -940,7 +950,7 @@ QWaylandXdgPopup::QWaylandXdgPopup() */ QWaylandXdgPopup::QWaylandXdgPopup(QWaylandXdgShell *xdgShell, QWaylandSurface *surface, QWaylandSurface *parentSurface, const QWaylandResource &resource) - : QWaylandExtensionTemplate<QWaylandXdgPopup>(*new QWaylandXdgPopupPrivate) + : QWaylandCompositorExtensionTemplate<QWaylandXdgPopup>(*new QWaylandXdgPopupPrivate) { initialize(xdgShell, surface, parentSurface, resource); } @@ -967,7 +977,7 @@ void QWaylandXdgPopup::initialize(QWaylandXdgShell *shell, QWaylandSurface *surf setExtensionContainer(surface); emit surfaceChanged(); emit parentSurfaceChanged(); - QWaylandExtension::initialize(); + QWaylandCompositorExtension::initialize(); } /*! @@ -1010,7 +1020,7 @@ QWaylandSurface *QWaylandXdgPopup::parentSurface() const */ void QWaylandXdgPopup::initialize() { - QWaylandExtensionTemplate::initialize(); + QWaylandCompositorExtensionTemplate::initialize(); } /*! diff --git a/src/compositor/extensions/qwaylandxdgshell.h b/src/compositor/extensions/qwaylandxdgshell.h index 2b751aee..c01726ac 100644 --- a/src/compositor/extensions/qwaylandxdgshell.h +++ b/src/compositor/extensions/qwaylandxdgshell.h @@ -37,8 +37,9 @@ #ifndef QWAYLANDXDGSHELL_H #define QWAYLANDXDGSHELL_H -#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtWaylandCompositor/QWaylandResource> +#include <QtWaylandCompositor/QWaylandShellSurface> #include <QtCore/QRect> @@ -58,7 +59,7 @@ class QWaylandInputDevice; class QWaylandOutput; class QWaylandClient; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShell : public QWaylandExtensionTemplate<QWaylandXdgShell> +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShell : public QWaylandCompositorExtensionTemplate<QWaylandXdgShell> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgShell) @@ -88,7 +89,7 @@ private Q_SLOTS: }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurface : public QWaylandExtensionTemplate<QWaylandXdgSurface> +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurface : public QWaylandShellSurfaceTemplate<QWaylandXdgSurface> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgSurface) @@ -158,6 +159,8 @@ public: Q_INVOKABLE uint requestFullscreen(const QSize &size); Q_INVOKABLE uint requestResizing(const QSize &maxSize); + QWaylandQuickShellIntegration *createIntegration(QWaylandQuickShellSurfaceItem *item) Q_DECL_OVERRIDE; + Q_SIGNALS: void surfaceChanged(); void titleChanged(); @@ -189,7 +192,7 @@ private Q_SLOTS: void handleSurfaceSizeChanged(); }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopup : public QWaylandExtensionTemplate<QWaylandXdgPopup> +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopup : public QWaylandCompositorExtensionTemplate<QWaylandXdgPopup> { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandXdgPopup) diff --git a/src/compositor/extensions/qwaylandxdgshell_p.h b/src/compositor/extensions/qwaylandxdgshell_p.h index 7337697d..3165eb7c 100644 --- a/src/compositor/extensions/qwaylandxdgshell_p.h +++ b/src/compositor/extensions/qwaylandxdgshell_p.h @@ -37,11 +37,13 @@ #ifndef QWAYLANDXDGSHELL_P_H #define QWAYLANDXDGSHELL_P_H -#include <QtWaylandCompositor/private/qwaylandextension_p.h> +#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h> #include <QtWaylandCompositor/private/qwayland-server-xdg-shell.h> #include <QtWaylandCompositor/QWaylandXdgShell> +#include <QtCore/QSet> + // // W A R N I N G // ------------- @@ -56,7 +58,7 @@ QT_BEGIN_NAMESPACE class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgShellPrivate - : public QWaylandExtensionTemplatePrivate + : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::xdg_shell { Q_DECLARE_PUBLIC(QWaylandXdgShell) @@ -89,7 +91,7 @@ private: }; class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgSurfacePrivate - : public QWaylandExtensionTemplatePrivate + : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::xdg_surface { Q_DECLARE_PUBLIC(QWaylandXdgSurface) @@ -146,7 +148,7 @@ private: }; class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandXdgPopupPrivate - : public QWaylandExtensionTemplatePrivate + : public QWaylandCompositorExtensionPrivate , public QtWaylandServer::xdg_popup { Q_DECLARE_PUBLIC(QWaylandXdgPopup) diff --git a/src/compositor/extensions/qwaylandxdgshellintegration.cpp b/src/compositor/extensions/qwaylandxdgshellintegration.cpp new file mode 100644 index 00000000..3a22cce0 --- /dev/null +++ b/src/compositor/extensions/qwaylandxdgshellintegration.cpp @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWaylandCompositor module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandxdgshellintegration_p.h" + +#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem> +#include <QtWaylandCompositor/QWaylandCompositor> +#include <QtWaylandCompositor/QWaylandInputDevice> +#include <QMouseEvent> + +namespace QtWayland { + +XdgShellIntegration::XdgShellIntegration(QWaylandQuickShellSurfaceItem *item) + : QWaylandQuickShellIntegration(item) + , m_item(item) + , m_xdgSurface(qobject_cast<QWaylandXdgSurface *>(item->shellSurface())) + , grabberState(GrabberState::Default) +{ + m_item->setSurface(m_xdgSurface->surface()); + connect(m_xdgSurface, &QWaylandXdgSurface::startMove, this, &XdgShellIntegration::handleStartMove); + connect(m_xdgSurface, &QWaylandXdgSurface::startResize, this, &XdgShellIntegration::handleStartResize); + connect(m_xdgSurface, &QWaylandXdgSurface::setMaximized, this, &XdgShellIntegration::handleSetMaximized); + connect(m_xdgSurface, &QWaylandXdgSurface::unsetMaximized, this, &XdgShellIntegration::handleUnsetMaximized); + connect(m_xdgSurface, &QWaylandXdgSurface::maximizedChanged, this, &XdgShellIntegration::handleMaximizedChanged); + connect(m_xdgSurface, &QWaylandXdgSurface::activatedChanged, this, &XdgShellIntegration::handleActivatedChanged); + connect(m_xdgSurface->surface(), &QWaylandSurface::sizeChanged, this, &XdgShellIntegration::handleSurfaceSizeChanged); +} + +bool XdgShellIntegration::mouseMoveEvent(QMouseEvent *event) +{ + if (grabberState == GrabberState::Resize) { + Q_ASSERT(resizeState.inputDevice == m_item->compositor()->inputDeviceFor(event)); + if (!resizeState.initialized) { + resizeState.initialMousePos = event->windowPos(); + resizeState.initialized = true; + return true; + } + float scaleFactor = m_item->view()->output()->scaleFactor(); + QPointF delta = (event->windowPos() - resizeState.initialMousePos) / scaleFactor; + QSize newSize = m_xdgSurface->sizeForResize(resizeState.initialWindowSize, delta, resizeState.resizeEdges); + m_xdgSurface->requestResizing(newSize); + } else if (grabberState == GrabberState::Move) { + Q_ASSERT(moveState.inputDevice == m_item->compositor()->inputDeviceFor(event)); + QQuickItem *moveItem = m_item->moveItem(); + if (!moveState.initialized) { + moveState.initialOffset = moveItem->mapFromItem(nullptr, event->windowPos()); + moveState.initialized = true; + return true; + } + if (!moveItem->parentItem()) + return true; + QPointF parentPos = moveItem->parentItem()->mapFromItem(nullptr, event->windowPos()); + moveItem->setPosition(parentPos - moveState.initialOffset); + } + return false; +} + +bool XdgShellIntegration::mouseReleaseEvent(QMouseEvent *event) +{ + if (grabberState == GrabberState::Resize) { + float scaleFactor = m_item->view()->output()->scaleFactor(); + QPointF delta = (event->windowPos() - resizeState.initialMousePos) / scaleFactor; + QSize newSize = m_xdgSurface->sizeForResize(resizeState.initialWindowSize, delta, resizeState.resizeEdges); + m_xdgSurface->requestUnMaximized(newSize); + grabberState = GrabberState::Default; + return true; + } else if (grabberState == GrabberState::Move) { + grabberState = GrabberState::Default; + return true; + } + return false; +} + +void XdgShellIntegration::handleStartMove(QWaylandInputDevice *inputDevice) +{ + grabberState = GrabberState::Move; + moveState.inputDevice = inputDevice; + moveState.initialized = false; +} + +void XdgShellIntegration::handleStartResize(QWaylandInputDevice *inputDevice, QWaylandXdgSurface::ResizeEdge edges) +{ + grabberState = GrabberState::Resize; + resizeState.inputDevice = inputDevice; + resizeState.resizeEdges = edges; + resizeState.initialWindowSize = m_xdgSurface->windowGeometry().size(); + resizeState.initialPosition = m_item->position(); + resizeState.initialSurfaceSize = m_item->surface()->size(); + resizeState.initialized = false; +} + +void XdgShellIntegration::handleSetMaximized() +{ + maximizeState.initialWindowSize = m_xdgSurface->windowGeometry().size(); + maximizeState.initialPosition = m_item->position(); + + QWaylandOutput *output = m_item->compositor()->outputs().first(); + m_xdgSurface->requestMaximized(output->geometry().size() / output->scaleFactor()); +} + +void XdgShellIntegration::handleUnsetMaximized() +{ + m_xdgSurface->requestUnMaximized(maximizeState.initialWindowSize); +} + +void XdgShellIntegration::handleMaximizedChanged() +{ + if (m_xdgSurface->maximized()) { + QWaylandOutput *output = m_item->compositor()->outputs().first(); + m_item->setPosition(output->geometry().topLeft()); + } else { + m_item->setPosition(maximizeState.initialPosition); + } +} + +void XdgShellIntegration::handleActivatedChanged() +{ + if (m_xdgSurface->activated()) + m_item->raise(); +} + +void XdgShellIntegration::handleSurfaceSizeChanged() +{ + if (grabberState == GrabberState::Resize) { + qreal x = resizeState.initialPosition.x(); + qreal y = resizeState.initialPosition.y(); + if (resizeState.resizeEdges & QWaylandXdgSurface::ResizeEdge::TopEdge) + y += resizeState.initialSurfaceSize.height() - m_item->surface()->size().height(); + + if (resizeState.resizeEdges & QWaylandXdgSurface::ResizeEdge::LeftEdge) + x += resizeState.initialSurfaceSize.width() - m_item->surface()->size().width(); + m_item->setPosition(QPointF(x, y)); + } +} + +} diff --git a/src/compositor/extensions/qwaylandquickxdgsurfaceitem_p.h b/src/compositor/extensions/qwaylandxdgshellintegration_p.h index 4ac2853d..df2fa8b8 100644 --- a/src/compositor/extensions/qwaylandquickxdgsurfaceitem_p.h +++ b/src/compositor/extensions/qwaylandxdgshellintegration_p.h @@ -34,10 +34,11 @@ ** ****************************************************************************/ -#ifndef QWAYLANDQUICKXDGSURFACEITEM_P_H -#define QWAYLANDQUICKXDGSURFACEITEM_P_H +#ifndef QWAYLANDXDGSHELLINTEGRATION_H +#define QWAYLANDXDGSHELLINTEGRATION_H -#include <QtWaylandCompositor/private/qwaylandquickitem_p.h> +#include <QtWaylandCompositor/private/qwaylandquickshellsurfaceitem_p.h> +#include <QtWaylandCompositor/QWaylandXdgSurface> QT_BEGIN_NAMESPACE @@ -52,24 +53,33 @@ QT_BEGIN_NAMESPACE // We mean it. // -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandQuickXdgSurfaceItemPrivate : public QWaylandQuickItemPrivate +namespace QtWayland { + +class XdgShellIntegration : public QWaylandQuickShellIntegration { + Q_OBJECT public: - enum GrabberState { - DefaultState, - ResizeState, - MoveState - }; + XdgShellIntegration(QWaylandQuickShellSurfaceItem *item); + bool mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + bool mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - QWaylandQuickXdgSurfaceItemPrivate() - : QWaylandQuickItemPrivate() - , xdgSurface(Q_NULLPTR) - , moveItem(Q_NULLPTR) - , grabberState(DefaultState) - {} +private Q_SLOTS: + void handleStartMove(QWaylandInputDevice *inputDevice); + void handleStartResize(QWaylandInputDevice *inputDevice, QWaylandXdgSurface::ResizeEdge edges); + void handleSetMaximized(); + void handleUnsetMaximized(); + void handleMaximizedChanged(); + void handleActivatedChanged(); + void handleSurfaceSizeChanged(); - QWaylandXdgSurface *xdgSurface; - QQuickItem *moveItem; +private: + enum class GrabberState { + Default, + Resize, + Move + }; + QWaylandQuickShellSurfaceItem *m_item; + QWaylandXdgSurface *m_xdgSurface; GrabberState grabberState; struct { @@ -94,6 +104,8 @@ public: } maximizeState; }; +} + QT_END_NAMESPACE -#endif /*QWAYLANDQUICKXDGSURFACEITEM_P_H*/ +#endif // QWAYLANDXDGSHELLINTEGRATION_H diff --git a/src/compositor/extensions/qwlextendedsurface.cpp b/src/compositor/extensions/qwlextendedsurface.cpp index f619ec33..fb89ebf3 100644 --- a/src/compositor/extensions/qwlextendedsurface.cpp +++ b/src/compositor/extensions/qwlextendedsurface.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE namespace QtWayland { SurfaceExtensionGlobal::SurfaceExtensionGlobal(QWaylandCompositor *compositor) - : QWaylandExtensionTemplate(compositor) + : QWaylandCompositorExtensionTemplate(compositor) , QtWaylandServer::qt_surface_extension(compositor->display(), 1) { } @@ -58,7 +58,7 @@ void SurfaceExtensionGlobal::surface_extension_get_extended_surface(Resource *re } ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, int version, QWaylandSurface *surface) - : QWaylandExtensionTemplate(surface) + : QWaylandCompositorExtensionTemplate(surface) , QtWaylandServer::qt_extended_surface(client, id, version) , m_surface(surface) , m_windowFlags(0) diff --git a/src/compositor/extensions/qwlextendedsurface_p.h b/src/compositor/extensions/qwlextendedsurface_p.h index 6ce1b426..a868cd83 100644 --- a/src/compositor/extensions/qwlextendedsurface_p.h +++ b/src/compositor/extensions/qwlextendedsurface_p.h @@ -52,7 +52,7 @@ #include <QtWaylandCompositor/private/qwayland-server-surface-extension.h> #include <QtWaylandCompositor/qwaylandsurface.h> -#include <QtWaylandCompositor/qwaylandextension.h> +#include <QtWaylandCompositor/qwaylandcompositorextension.h> #include <QtCore/QVariant> #include <QtCore/QLinkedList> @@ -67,7 +67,7 @@ namespace QtWayland { class ExtendedSurface; -class Q_WAYLAND_COMPOSITOR_EXPORT SurfaceExtensionGlobal : public QWaylandExtensionTemplate<SurfaceExtensionGlobal>, public QtWaylandServer::qt_surface_extension +class Q_WAYLAND_COMPOSITOR_EXPORT SurfaceExtensionGlobal : public QWaylandCompositorExtensionTemplate<SurfaceExtensionGlobal>, public QtWaylandServer::qt_surface_extension { Q_OBJECT public: @@ -83,7 +83,7 @@ private: }; -class Q_WAYLAND_COMPOSITOR_EXPORT ExtendedSurface : public QWaylandExtensionTemplate<ExtendedSurface>, public QtWaylandServer::qt_extended_surface +class Q_WAYLAND_COMPOSITOR_EXPORT ExtendedSurface : public QWaylandCompositorExtensionTemplate<ExtendedSurface>, public QtWaylandServer::qt_extended_surface { Q_OBJECT Q_PROPERTY(Qt::ScreenOrientations contentOrientationMask READ contentOrientationMask NOTIFY contentOrientationMaskChanged) diff --git a/src/compositor/extensions/qwlqtkey.cpp b/src/compositor/extensions/qwlqtkey.cpp index 52373df0..da8c19d7 100644 --- a/src/compositor/extensions/qwlqtkey.cpp +++ b/src/compositor/extensions/qwlqtkey.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE namespace QtWayland { QtKeyExtensionGlobal::QtKeyExtensionGlobal(QWaylandCompositor *compositor) - : QWaylandExtensionTemplate(compositor) + : QWaylandCompositorExtensionTemplate(compositor) , QtWaylandServer::qt_key_extension(compositor->display(), 2) , m_compositor(compositor) { diff --git a/src/compositor/extensions/qwlqtkey_p.h b/src/compositor/extensions/qwlqtkey_p.h index aebfab6e..1b9c7391 100644 --- a/src/compositor/extensions/qwlqtkey_p.h +++ b/src/compositor/extensions/qwlqtkey_p.h @@ -50,7 +50,7 @@ #include "wayland-util.h" -#include <QtWaylandCompositor/QWaylandExtensionTemplate> +#include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate> #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/private/qwayland-server-qtkey-extension.h> @@ -61,7 +61,7 @@ class QKeyEvent; namespace QtWayland { -class QtKeyExtensionGlobal : public QWaylandExtensionTemplate<QtKeyExtensionGlobal>, public QtWaylandServer::qt_key_extension +class QtKeyExtensionGlobal : public QWaylandCompositorExtensionTemplate<QtKeyExtensionGlobal>, public QtWaylandServer::qt_key_extension { Q_OBJECT public: diff --git a/src/compositor/extensions/qwlqttouch.cpp b/src/compositor/extensions/qwlqttouch.cpp index 70738ce2..17246b39 100644 --- a/src/compositor/extensions/qwlqttouch.cpp +++ b/src/compositor/extensions/qwlqttouch.cpp @@ -46,7 +46,7 @@ namespace QtWayland { static const int maxRawPos = 24; TouchExtensionGlobal::TouchExtensionGlobal(QWaylandCompositor *compositor) - : QWaylandExtensionTemplate(compositor) + : QWaylandCompositorExtensionTemplate(compositor) , QtWaylandServer::qt_touch_extension(compositor->display(), 1) , m_compositor(compositor) , m_flags(0) diff --git a/src/compositor/extensions/qwlqttouch_p.h b/src/compositor/extensions/qwlqttouch_p.h index e2daad63..32d7658f 100644 --- a/src/compositor/extensions/qwlqttouch_p.h +++ b/src/compositor/extensions/qwlqttouch_p.h @@ -50,7 +50,7 @@ #include <QtWaylandCompositor/private/qwayland-server-touch-extension.h> #include <QtWaylandCompositor/QWaylandCompositor> -#include <QtWaylandCompositor/QWaylandExtensionTemplate> +#include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate> #include "wayland-util.h" QT_BEGIN_NAMESPACE @@ -61,7 +61,7 @@ class QWaylandView; namespace QtWayland { -class TouchExtensionGlobal : public QWaylandExtensionTemplate<TouchExtensionGlobal>, public QtWaylandServer::qt_touch_extension +class TouchExtensionGlobal : public QWaylandCompositorExtensionTemplate<TouchExtensionGlobal>, public QtWaylandServer::qt_touch_extension { Q_OBJECT Q_PROPERTY(BehaviorFlags behaviorFlags READ behaviorFlags WRITE setBehviorFlags NOTIFY behaviorFlagsChanged) diff --git a/src/compositor/global/global.pri b/src/compositor/global/global.pri index 6edfd968..e48b8a8c 100644 --- a/src/compositor/global/global.pri +++ b/src/compositor/global/global.pri @@ -2,10 +2,10 @@ INCLUDEPATH += global/ HEADERS += \ global/qwaylandexport.h \ - global/qwaylandextension.h \ - global/qwaylandextension_p.h \ + global/qwaylandcompositorextension.h \ + global/qwaylandcompositorextension_p.h \ global/qwaylandquickextension.h \ SOURCES += \ - global/qwaylandextension.cpp + global/qwaylandcompositorextension.cpp diff --git a/src/compositor/global/qwaylandextension.cpp b/src/compositor/global/qwaylandcompositorextension.cpp index 4fee48df..ddfd2583 100644 --- a/src/compositor/global/qwaylandextension.cpp +++ b/src/compositor/global/qwaylandcompositorextension.cpp @@ -35,8 +35,8 @@ ****************************************************************************/ -#include "qwaylandextension.h" -#include "qwaylandextension_p.h" +#include "qwaylandcompositorextension.h" +#include "qwaylandcompositorextension_p.h" #include <QtCore/QCoreApplication> #include <QtCore/QDebug> @@ -45,59 +45,59 @@ QT_BEGIN_NAMESPACE -QWaylandExtension::QWaylandExtension() - : QWaylandObject(*new QWaylandExtensionPrivate()) +QWaylandCompositorExtension::QWaylandCompositorExtension() + : QWaylandObject(*new QWaylandCompositorExtensionPrivate()) { } -QWaylandExtension::QWaylandExtension(QWaylandObject *container) - : QWaylandObject(*new QWaylandExtensionPrivate()) +QWaylandCompositorExtension::QWaylandCompositorExtension(QWaylandObject *container) + : QWaylandObject(*new QWaylandCompositorExtensionPrivate()) { d_func()->extension_container = container; QCoreApplication::postEvent(this, new QEvent(QEvent::Polish)); } -QWaylandExtension::QWaylandExtension(QWaylandExtensionPrivate &dd) +QWaylandCompositorExtension::QWaylandCompositorExtension(QWaylandCompositorExtensionPrivate &dd) : QWaylandObject(dd) { } -QWaylandExtension::QWaylandExtension(QWaylandObject *container, QWaylandExtensionPrivate &dd) +QWaylandCompositorExtension::QWaylandCompositorExtension(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) : QWaylandObject(dd) { d_func()->extension_container = container; QCoreApplication::postEvent(this, new QEvent(QEvent::Polish)); } -QWaylandExtension::~QWaylandExtension() +QWaylandCompositorExtension::~QWaylandCompositorExtension() { - Q_D(QWaylandExtension); + Q_D(QWaylandCompositorExtension); if (d->extension_container) d->extension_container->removeExtension(this); } -QWaylandObject *QWaylandExtension::extensionContainer() const +QWaylandObject *QWaylandCompositorExtension::extensionContainer() const { - Q_D(const QWaylandExtension); + Q_D(const QWaylandCompositorExtension); return d->extension_container; } -void QWaylandExtension::setExtensionContainer(QWaylandObject *container) +void QWaylandCompositorExtension::setExtensionContainer(QWaylandObject *container) { - Q_D(QWaylandExtension); + Q_D(QWaylandCompositorExtension); d->extension_container = container; } -void QWaylandExtension::initialize() +void QWaylandCompositorExtension::initialize() { - Q_D(QWaylandExtension); + Q_D(QWaylandCompositorExtension); if (d->initialized) { - qWarning() << "QWaylandExtension:" << extensionInterface()->name << "is already initialized"; + qWarning() << "QWaylandCompositorExtension:" << extensionInterface()->name << "is already initialized"; return; } if (!d->extension_container) { - qWarning() << "QWaylandExtension:" << extensionInterface()->name << "requests to initialize with no extension container set"; + qWarning() << "QWaylandCompositorExtension:" << extensionInterface()->name << "requests to initialize with no extension container set"; return; } @@ -105,13 +105,13 @@ void QWaylandExtension::initialize() d->initialized = true; } -bool QWaylandExtension::isInitialized() const +bool QWaylandCompositorExtension::isInitialized() const { - Q_D(const QWaylandExtension); + Q_D(const QWaylandCompositorExtension); return d->initialized; } -bool QWaylandExtension::event(QEvent *event) +bool QWaylandCompositorExtension::event(QEvent *event) { switch(event->type()) { case QEvent::Polish: @@ -136,11 +136,11 @@ QWaylandObject::QWaylandObject(QObjectPrivate &d, QObject *parent) QWaylandObject::~QWaylandObject() { - foreach (QWaylandExtension *extension, extension_vector) - QWaylandExtensionPrivate::get(extension)->extension_container = Q_NULLPTR; + foreach (QWaylandCompositorExtension *extension, extension_vector) + QWaylandCompositorExtensionPrivate::get(extension)->extension_container = Q_NULLPTR; } -QWaylandExtension *QWaylandObject::extension(const QByteArray &name) +QWaylandCompositorExtension *QWaylandObject::extension(const QByteArray &name) { for (int i = 0; i < extension_vector.size(); i++) { if (extension_vector.at(i)->extensionInterface()->name == name) @@ -149,7 +149,7 @@ QWaylandExtension *QWaylandObject::extension(const QByteArray &name) return Q_NULLPTR; } -QWaylandExtension *QWaylandObject::extension(const wl_interface *interface) +QWaylandCompositorExtension *QWaylandObject::extension(const wl_interface *interface) { for (int i = 0; i < extension_vector.size(); i++) { if (extension_vector.at(i)->extensionInterface() == interface) @@ -158,18 +158,18 @@ QWaylandExtension *QWaylandObject::extension(const wl_interface *interface) return Q_NULLPTR; } -QList<QWaylandExtension *> QWaylandObject::extensions() const +QList<QWaylandCompositorExtension *> QWaylandObject::extensions() const { return extension_vector; } -void QWaylandObject::addExtension(QWaylandExtension *extension) +void QWaylandObject::addExtension(QWaylandCompositorExtension *extension) { Q_ASSERT(!extension_vector.contains(extension)); extension_vector.append(extension); } -void QWaylandObject::removeExtension(QWaylandExtension *extension) +void QWaylandObject::removeExtension(QWaylandCompositorExtension *extension) { Q_ASSERT(extension_vector.contains(extension)); extension_vector.removeOne(extension); diff --git a/src/compositor/global/qwaylandextension.h b/src/compositor/global/qwaylandcompositorextension.h index 7692aac8..762df2e8 100644 --- a/src/compositor/global/qwaylandextension.h +++ b/src/compositor/global/qwaylandcompositorextension.h @@ -47,35 +47,34 @@ struct wl_interface; QT_BEGIN_NAMESPACE class QWaylandCompositor; -class QWaylandExtension; -class QWaylandExtensionPrivate; -class QWaylandExtensionTemplatePrivate; +class QWaylandCompositorExtension; +class QWaylandCompositorExtensionPrivate; class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandObject : public QObject { public: virtual ~QWaylandObject(); - QWaylandExtension *extension(const QByteArray &name); - QWaylandExtension *extension(const wl_interface *interface); - QList<QWaylandExtension *> extensions() const; - void addExtension(QWaylandExtension *extension); - void removeExtension(QWaylandExtension *extension); + QWaylandCompositorExtension *extension(const QByteArray &name); + QWaylandCompositorExtension *extension(const wl_interface *interface); + QList<QWaylandCompositorExtension *> extensions() const; + void addExtension(QWaylandCompositorExtension *extension); + void removeExtension(QWaylandCompositorExtension *extension); protected: QWaylandObject(QObject *parent = 0); QWaylandObject(QObjectPrivate &d, QObject *parent = 0); - QList<QWaylandExtension *> extension_vector; + QList<QWaylandCompositorExtension *> extension_vector; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandExtension : public QWaylandObject +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorExtension : public QWaylandObject { Q_OBJECT - Q_DECLARE_PRIVATE(QWaylandExtension) + Q_DECLARE_PRIVATE(QWaylandCompositorExtension) public: - QWaylandExtension(); - QWaylandExtension(QWaylandObject *container); - virtual ~QWaylandExtension(); + QWaylandCompositorExtension(); + QWaylandCompositorExtension(QWaylandObject *container); + virtual ~QWaylandCompositorExtension(); QWaylandObject *extensionContainer() const; void setExtensionContainer(QWaylandObject *container); @@ -86,23 +85,22 @@ public: virtual const struct wl_interface *extensionInterface() const = 0; protected: - QWaylandExtension(QWaylandExtensionPrivate &dd); - QWaylandExtension(QWaylandObject *container, QWaylandExtensionPrivate &dd); + QWaylandCompositorExtension(QWaylandCompositorExtensionPrivate &dd); + QWaylandCompositorExtension(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd); bool event(QEvent *event) Q_DECL_OVERRIDE; }; template <typename T> -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandExtensionTemplate : public QWaylandExtension +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorExtensionTemplate : public QWaylandCompositorExtension { - Q_DECLARE_PRIVATE(QWaylandExtensionTemplate) public: - QWaylandExtensionTemplate() - : QWaylandExtension() + QWaylandCompositorExtensionTemplate() + : QWaylandCompositorExtension() { } - QWaylandExtensionTemplate(QWaylandObject *container) - : QWaylandExtension(container) + QWaylandCompositorExtensionTemplate(QWaylandObject *container) + : QWaylandCompositorExtension(container) { } const struct wl_interface *extensionInterface() const Q_DECL_OVERRIDE @@ -117,12 +115,12 @@ public: } protected: - QWaylandExtensionTemplate(QWaylandExtensionPrivate &dd) - : QWaylandExtension(dd) + QWaylandCompositorExtensionTemplate(QWaylandCompositorExtensionPrivate &dd) + : QWaylandCompositorExtension(dd) { } - QWaylandExtensionTemplate(QWaylandObject *container, QWaylandExtensionPrivate &dd) - : QWaylandExtension(container,dd) + QWaylandCompositorExtensionTemplate(QWaylandObject *container, QWaylandCompositorExtensionPrivate &dd) + : QWaylandCompositorExtension(container,dd) { } }; diff --git a/src/compositor/global/qwaylandextension_p.h b/src/compositor/global/qwaylandcompositorextension_p.h index 3aaf235c..a9a670d6 100644 --- a/src/compositor/global/qwaylandextension_p.h +++ b/src/compositor/global/qwaylandcompositorextension_p.h @@ -48,37 +48,29 @@ // We mean it. // -#include "qwaylandextension.h" +#include "qwaylandcompositorextension.h" #include <QtCore/private/qobject_p.h> QT_BEGIN_NAMESPACE -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandExtensionPrivate : public QObjectPrivate +class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandCompositorExtensionPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QWaylandExtension) + Q_DECLARE_PUBLIC(QWaylandCompositorExtension) public: - QWaylandExtensionPrivate() + QWaylandCompositorExtensionPrivate() : QObjectPrivate() , extension_container(Q_NULLPTR) , initialized(false) { } - static QWaylandExtensionPrivate *get(QWaylandExtension *extension) { return extension->d_func(); } + static QWaylandCompositorExtensionPrivate *get(QWaylandCompositorExtension *extension) { return extension->d_func(); } QWaylandObject *extension_container; bool initialized; }; -class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandExtensionTemplatePrivate : public QWaylandExtensionPrivate -{ -public: - QWaylandExtensionTemplatePrivate() - : QWaylandExtensionPrivate() - { } -}; - QT_END_NAMESPACE #endif /*QWAYLANDEXTENSION_P_H*/ diff --git a/src/compositor/global/qwaylandquickextension.h b/src/compositor/global/qwaylandquickextension.h index 64359ffa..32f4e652 100644 --- a/src/compositor/global/qwaylandquickextension.h +++ b/src/compositor/global/qwaylandquickextension.h @@ -37,7 +37,7 @@ #ifndef QWAYLANDQUICKEXTENSION_H #define QWAYLANDQUICKEXTENSION_H -#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtQml/QQmlParserStatus> #include <QtQml/QQmlListProperty> @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE { \ /* qmake ignore Q_OBJECT */ \ Q_OBJECT \ - Q_PROPERTY(QQmlListProperty<QWaylandExtension> extensions READ extensions) \ + Q_PROPERTY(QQmlListProperty<QWaylandCompositorExtension> extensions READ extensions) \ Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) \ Q_CLASSINFO("DefaultProperty", "data") \ public: \ @@ -74,28 +74,28 @@ QT_BEGIN_NAMESPACE { \ return QQmlListProperty<QObject>(this, m_objects); \ } \ - QQmlListProperty<QWaylandExtension> extensions() \ + QQmlListProperty<QWaylandCompositorExtension> extensions() \ { \ - return QQmlListProperty<QWaylandExtension>(this, this, \ + return QQmlListProperty<QWaylandCompositorExtension>(this, this, \ &className##QuickExtensionContainer::append_extension, \ &className##QuickExtensionContainer::countFunction, \ &className##QuickExtensionContainer::atFunction, \ &className##QuickExtensionContainer::clearFunction); \ } \ - static int countFunction(QQmlListProperty<QWaylandExtension> *list) \ + static int countFunction(QQmlListProperty<QWaylandCompositorExtension> *list) \ { \ return static_cast<className##QuickExtensionContainer *>(list->data)->extension_vector.size(); \ } \ - static QWaylandExtension *atFunction(QQmlListProperty<QWaylandExtension> *list, int index) \ + static QWaylandCompositorExtension *atFunction(QQmlListProperty<QWaylandCompositorExtension> *list, int index) \ { \ return static_cast<className##QuickExtensionContainer *>(list->data)->extension_vector.at(index); \ } \ - static void append_extension(QQmlListProperty<QWaylandExtension> *list, QWaylandExtension *extension) \ + static void append_extension(QQmlListProperty<QWaylandCompositorExtension> *list, QWaylandCompositorExtension *extension) \ { \ className##QuickExtensionContainer *quickExtObj = static_cast<className##QuickExtensionContainer *>(list->data); \ extension->setExtensionContainer(quickExtObj); \ } \ - static void clearFunction(QQmlListProperty<QWaylandExtension> *list) \ + static void clearFunction(QQmlListProperty<QWaylandCompositorExtension> *list) \ { \ static_cast<className##QuickExtensionContainer *>(list->data)->extension_vector.clear(); \ } \ diff --git a/src/compositor/hardware_integration/qwlclientbufferintegration_p.h b/src/compositor/hardware_integration/qwlclientbufferintegration_p.h index 1fbcb799..90762437 100644 --- a/src/compositor/hardware_integration/qwlclientbufferintegration_p.h +++ b/src/compositor/hardware_integration/qwlclientbufferintegration_p.h @@ -73,6 +73,7 @@ public: virtual void initializeBuffer(struct ::wl_resource *buffer) { Q_UNUSED(buffer); } virtual QWaylandBufferRef::BufferFormatEgl bufferFormat(struct ::wl_resource *buffer) { Q_UNUSED(buffer); return QWaylandBufferRef::BufferFormatEgl_RGBA; } + virtual uint textureForBuffer(struct ::wl_resource *buffer, int plane) { Q_UNUSED(buffer); Q_UNUSED(plane); return 0; } virtual void bindTextureToBuffer(struct ::wl_resource *buffer) = 0; virtual void updateTextureForBuffer(struct ::wl_resource *buffer) { Q_UNUSED(buffer); } diff --git a/src/compositor/hardware_integration/qwlhwintegration.cpp b/src/compositor/hardware_integration/qwlhwintegration.cpp index a163d4c2..7fb2c8b5 100644 --- a/src/compositor/hardware_integration/qwlhwintegration.cpp +++ b/src/compositor/hardware_integration/qwlhwintegration.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE namespace QtWayland { HardwareIntegration::HardwareIntegration(QWaylandCompositor *compositor) - : QWaylandExtensionTemplate<HardwareIntegration>(compositor) + : QWaylandCompositorExtensionTemplate<HardwareIntegration>(compositor) , qt_hardware_integration(compositor->display(), 1) { } diff --git a/src/compositor/hardware_integration/qwlhwintegration_p.h b/src/compositor/hardware_integration/qwlhwintegration_p.h index 2cc11a87..2cd368bc 100644 --- a/src/compositor/hardware_integration/qwlhwintegration_p.h +++ b/src/compositor/hardware_integration/qwlhwintegration_p.h @@ -50,7 +50,7 @@ #include <QtWaylandCompositor/private/qwayland-server-hardware-integration.h> -#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtCore/QString> @@ -60,7 +60,7 @@ class QWaylandCompositor; namespace QtWayland { -class HardwareIntegration : public QWaylandExtensionTemplate<HardwareIntegration>, public QtWaylandServer::qt_hardware_integration +class HardwareIntegration : public QWaylandCompositorExtensionTemplate<HardwareIntegration>, public QtWaylandServer::qt_hardware_integration { public: HardwareIntegration(QWaylandCompositor *compositor); diff --git a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp index 3aa55ce1..2f40b0e4 100644 --- a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp +++ b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp @@ -43,7 +43,7 @@ #include "qwldatadevice_p.h" #include "qwldatasource_p.h" #include "qwldataoffer_p.h" -#include "qwaylandmimehelper.h" +#include "qwaylandmimehelper_p.h" #include <QtCore/QDebug> #include <QtCore/QSocketNotifier> diff --git a/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp b/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp index c7bdbcee..240ce01b 100644 --- a/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp +++ b/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp @@ -44,7 +44,7 @@ #include <QtCore/QDebug> #include <wayland-server-protocol.h> -#include "qwaylandshmformathelper.h" +#include "qwaylandshmformathelper_p.h" #include <QtWaylandCompositor/private/qwaylandcompositor_p.h> @@ -232,6 +232,14 @@ void SurfaceBuffer::bindToTexture() const } } +uint SurfaceBuffer::textureForPlane(int plane) const +{ + if (QtWayland::ClientBufferIntegration *clientInt = QWaylandCompositorPrivate::get(m_compositor)->clientBufferIntegration()) + return clientInt->textureForBuffer(m_buffer, plane); + + return 0; +} + void SurfaceBuffer::updateTexture() const { if (QtWayland::ClientBufferIntegration *clientInt = QWaylandCompositorPrivate::get(m_compositor)->clientBufferIntegration()) diff --git a/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h b/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h index 85f78d41..95e7e815 100644 --- a/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h +++ b/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h @@ -106,6 +106,7 @@ public: QImage image() const; QWaylandBufferRef::BufferFormatEgl bufferFormatEgl() const; void bindToTexture() const; + uint textureForPlane(int plane) const; void updateTexture() const; static bool hasContent(SurfaceBuffer *buffer) { return buffer && buffer->waylandBufferHandle(); } diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri index 91ccbe1f..f338ddc0 100644 --- a/src/compositor/wayland_wrapper/wayland_wrapper.pri +++ b/src/compositor/wayland_wrapper/wayland_wrapper.pri @@ -9,7 +9,7 @@ HEADERS += \ wayland_wrapper/qwldatasource_p.h \ wayland_wrapper/qwlregion_p.h \ wayland_wrapper/qwlsurfacebuffer_p.h \ - ../shared/qwaylandxkb.h \ + ../shared/qwaylandxkb_p.h \ SOURCES += \ wayland_wrapper/qwldatadevice.cpp \ diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp index e6b68225..1c009d34 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp @@ -117,6 +117,7 @@ struct BufferState EGLint egl_format; QVarLengthArray<EGLImageKHR, 3> egl_images; EGLStreamKHR egl_stream; + GLuint eglstream_texture; bool isYInverted; QSize size; @@ -167,6 +168,7 @@ struct buffer_destroy_listener : wl_listener BufferState::BufferState() : egl_format(EGL_TEXTURE_RGBA) , egl_stream(EGL_NO_STREAM_KHR) + , eglstream_texture(0) , isYInverted(true) {} @@ -269,7 +271,21 @@ void WaylandEglClientBufferIntegrationPrivate::attach_egl_fd_texture(struct ::wl return; } + if (!QOpenGLContext::currentContext()) + qWarning("EglClientBufferIntegration: creating texture with no current context"); + + //TODO This texture might end up in a different context than the quick item which wants to use it, this needs to be fixed somehow. + glGenTextures(1, &state.eglstream_texture); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_EXTERNAL_OES, state.eglstream_texture); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + register_buffer(buffer, state); + + bindBuffer(buffer); } void WaylandEglClientBufferIntegrationPrivate::register_buffer(struct ::wl_resource *buffer, BufferState state) @@ -301,8 +317,12 @@ void WaylandEglClientBufferIntegrationPrivate::bindBuffer(struct ::wl_resource * const BufferState state = buffers.value(buffer); if (state.egl_stream != EGL_NO_STREAM_KHR) { - if (funcs->stream_consumer_gltexture(egl_display, state.egl_stream) != EGL_TRUE) - qWarning("%s:%d: eglStreamConsumerGLTextureExternalKHR failed: 0x%x", Q_FUNC_INFO, __LINE__, eglGetError()); + EGLint stream_state; + funcs->query_stream(egl_display, state.egl_stream, EGL_STREAM_STATE_KHR, &stream_state); + + if (stream_state == EGL_STREAM_STATE_CREATED_KHR) + if (funcs->stream_consumer_gltexture(egl_display, state.egl_stream) != EGL_TRUE) + qWarning("%s:%d: eglStreamConsumerGLTextureExternalKHR failed: 0x%x", Q_FUNC_INFO, __LINE__, eglGetError()); } else { GLint previousTexture = GL_TEXTURE0; glGetIntegerv(GL_ACTIVE_TEXTURE, &previousTexture); @@ -340,6 +360,11 @@ void WaylandEglClientBufferIntegrationPrivate::handle_buffer_destroy(wl_listener BufferState state = self->buffers.take(buffer); + /* TODO This texture shouldn't get deleted here as the compositor might want to show an transition. But at the same time we need to make sure + that the texture is deleted properly although if the compositor didn't use it (e.g. by creating a quick item)*/ + if (state.eglstream_texture) + glDeleteTextures(1, &state.eglstream_texture); + for (int i = 0; i < state.egl_images.size(); i++) self->egl_destroy_image(self->egl_display, state.egl_images[i]); @@ -453,6 +478,17 @@ QWaylandBufferRef::BufferFormatEgl WaylandEglClientBufferIntegration::bufferForm return formatFromEglFormat(d->buffers.value(buffer).egl_format); } +uint WaylandEglClientBufferIntegration::textureForBuffer(wl_resource *buffer, int plane) +{ + Q_UNUSED(plane) + Q_D(WaylandEglClientBufferIntegration); + if (!buffer) + return 0; + + const BufferState state = d->buffers.value(buffer); + return state.eglstream_texture; +} + void WaylandEglClientBufferIntegration::bindTextureToBuffer(struct ::wl_resource *buffer) { Q_D(WaylandEglClientBufferIntegration); @@ -475,8 +511,15 @@ void WaylandEglClientBufferIntegration::updateTextureForBuffer(struct ::wl_resou const BufferState state = d->buffers.value(buffer); - if (state.egl_stream != EGL_NO_STREAM_KHR) - d->funcs->stream_consumer_acquire(d->egl_display, state.egl_stream); + if (state.egl_stream != EGL_NO_STREAM_KHR) { + EGLint stream_state; + d->funcs->query_stream(d->egl_display, state.egl_stream, EGL_STREAM_STATE_KHR, &stream_state); + + if (stream_state == EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR) { + if (d->funcs->stream_consumer_acquire(d->egl_display, state.egl_stream) != EGL_TRUE) + qWarning("%s:%d: eglStreamConsumerAcquireKHR failed: 0x%x", Q_FUNC_INFO, __LINE__, eglGetError()); + } + } } QWaylandSurface::Origin WaylandEglClientBufferIntegration::origin(struct ::wl_resource *buffer) const diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h index 57e83717..74cad708 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h @@ -54,6 +54,7 @@ public: void initializeBuffer(struct ::wl_resource *buffer) Q_DECL_OVERRIDE; QWaylandBufferRef::BufferFormatEgl bufferFormat(struct ::wl_resource *buffer) Q_DECL_OVERRIDE; + uint textureForBuffer(struct ::wl_resource *buffer, int plane) Q_DECL_OVERRIDE; void bindTextureToBuffer(struct ::wl_resource *buffer) Q_DECL_OVERRIDE; void updateTextureForBuffer(struct ::wl_resource *buffer) Q_DECL_OVERRIDE; diff --git a/src/imports/compositor/plugins.qmltypes b/src/imports/compositor/plugins.qmltypes index f73f9660..54b3bfcc 100644 --- a/src/imports/compositor/plugins.qmltypes +++ b/src/imports/compositor/plugins.qmltypes @@ -80,7 +80,7 @@ Module { } } Component { - name: "QWaylandExtension" + name: "QWaylandCompositorExtension" prototype: "QObject" exports: ["QtWayland.Compositor/WaylandExtension 1.0"] isCreatable: false @@ -178,7 +178,7 @@ Module { prototype: "QWaylandQuickCompositor" exports: ["QtWayland.Compositor/WaylandCompositor 1.0"] exportMetaObjectRevisions: [0] - Property { name: "extensions"; type: "QWaylandExtension"; isList: true; isReadonly: true } + Property { name: "extensions"; type: "QWaylandCompositorExtension"; isList: true; isReadonly: true } Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } } Component { @@ -230,6 +230,14 @@ Module { Method { name: "updateStarted" } } Component { + name: "QWaylandQuickShellSurfaceItem" + defaultProperty: "data" + prototype: "QWaylandQuickItem" + exports: ["QtWayland.Compositor/ShellSurfaceItem 1.0"] + exportMetaObjectRevisions: [0] + Property { name: "shellSurface"; type: "QWaylandShellSurface"; isPointer: true } + } + Component { name: "QWaylandQuickSurface" prototype: "QWaylandSurface" exports: ["QtWayland.Compositor/WaylandSurface 1.0"] @@ -238,26 +246,15 @@ Module { Property { name: "clientRenderingEnabled"; type: "bool" } } Component { - name: "QWaylandQuickWlShellSurfaceItem" - defaultProperty: "data" - prototype: "QWaylandQuickItem" - exports: ["QtWayland.Compositor/WlShellSurfaceItem 1.0"] - exportMetaObjectRevisions: [0] - Property { name: "shellSurface"; type: "QWaylandWlShellSurface"; isPointer: true } - Property { name: "moveItem"; type: "QQuickItem"; isPointer: true } - } - Component { - name: "QWaylandQuickXdgSurfaceItem" - defaultProperty: "data" - prototype: "QWaylandQuickItem" - exports: ["QtWayland.Compositor/XdgSurfaceItem 1.0"] + name: "QWaylandResource" + exports: ["QtWayland.Compositor/WaylandResource 1.0"] + isCreatable: false exportMetaObjectRevisions: [0] - Property { name: "xdgSurface"; type: "QWaylandXdgSurface"; isPointer: true } - Property { name: "moveItem"; type: "QQuickItem"; isPointer: true } } Component { - name: "QWaylandResource" - exports: ["QtWayland.Compositor/WaylandResource 1.0"] + name: "QWaylandShellSurface" + prototype: "QWaylandCompositorExtension" + exports: ["QtWayland.Compositor/ShellSurface 1.0"] isCreatable: false exportMetaObjectRevisions: [0] } @@ -329,7 +326,7 @@ Module { Method { name: "frameStarted" } Method { name: "sendFrameCallbacks" } } - Component { name: "QWaylandTextInputManager"; prototype: "QWaylandExtension" } + Component { name: "QWaylandTextInputManager"; prototype: "QWaylandCompositorExtension" } Component { name: "QWaylandTextInputManagerQuickExtension" defaultProperty: "data" @@ -353,7 +350,7 @@ Module { } Component { name: "QWaylandWindowManagerExtension" - prototype: "QWaylandExtension" + prototype: "QWaylandCompositorExtension" Property { name: "showIsFullScreen"; type: "bool" } Signal { name: "openUrl" @@ -371,7 +368,7 @@ Module { } Component { name: "QWaylandWlShell" - prototype: "QWaylandExtension" + prototype: "QWaylandCompositorExtension" Signal { name: "createShellSurface" Parameter { name: "surface"; type: "QWaylandSurface"; isPointer: true } @@ -392,7 +389,7 @@ Module { } Component { name: "QWaylandWlShellSurface" - prototype: "QWaylandExtension" + prototype: "QWaylandShellSurface" exports: [ "QtWayland.Compositor/WlShellSurface 1.0", "QtWayland.Compositor/WlShellSurfaceBase 1.0" @@ -489,7 +486,7 @@ Module { } Component { name: "QWaylandXdgShell" - prototype: "QWaylandExtension" + prototype: "QWaylandCompositorExtension" Signal { name: "createXdgSurface" Parameter { name: "surface"; type: "QWaylandSurface"; isPointer: true } @@ -532,7 +529,7 @@ Module { } Component { name: "QWaylandXdgSurface" - prototype: "QWaylandExtension" + prototype: "QWaylandShellSurface" exports: [ "QtWayland.Compositor/XdgSurface 1.0", "QtWayland.Compositor/XdgSurfaceBase 1.0" diff --git a/src/imports/compositor/qwaylandmousetracker.cpp b/src/imports/compositor/qwaylandmousetracker.cpp index fd6a591e..a77d6b1a 100644 --- a/src/imports/compositor/qwaylandmousetracker.cpp +++ b/src/imports/compositor/qwaylandmousetracker.cpp @@ -46,6 +46,7 @@ class QWaylandMouseTrackerPrivate : public QQuickItemPrivate public: QWaylandMouseTrackerPrivate() : enableWSCursor(false) + , hovered(false) { QImage cursorImage(64,64,QImage::Format_ARGB32); cursorImage.fill(Qt::transparent); @@ -65,9 +66,19 @@ public: } } + void setHovered(bool hovered) + { + Q_Q(QWaylandMouseTracker); + if (this->hovered == hovered) + return; + this->hovered = hovered; + emit q->hoveredChanged(); + } + QPointF mousePos; bool enableWSCursor; QPixmap cursorPixmap; + bool hovered; }; QWaylandMouseTracker::QWaylandMouseTracker(QQuickItem *parent) @@ -76,6 +87,7 @@ QWaylandMouseTracker::QWaylandMouseTracker(QQuickItem *parent) Q_D(QWaylandMouseTracker); setFiltersChildMouseEvents(true); setAcceptHoverEvents(true); + setAcceptedMouseButtons(Qt::AllButtons); setCursor(QCursor(d->cursorPixmap)); } @@ -110,6 +122,12 @@ bool QWaylandMouseTracker::enableWSCursor() const return d->enableWSCursor; } +bool QWaylandMouseTracker::hovered() const +{ + Q_D(const QWaylandMouseTracker); + return d->hovered; +} + bool QWaylandMouseTracker::childMouseEventFilter(QQuickItem *item, QEvent *event) { Q_D(QWaylandMouseTracker); @@ -137,4 +155,18 @@ void QWaylandMouseTracker::hoverMoveEvent(QHoverEvent *event) d->handleMousePos(event->posF()); } +void QWaylandMouseTracker::hoverEnterEvent(QHoverEvent *event) +{ + Q_D(QWaylandMouseTracker); + Q_UNUSED(event); + d->setHovered(true); +} + +void QWaylandMouseTracker::hoverLeaveEvent(QHoverEvent *event) +{ + Q_D(QWaylandMouseTracker); + Q_UNUSED(event); + d->setHovered(false); +} + QT_END_NAMESPACE diff --git a/src/imports/compositor/qwaylandmousetracker_p.h b/src/imports/compositor/qwaylandmousetracker_p.h index 2cc8798b..1bc37a5e 100644 --- a/src/imports/compositor/qwaylandmousetracker_p.h +++ b/src/imports/compositor/qwaylandmousetracker_p.h @@ -51,6 +51,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandMouseTracker : public QQuickItem Q_DECLARE_PRIVATE(QWaylandMouseTracker) Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mouseXChanged) Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mouseYChanged) + Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged) Q_PROPERTY(bool enableWSCursor READ enableWSCursor WRITE setEnableWSCursor NOTIFY enableWSCursorChanged) public: @@ -61,15 +62,20 @@ public: void setEnableWSCursor(bool enable); bool enableWSCursor() const; + bool hovered() const; + signals: void mouseXChanged(); void mouseYChanged(); void enableWSCursorChanged(); + void hoveredChanged(); protected: bool childMouseEventFilter(QQuickItem *item, QEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; }; QT_END_NAMESPACE diff --git a/src/imports/compositor/qwaylandquickcompositorplugin.cpp b/src/imports/compositor/qwaylandquickcompositorplugin.cpp index ae4f874d..6f00351c 100644 --- a/src/imports/compositor/qwaylandquickcompositorplugin.cpp +++ b/src/imports/compositor/qwaylandquickcompositorplugin.cpp @@ -44,11 +44,10 @@ #include <QtWaylandCompositor/QWaylandQuickSurface> #include <QtWaylandCompositor/QWaylandClient> #include <QtWaylandCompositor/QWaylandQuickOutput> -#include <QtWaylandCompositor/QWaylandExtension> +#include <QtWaylandCompositor/QWaylandCompositorExtension> #include <QtWaylandCompositor/QWaylandQuickExtension> #include <QtWaylandCompositor/QWaylandInputDevice> -#include <QtWaylandCompositor/QWaylandQuickWlShellSurfaceItem> -#include <QtWaylandCompositor/QWaylandQuickXdgSurfaceItem> +#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem> #include <QtWaylandCompositor/QWaylandResource> #include <QtWaylandCompositor/QWaylandWindowManagerExtension> @@ -135,12 +134,13 @@ public: qmlRegisterType<QWaylandQuickOutput>(uri, 1, 0, "WaylandOutput"); qmlRegisterType<QWaylandQuickSurface>(uri, 1, 0, "WaylandSurface"); - qmlRegisterUncreatableType<QWaylandExtension>(uri, 1, 0, "WaylandExtension", QObject::tr("Cannot create instance of WaylandExtension")); + qmlRegisterUncreatableType<QWaylandCompositorExtension>(uri, 1, 0, "WaylandExtension", QObject::tr("Cannot create instance of WaylandExtension")); qmlRegisterUncreatableType<QWaylandClient>(uri, 1, 0, "WaylandClient", QObject::tr("Cannot create instance of WaylandClient")); qmlRegisterUncreatableType<QWaylandView>(uri, 1, 0, "WaylandView", QObject::tr("Cannot create instance of WaylandView, it can be retrieved by accessor on WaylandQuickItem")); qmlRegisterUncreatableType<QWaylandInputDevice>(uri, 1, 0, "WaylandInputDevice", QObject::tr("Cannot create instance of WaylandInputDevice")); qmlRegisterUncreatableType<QWaylandCompositor>(uri, 1, 0, "WaylandCompositorBase", QObject::tr("Cannot create instance of WaylandCompositorBase, use WaylandCompositor instead")); qmlRegisterUncreatableType<QWaylandSurface>(uri, 1, 0, "WaylandSurfaceBase", QObject::tr("Cannot create instance of WaylandSurfaceBase, use WaylandSurface instead")); + qmlRegisterUncreatableType<QWaylandShellSurface>(uri, 1, 0, "ShellSurface", QObject::tr("Cannot create instance of ShellSurface")); qmlRegisterUncreatableType<QWaylandWlShellSurface>(uri, 1, 0, "WlShellSurfaceBase", QObject::tr("Cannot create instance of WlShellSurfaceBase, use WlShellSurface instead")); qmlRegisterUncreatableType<QWaylandXdgSurface>(uri, 1, 0, "XdgSurfaceBase", QObject::tr("Cannot create instance of XdgSurfaceBase, use XdgSurface instead")); qmlRegisterUncreatableType<QWaylandResource>(uri, 1, 0, "WaylandResource", QObject::tr("Cannot create instance of WaylandResource")); @@ -149,10 +149,9 @@ public: qmlRegisterType<QWaylandWindowManagerExtensionQuickExtension>(uri, 1, 0, "WindowManager"); qmlRegisterType<QWaylandWlShellQuickExtension>(uri, 1, 0, "WlShell"); qmlRegisterType<QWaylandWlShellSurface>(uri, 1, 0, "WlShellSurface"); - qmlRegisterType<QWaylandQuickWlShellSurfaceItem>(uri, 1, 0, "WlShellSurfaceItem"); + qmlRegisterType<QWaylandQuickShellSurfaceItem>(uri, 1, 0, "ShellSurfaceItem"); qmlRegisterType<QWaylandXdgShellQuickExtension>(uri, 1, 0, "XdgShell"); qmlRegisterType<QWaylandXdgSurface>(uri, 1, 0, "XdgSurface"); - qmlRegisterType<QWaylandQuickXdgSurfaceItem>(uri, 1, 0, "XdgSurfaceItem"); qmlRegisterType<QWaylandTextInputManagerQuickExtension>(uri, 1, 0, "TextInputManager"); } }; diff --git a/src/shared/qwaylandinputmethodeventbuilder.cpp b/src/shared/qwaylandinputmethodeventbuilder.cpp index fe93f514..0e2d1a40 100644 --- a/src/shared/qwaylandinputmethodeventbuilder.cpp +++ b/src/shared/qwaylandinputmethodeventbuilder.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include "qwaylandinputmethodeventbuilder.h" +#include "qwaylandinputmethodeventbuilder_p.h" #include <QInputMethod> #include <QTextCharFormat> diff --git a/src/shared/qwaylandinputmethodeventbuilder.h b/src/shared/qwaylandinputmethodeventbuilder_p.h index 3912afc0..3912afc0 100644 --- a/src/shared/qwaylandinputmethodeventbuilder.h +++ b/src/shared/qwaylandinputmethodeventbuilder_p.h diff --git a/src/shared/qwaylandmimehelper.cpp b/src/shared/qwaylandmimehelper.cpp index c223efbe..a5fdd34d 100644 --- a/src/shared/qwaylandmimehelper.cpp +++ b/src/shared/qwaylandmimehelper.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include "qwaylandmimehelper.h" +#include "qwaylandmimehelper_p.h" #include <QImage> #include <QColor> #include <QUrl> diff --git a/src/shared/qwaylandmimehelper.h b/src/shared/qwaylandmimehelper_p.h index 80487705..80487705 100644 --- a/src/shared/qwaylandmimehelper.h +++ b/src/shared/qwaylandmimehelper_p.h diff --git a/src/shared/qwaylandshmformathelper.h b/src/shared/qwaylandshmformathelper_p.h index 58db42e2..58db42e2 100644 --- a/src/shared/qwaylandshmformathelper.h +++ b/src/shared/qwaylandshmformathelper_p.h diff --git a/src/shared/qwaylandxkb.cpp b/src/shared/qwaylandxkb.cpp index 32d24bd6..49925700 100644 --- a/src/shared/qwaylandxkb.cpp +++ b/src/shared/qwaylandxkb.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include "qwaylandxkb.h" +#include "qwaylandxkb_p.h" #include <QKeyEvent> #include <QString> diff --git a/src/shared/qwaylandxkb.h b/src/shared/qwaylandxkb_p.h index 9b5c935a..9b5c935a 100644 --- a/src/shared/qwaylandxkb.h +++ b/src/shared/qwaylandxkb_p.h |