diff options
author | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2015-12-02 14:00:44 +0100 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2015-12-02 14:01:08 +0100 |
commit | 05bf419b206f3cd078364cf67af2df4e4d1477c0 (patch) | |
tree | c942e884e8f75a29bd9f281c993fbc85a0b832ed /examples/wayland/multi-output | |
parent | dd5e1ffd3e9e379574325193c8546d453c11303e (diff) | |
parent | 3698b116a1973146b76319673cdb6787f13f2de6 (diff) |
Merge branch 'wip-compositor-api' into dev
This introduces the new compositor API, removing the
old API (which was never officially supported).
Change-Id: I1dc01f0fb4edc749e34ed8356e56ad87d7d64913
Diffstat (limited to 'examples/wayland/multi-output')
-rw-r--r-- | examples/wayland/multi-output/doc/src/multi-output.qdoc | 41 | ||||
-rw-r--r-- | examples/wayland/multi-output/images/background.jpg | bin | 0 -> 30730 bytes | |||
-rw-r--r-- | examples/wayland/multi-output/main.cpp | 55 | ||||
-rw-r--r-- | examples/wayland/multi-output/multi-output.pro | 16 | ||||
-rw-r--r-- | examples/wayland/multi-output/multi-output.qrc | 9 | ||||
-rw-r--r-- | examples/wayland/multi-output/qml/GridScreen.qml | 85 | ||||
-rw-r--r-- | examples/wayland/multi-output/qml/ShellChrome.qml | 73 | ||||
-rw-r--r-- | examples/wayland/multi-output/qml/ShellScreen.qml | 76 | ||||
-rw-r--r-- | examples/wayland/multi-output/qml/main.qml | 104 |
9 files changed, 459 insertions, 0 deletions
diff --git a/examples/wayland/multi-output/doc/src/multi-output.qdoc b/examples/wayland/multi-output/doc/src/multi-output.qdoc new file mode 100644 index 000000000..32b9aa696 --- /dev/null +++ b/examples/wayland/multi-output/doc/src/multi-output.qdoc @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \title Qt Wayland Compositor Examples - Multi Output + \example multi-output + \brief Multi Output is an example that demonstrates a compositor with multiple outputs. + \ingroup qtwaylandcompositor-examples + + Multi Output demonstrates how to display the same clients on different + \l{WaylandOutput}{WaylandOutputs} with different types of composition. + + The example opens two different windows, one for each output. When a client connects, its + WaylandSurface is displayed in a GridView on one of the outputs, while a ShellSurface + associated with the WaylandSurface is displayed with desktop-style composition on + the other output. +*/ diff --git a/examples/wayland/multi-output/images/background.jpg b/examples/wayland/multi-output/images/background.jpg Binary files differnew file mode 100644 index 000000000..445567fbd --- /dev/null +++ b/examples/wayland/multi-output/images/background.jpg diff --git a/examples/wayland/multi-output/main.cpp b/examples/wayland/multi-output/main.cpp new file mode 100644 index 000000000..7ee6779d0 --- /dev/null +++ b/examples/wayland/multi-output/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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$ +** +****************************************************************************/ + +#include <QtCore/QUrl> +#include <QtCore/QDebug> + +#include <QtGui/QGuiApplication> + +#include <QtQml/QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine appEngine(QUrl("qrc:///qml/main.qml")); + + return app.exec(); +} diff --git a/examples/wayland/multi-output/multi-output.pro b/examples/wayland/multi-output/multi-output.pro new file mode 100644 index 000000000..468dc2e09 --- /dev/null +++ b/examples/wayland/multi-output/multi-output.pro @@ -0,0 +1,16 @@ +QT += core gui qml + +SOURCES += \ + main.cpp + +OTHER_FILES = \ + qml/main.qml \ + qml/GridScreen.qml \ + qml/ShellScreen.qml \ + qml/ShellChrome.qml \ + images/background.jpg \ + +RESOURCES += multi-output.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/wayland/multi-output +INSTALLS += target diff --git a/examples/wayland/multi-output/multi-output.qrc b/examples/wayland/multi-output/multi-output.qrc new file mode 100644 index 000000000..86df88177 --- /dev/null +++ b/examples/wayland/multi-output/multi-output.qrc @@ -0,0 +1,9 @@ +<RCC> + <qresource prefix="/"> + <file>images/background.jpg</file> + <file>qml/main.qml</file> + <file>qml/GridScreen.qml</file> + <file>qml/ShellScreen.qml</file> + <file>qml/ShellChrome.qml</file> + </qresource> +</RCC> diff --git a/examples/wayland/multi-output/qml/GridScreen.qml b/examples/wayland/multi-output/qml/GridScreen.qml new file mode 100644 index 000000000..6b1d574cd --- /dev/null +++ b/examples/wayland/multi-output/qml/GridScreen.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 QtQuick.Window 2.2 +import QtWayland.Compositor 1.0 + +WaylandOutput { + id: output + property alias gridSurfaces: listModel + + window: Window { + width: 1024 + height: 760 + visible: true + + Image { + id: background + anchors.fill: parent + fillMode: Image.Tile + source: "qrc:/images/background.jpg" + smooth: true + GridView { + id: gridView + anchors.fill: parent + model: ListModel { + id: listModel + } + interactive: false + cellWidth: 200 + cellHeight: 200 + delegate: WaylandQuickItem { + id: item + surface: gridSurface + width: gridView.cellWidth + height: gridView.cellHeight + sizeFollowsSurface: false + inputEventsEnabled: false + view.discardFrontBuffers: true + MouseArea { + anchors.fill: parent + onClicked: item.surface.activated() + } + } + } + } + } +} diff --git a/examples/wayland/multi-output/qml/ShellChrome.qml b/examples/wayland/multi-output/qml/ShellChrome.qml new file mode 100644 index 000000000..83f883dac --- /dev/null +++ b/examples/wayland/multi-output/qml/ShellChrome.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 + +ShellSurfaceItem { + id: rootChrome + + shellSurface: ShellSurface { + } + + onSurfaceDestroyed: { + view.bufferLock = true; + destroyAnimation.start(); + } + + 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/multi-output/qml/ShellScreen.qml b/examples/wayland/multi-output/qml/ShellScreen.qml new file mode 100644 index 000000000..77fbeb828 --- /dev/null +++ b/examples/wayland/multi-output/qml/ShellScreen.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 QtQuick.Window 2.2 +import QtWayland.Compositor 1.0 + +WaylandOutput { + id: output + property alias surfaceArea: background + + window: Window { + width: 1024 + height: 760 + visible: true + + WaylandMouseTracker { + id: mouseTracker + anchors.fill: parent + + enableWSCursor: true + Image { + id: background + anchors.fill: parent + fillMode: Image.Tile + source: "qrc:/images/background.jpg" + smooth: true + } + WaylandCursorItem { + id: cursor + inputEventsEnabled: false + x: mouseTracker.mouseX - hotspotX + y: mouseTracker.mouseY - hotspotY + + inputDevice : output.compositor.defaultInputDevice + } + } + } +} diff --git a/examples/wayland/multi-output/qml/main.qml b/examples/wayland/multi-output/qml/main.qml new file mode 100644 index 000000000..9fd29fc29 --- /dev/null +++ b/examples/wayland/multi-output/qml/main.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2015 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 + +WaylandCompositor { + id: comp + + defaultOutput: shellScreen + ShellScreen { + id: shellScreen + compositor: comp + } + + GridScreen { + id: gridScreen + compositor: comp + } + + Component { + id: chromeComponent + ShellChrome { + } + } + + Component { + id: surfaceComponent + WaylandSurface { + id: surface + signal activated() + onMappedChanged: { + if (isMapped && !cursorSurface) { + gridScreen.gridSurfaces.append( { "gridSurface" : surface } ); + } else { + for (var i = 0; i < gridScreen.gridSurfaces.count; i++) { + if (gridScreen.gridSurfaces.get(i).gridSurface === surface) { + gridScreen.gridSurfaces.remove(i,1); + break; + } + } + } + } + } + } + + extensions: [ + Shell { + id: defaultShell + + onCreateShellSurface: { + var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "surface": surface } ); + item.shellSurface.initialize(defaultShell, surface, client, id); + surface.activated.connect(item.raise); + } + + Component.onCompleted: { + initialize(); + } + } + ] + + onCreateSurface: { + var surface = surfaceComponent.createObject(comp, { } ); + surface.initialize(comp, client, id, version); + } +} |