diff options
Diffstat (limited to 'examples/wayland/overview-compositor')
-rw-r--r-- | examples/wayland/overview-compositor/CMakeLists.txt | 48 | ||||
-rw-r--r-- | examples/wayland/overview-compositor/doc/images/overview-compositor.jpg | bin | 0 -> 39465 bytes | |||
-rw-r--r-- | examples/wayland/overview-compositor/doc/src/overview-compositor.qdoc | 85 | ||||
-rw-r--r-- | examples/wayland/overview-compositor/main.cpp | 51 | ||||
-rw-r--r-- | examples/wayland/overview-compositor/main.qml | 70 |
5 files changed, 122 insertions, 132 deletions
diff --git a/examples/wayland/overview-compositor/CMakeLists.txt b/examples/wayland/overview-compositor/CMakeLists.txt new file mode 100644 index 000000000..7afe52982 --- /dev/null +++ b/examples/wayland/overview-compositor/CMakeLists.txt @@ -0,0 +1,48 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(overview-compositor LANGUAGES CXX) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/wayland/overview-compositor") + +find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml) + +qt_add_executable(overview-compositor + main.cpp +) + +set_target_properties(overview-compositor PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +target_link_libraries(overview-compositor PUBLIC + Qt::Core + Qt::Gui + Qt::Qml +) + +# Resources: +set(overview-compositor_resource_files + "main.qml" +) + +qt6_add_resources(overview-compositor "overview-compositor" + PREFIX + "/" + FILES + ${overview-compositor_resource_files} +) + +install(TARGETS overview-compositor + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/wayland/overview-compositor/doc/images/overview-compositor.jpg b/examples/wayland/overview-compositor/doc/images/overview-compositor.jpg Binary files differnew file mode 100644 index 000000000..71e56c827 --- /dev/null +++ b/examples/wayland/overview-compositor/doc/images/overview-compositor.jpg diff --git a/examples/wayland/overview-compositor/doc/src/overview-compositor.qdoc b/examples/wayland/overview-compositor/doc/src/overview-compositor.qdoc index 50408bc56..8ac3dfae0 100644 --- a/examples/wayland/overview-compositor/doc/src/overview-compositor.qdoc +++ b/examples/wayland/overview-compositor/doc/src/overview-compositor.qdoc @@ -1,34 +1,65 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! - * \title Qt Wayland Compositor Examples - Overview Compositor + * \title Overview Compositor * \example overview-compositor + * \examplecategory {Embedded} * \brief Overview Compositor shows how to switch between clients in a grid. * + * \section1 Introduction + * + * Overview Compositor demonstrates selecting and activating an application + * from a grid of currently connected clients. + * + * \image overview-compositor.jpg + * + * For an introduction to the basic principles of creating a \l{Qt Wayland Compositor} with Qt, + * see the \l{Minimal QML}{Minimal QML example}. + * + * \section1 Application Grid + * + * In this example, the compositor supports two different modes of operation: + * + * \list + * \li A \e fullscreen mode, where a single application window occupies the whole compositor + * window and is interactable. + * \li An \e overview mode, where all application windows are visible in a grid. Clicking on a + * window in the grid causes it to be selected. The compositor enters fullscreen mode, + * showing the selected application window. + * \endlist + * + * When a client connects to the compositor and creates a top-level surface, the surface will be + * connected to a \l{Shell Extensions - Qt Wayland Compositor}{shell extension}. The example only + * supports the \l{XdgShell} extension, so the client will connect to this. + * + * \snippet overview-compositor/main.qml XdgShell + * + * For each surface, we tell the client to configure it as fullscreen. In addition, the surfaces + * are added to a \l ListModel for easy access. + * + * This model is used by a \l Repeater to create \l{ShellSurfaceItem}{ShellSurfaceItems} inside + * a \l{Grid}. The \l Grid component positions the items in a grid. + * + * \snippet overview-compositor/main.qml toplevels repeater + * + * For each of the items, we create a \l MouseArea which covers the item and intercepts all mouse + * and touch input. This is only active when the compositor is in \e{overview} mode, and activates + * the application that was clicked. + * + * When the compositor goes into fullscreen mode, the same \l Grid component is used, but is scaled + * and translated into a position where the single selected cell fills the compositor's window. The + * idea is to "zoom in" on the selected cell, allowing the user to interact with the application it + * contains. + * + * \snippet overview-compositor/main.qml zoom transform + * + * At the bottom side of the window, there is a button which toggles between the modes. This can + * be used to bring back the application grid while the compositor is in fullscreen mode. + * + * This example shows one way to have the compositor visualize clients in different modes. Another + * way to achieve similar effects is to create multiple Qt Quick items that refer to the same + * surface. See \l{Multi Output}{the Multi Output example} for a demonstration. + * * \ingroup qtwaylandcompositor-examples */ diff --git a/examples/wayland/overview-compositor/main.cpp b/examples/wayland/overview-compositor/main.cpp index 435b4e3f1..50f48df7a 100644 --- a/examples/wayland/overview-compositor/main.cpp +++ b/examples/wayland/overview-compositor/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QtCore/QUrl> #include <QtCore/QDebug> diff --git a/examples/wayland/overview-compositor/main.qml b/examples/wayland/overview-compositor/main.qml index d0482a90e..3d6f35aac 100644 --- a/examples/wayland/overview-compositor/main.qml +++ b/examples/wayland/overview-compositor/main.qml @@ -1,57 +1,11 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.7 -import QtWayland.Compositor 1.3 -import QtQuick.Window 2.3 -import QtQuick.Controls 2.0 +import QtQuick +import QtWayland.Compositor +import QtWayland.Compositor.XdgShell +import QtQuick.Window +import QtQuick.Controls WaylandCompositor { WaylandOutput { @@ -76,6 +30,7 @@ WaylandCompositor { anchors.fill: parent columns: Math.ceil(Math.sqrt(toplevels.count)) + // ![zoom transform] transform: [ Scale { xScale: grid.overview ? (1.0/grid.columns) : 1 @@ -90,7 +45,9 @@ WaylandCompositor { Behavior on y { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 200 } } } ] + // ![zoom transform] + // ![toplevels repeater] Repeater { model: toplevels Item { @@ -99,8 +56,6 @@ WaylandCompositor { ShellSurfaceItem { anchors.fill: parent shellSurface: xdgSurface - autoCreatePopupItems: true - sizeFollowsSurface: false onSurfaceDestroyed: toplevels.remove(index) } MouseArea { @@ -113,6 +68,7 @@ WaylandCompositor { } } } + // ![toplevels repeater] } Button { @@ -132,10 +88,12 @@ WaylandCompositor { ListModel { id: toplevels } + // ![XdgShell] XdgShell { - onToplevelCreated: { + onToplevelCreated: (toplevel, xdgSurface) => { toplevels.append({xdgSurface}); toplevel.sendFullscreen(Qt.size(win.pixelWidth, win.pixelHeight)); } } + // ![XdgShell] } |