summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-08-13 16:18:47 +0200
committerPaul Olav Tvete <paul.tvete@qt.io>2018-08-17 14:41:05 +0000
commit845839b971f6af017be77dbe1ee1541453d12c23 (patch)
tree4289e0aa931cf95586e088620bb508b17f5e26f9 /examples
parent53d7bffef7fd7f2e1026ac54e5c8bdb3df761208 (diff)
Compositor API: Add xdg-decoration unstable v1 support
And add an example with server-side window decorations. Task-number: QTBUG-69934 Change-Id: Ic3984b50cf7574cae5135dea51eb4b1c80bb45a7 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/wayland/server-side-decoration/doc/src/server-side-decoration.qdoc36
-rw-r--r--examples/wayland/server-side-decoration/main.cpp68
-rw-r--r--examples/wayland/server-side-decoration/main.qml103
-rw-r--r--examples/wayland/server-side-decoration/server-side-decoration.pro14
-rw-r--r--examples/wayland/server-side-decoration/server-side-decoration.qrc5
-rw-r--r--examples/wayland/wayland.pro1
6 files changed, 227 insertions, 0 deletions
diff --git a/examples/wayland/server-side-decoration/doc/src/server-side-decoration.qdoc b/examples/wayland/server-side-decoration/doc/src/server-side-decoration.qdoc
new file mode 100644
index 000000000..7032152d1
--- /dev/null
+++ b/examples/wayland/server-side-decoration/doc/src/server-side-decoration.qdoc
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ * \title Qt Wayland Compositor Examples - Sever Side Decoration Compositor
+ * \example server-side-decoration
+ * \brief Server Side Decoration Compositor is a simple example that demonstrates server side window decorations on xdg-shell.
+ * \ingroup qtwaylandcompositor-examples
+ *
+ * Server Side Decoration Compositor is a desktop-style Wayland compositor example implementing
+ * server-side window decorations.
+ */
diff --git a/examples/wayland/server-side-decoration/main.cpp b/examples/wayland/server-side-decoration/main.cpp
new file mode 100644
index 000000000..e765fafb6
--- /dev/null
+++ b/examples/wayland/server-side-decoration/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QUrl>
+#include <QtCore/QDebug>
+
+#include <QtGui/QGuiApplication>
+
+#include <QtQml/QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ // ShareOpenGLContexts is needed for using the threaded renderer
+ // on Nvidia EGLStreams
+ QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine appEngine(QUrl("qrc:///main.qml"));
+
+ return app.exec();
+}
diff --git a/examples/wayland/server-side-decoration/main.qml b/examples/wayland/server-side-decoration/main.qml
new file mode 100644
index 000000000..8ec50dd57
--- /dev/null
+++ b/examples/wayland/server-side-decoration/main.qml
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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.6
+import QtQuick.Window 2.2
+import QtQuick.Layouts 1.3
+import QtWayland.Compositor 1.3
+
+WaylandCompositor {
+ // The output defines the screen.
+ WaylandOutput {
+ sizeFollowsWindow: true
+ window: Window {
+ width: 1024
+ height: 768
+ visible: true
+ Repeater {
+ model: shellSurfaces
+ Column {
+ Rectangle {
+ visible: modelData.toplevel.decorationMode === XdgToplevel.ServerSideDecoration
+ width: parent.width
+ height: 30
+ gradient: "HeavyRain";
+ RowLayout {
+ anchors.fill: parent
+ Text {
+ text: modelData.toplevel.title
+ Layout.fillWidth: true
+ }
+ MouseArea {
+ width: 30
+ height: 30
+ Text { text: "X"; anchors.centerIn: parent }
+ onClicked: modelData.toplevel.sendClose()
+ }
+ }
+ }
+ ShellSurfaceItem {
+ moveItem: parent
+ autoCreatePopupItems: true
+ shellSurface: modelData
+ onSurfaceDestroyed: shellSurfaces.remove(index)
+ }
+ }
+ }
+ }
+ }
+ XdgShell {
+ onToplevelCreated: shellSurfaces.append({shellSurface: xdgSurface});
+ }
+ XdgDecorationManagerV1 {
+ preferredMode: XdgToplevel.ServerSideDecoration
+ }
+ ListModel { id: shellSurfaces }
+}
diff --git a/examples/wayland/server-side-decoration/server-side-decoration.pro b/examples/wayland/server-side-decoration/server-side-decoration.pro
new file mode 100644
index 000000000..e6a5cd20a
--- /dev/null
+++ b/examples/wayland/server-side-decoration/server-side-decoration.pro
@@ -0,0 +1,14 @@
+QT += gui qml
+
+SOURCES += \
+ main.cpp
+
+OTHER_FILES = \
+ main.qml
+
+RESOURCES += server-side-decoration.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/wayland/server-side-decoration
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS server-side-decoration.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/wayland/server-side-decoration
+INSTALLS += target sources
diff --git a/examples/wayland/server-side-decoration/server-side-decoration.qrc b/examples/wayland/server-side-decoration/server-side-decoration.qrc
new file mode 100644
index 000000000..5f6483ac3
--- /dev/null
+++ b/examples/wayland/server-side-decoration/server-side-decoration.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/wayland/wayland.pro b/examples/wayland/wayland.pro
index 0cb050cca..b9e4263e7 100644
--- a/examples/wayland/wayland.pro
+++ b/examples/wayland/wayland.pro
@@ -14,6 +14,7 @@ qtHaveModule(quick) {
SUBDIRS += multi-screen
SUBDIRS += overview-compositor
SUBDIRS += ivi-compositor
+ SUBDIRS += server-side-decoration
qtHaveModule(waylandclient) {
SUBDIRS += \
custom-extension \