diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2023-02-13 08:28:46 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2023-03-06 07:58:48 +0000 |
commit | 6ffff6b50be77cda196851fe81e30445e8a1e723 (patch) | |
tree | 788d65623eaf686353ea20f9c02019690a3868da /examples/wayland/pure-qml | |
parent | 5826c898b6a624c669bf1bfeea4265b7f4934ffe (diff) |
Rename pure-qml to fancy-compositor
The pure-qml name made sense when the example was made, but since
then we have added a lot of examples that are all in Pure QML.
Minimal QML covers the basics of how to set up a compositor in QML,
but Pure QML shows a more advanced use case, with animations,
windowing system features, virtual keyboard support, etc.
To make it clear what the example is demonstrating, we call it
Fancy Compositor instead.
Task-number: QTBUG-110993
Change-Id: Iad1cfb11b6461858ebcdaa388ed16e1fd3ec8805
Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'examples/wayland/pure-qml')
-rw-r--r-- | examples/wayland/pure-qml/CMakeLists.txt | 52 | ||||
-rw-r--r-- | examples/wayland/pure-qml/doc/src/pure-qml.qdoc | 106 | ||||
-rw-r--r-- | examples/wayland/pure-qml/images/background.jpg | bin | 30730 -> 0 bytes | |||
-rw-r--r-- | examples/wayland/pure-qml/main.cpp | 21 | ||||
-rw-r--r-- | examples/wayland/pure-qml/pure-qml.pro | 18 | ||||
-rw-r--r-- | examples/wayland/pure-qml/pure-qml.qrc | 9 | ||||
-rw-r--r-- | examples/wayland/pure-qml/qml/Chrome.qml | 68 | ||||
-rw-r--r-- | examples/wayland/pure-qml/qml/CompositorScreen.qml | 83 | ||||
-rw-r--r-- | examples/wayland/pure-qml/qml/Keyboard.qml | 15 | ||||
-rw-r--r-- | examples/wayland/pure-qml/qml/main.qml | 38 |
10 files changed, 0 insertions, 410 deletions
diff --git a/examples/wayland/pure-qml/CMakeLists.txt b/examples/wayland/pure-qml/CMakeLists.txt deleted file mode 100644 index 2642ca7a4..000000000 --- a/examples/wayland/pure-qml/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(pure-qml LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/wayland/pure-qml") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml) - -qt_add_executable(pure-qml - main.cpp -) - -set_target_properties(pure-qml PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(pure-qml PUBLIC - Qt::Core - Qt::Gui - Qt::Qml -) - -# Resources: -set(pure-qml_resource_files - "images/background.jpg" - "qml/Chrome.qml" - "qml/CompositorScreen.qml" - "qml/Keyboard.qml" - "qml/main.qml" -) - -qt6_add_resources(pure-qml "pure-qml" - PREFIX - "/" - FILES - ${pure-qml_resource_files} -) - -install(TARGETS pure-qml - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/wayland/pure-qml/doc/src/pure-qml.qdoc b/examples/wayland/pure-qml/doc/src/pure-qml.qdoc deleted file mode 100644 index 0fcb231d8..000000000 --- a/examples/wayland/pure-qml/doc/src/pure-qml.qdoc +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \title Pure QML - \example pure-qml - \meta category {Embedded} - \brief Pure QML is an example that demonstrates how to write a Wayland compositor in pure QML. - \ingroup qtwaylandcompositor-examples - - \section1 Introduction - - Pure QML is a small desktop-style Wayland compositor example that demonstrates the power and - ease of the \l{Qt Wayland Compositor} QML APIs. - - The Pure QML example is similar to the \l{Minimal QML}{Minimal QML example}, in that it is a - full-blown Wayland compositor, implemented only using QML code. - - \section1 Initializing the Compositor - - Like the \l{Minimal QML}{Minimal QML example}, Pure QML supports the main - \l{Shell Extensions - Qt Wayland Compositor}{shell extensions} that are supported by Qt. - - \snippet pure-qml/qml/main.qml shell extensions - - These are instantiated as children of the \l{WaylandCompositor} which automatically adds - them to the list of supported interfaces which is broadcasted to clients from the server. - - When a connected client creates a surface and binds it to one of the shell extensions, the - corresponding signal is emitted. This then calls a method inside our custom \l WaylandOutput - class, which appends the \l ShellSurface to a \l{ListModel}. - - \snippet pure-qml/qml/CompositorScreen.qml handleShellSurface - - This model is used as the source for a \l Repeater which creates - \l{ShellSurfaceItem}{ShellSurfaceItems} inside the compositor's \l WaylandOutput. This adds a - view of the surface in the Qt Quick scene. Since it is a \l{ShellSurfaceItem}, it also has - certain interaction options for the user of the compositor, depending on which shell extension - is in use. - - \snippet pure-qml/qml/CompositorScreen.qml repeater - - \section1 Keyboard - - In addition to the basic windowing system functions, the Pure QML compositor also supports an - optional on-screen keyboard running in-process. This uses the \l{Qt Virtual Keyboard} module, - and will be enabled if the module is available. - - \snippet pure-qml/qml/Keyboard.qml keyboard - - The code is simple. We instantiate an \l InputPanel in the bottom of the output, and make sure - it is visible if and only if it is currently active. - - \snippet pure-qml/qml/CompositorScreen.qml keyboard - - The keyboard is then added to the \l WaylandOutput using a \l Loader element. The \l Loader is - used here to avoid having a hard dependency on the \l{Qt Virtual Keyboard} module. If loading - fails, then the compositor will continue operating normally, but without support for an - on-screen keyboard. - - Finally, we need a way for the compositor to communicate the text input to its clients. This - is done via a \c{text-input} extension. The Pure QML example only supports the - \c{qt_text_input_method_unstable_v1} protocol. - - \snippet pure-qml/qml/main.qml text input - - The extension is added to the compositor by instantiating the \l QtTextInputMethodManager as - a child of the \l{WaylandCompositor}. - - In order for the on-screen keyboard to work, this protocol must also be supported by the client. - Therefore, the \l QtTextInputMethodManager is most useful if the clients are also Qt - applications. - - \note Qt also supports \l{TextInputManager}, which is an implementation of the - \c{text_input_unstable_v2} protocol. - - \section1 Transitions - - In addition to the basic functionality, the Pure QML example also demonstrates animated - transitions between states. - - The first of these is the \e{activation} transition. This is only supported on the \l{XdgShell}, - since this is the only shell extension which has an \l{XdgToplevel::}{activated} state. - - \snippet pure-qml/qml/Chrome.qml activation - - When a client window becomes activated under the \l XdgShell protocol, we trigger an animation - which makes the window "pop out" for 200 ms. - - The Pure QML compositor also supports a \e{destruction} animation. This triggers whenever the - window closes and surface is destroyed, whether this was because the client gracefully closed - its window, or even if it crashes. - - \snippet pure-qml/qml/Chrome.qml destruction - - To ensure that the content exists for the duration of the animation, we start by locking the - buffer. This means the final frame rendered by the client will remain in memory until we are - done with it. - - Again, we trigger an animation on the scale of the item. The animation in question imitates - turning off the power on a CRT screen, giving a visual clue to the user that the window is - closing, and didn't just vanish into thin air. - - Any sort of animated effect may be used for state changes such as these, with the full range - of Qt Quick at your disposal. -*/ diff --git a/examples/wayland/pure-qml/images/background.jpg b/examples/wayland/pure-qml/images/background.jpg Binary files differdeleted file mode 100644 index 445567fbd..000000000 --- a/examples/wayland/pure-qml/images/background.jpg +++ /dev/null diff --git a/examples/wayland/pure-qml/main.cpp b/examples/wayland/pure-qml/main.cpp deleted file mode 100644 index dca8dfe01..000000000 --- a/examples/wayland/pure-qml/main.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#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:///qml/main.qml")); - - return app.exec(); -} diff --git a/examples/wayland/pure-qml/pure-qml.pro b/examples/wayland/pure-qml/pure-qml.pro deleted file mode 100644 index 2214922e8..000000000 --- a/examples/wayland/pure-qml/pure-qml.pro +++ /dev/null @@ -1,18 +0,0 @@ -QT += gui qml - -SOURCES += \ - main.cpp - -OTHER_FILES = \ - qml/main.qml \ - qml/CompositorScreen.qml \ - qml/Chrome.qml \ - qml/Keyboard.qml \ - images/background.jpg \ - -RESOURCES += pure-qml.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/wayland/pure-qml -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS pure-qml.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/wayland/pure-qml -INSTALLS += target sources diff --git a/examples/wayland/pure-qml/pure-qml.qrc b/examples/wayland/pure-qml/pure-qml.qrc deleted file mode 100644 index 145b3f250..000000000 --- a/examples/wayland/pure-qml/pure-qml.qrc +++ /dev/null @@ -1,9 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>images/background.jpg</file> - <file>qml/main.qml</file> - <file>qml/CompositorScreen.qml</file> - <file>qml/Chrome.qml</file> - <file>qml/Keyboard.qml</file> - </qresource> -</RCC> diff --git a/examples/wayland/pure-qml/qml/Chrome.qml b/examples/wayland/pure-qml/qml/Chrome.qml deleted file mode 100644 index b8d71c756..000000000 --- a/examples/wayland/pure-qml/qml/Chrome.qml +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import QtWayland.Compositor - -ShellSurfaceItem { - id: chrome - - property bool isChild: parent.shellSurface !== undefined - - signal destroyAnimationFinished - - // ![destruction] - onSurfaceDestroyed: { - bufferLocked = 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: chrome; property: "opacity"; to: chrome.isChild ? 0 : 1; duration: 150 } - } - NumberAnimation { target: scaleTransform; property: "xScale"; to: 0; duration: 150 } - ScriptAction { script: destroyAnimationFinished() } - } - // ![destruction] - - transform: [ - Scale { - id: scaleTransform - origin.x: chrome.width / 2 - origin.y: chrome.height / 2 - } - ] - - // ![activation] - Connections { - target: shellSurface.toplevel !== undefined ? shellSurface.toplevel : null - - // some signals are not available on wl_shell, so let's ignore them - ignoreUnknownSignals: true - - function onActivatedChanged() { // xdg_shell only - if (shellSurface.toplevel.activated) { - receivedFocusAnimation.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 } - } - } - // ![activation] -} diff --git a/examples/wayland/pure-qml/qml/CompositorScreen.qml b/examples/wayland/pure-qml/qml/CompositorScreen.qml deleted file mode 100644 index 4b2ba36d6..000000000 --- a/examples/wayland/pure-qml/qml/CompositorScreen.qml +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import QtQuick.Window -import QtWayland.Compositor - -WaylandOutput { - id: output - - property ListModel shellSurfaces: ListModel {} - property bool isNestedCompositor: Qt.platform.pluginName.startsWith("wayland") || Qt.platform.pluginName === "xcb" - - // ![handleShellSurface] - function handleShellSurface(shellSurface) { - shellSurfaces.append({shellSurface: shellSurface}); - } - // ![handleShellSurface] - - // During development, it can be useful to start the compositor inside X11 or - // another Wayland compositor. In such cases, set sizeFollowsWindow to true to - // enable resizing of the compositor window to be forwarded to the Wayland clients - // as the output (screen) changing resolution. Consider setting it to false if you - // are running the compositor using eglfs, linuxfb or similar QPA backends. - sizeFollowsWindow: output.isNestedCompositor - - window: Window { - width: 1024 - height: 760 - visible: true - - WaylandMouseTracker { - id: mouseTracker - - anchors.fill: parent - - // Set this to false to disable the outer mouse cursor when running nested - // compositors. Otherwise you would see two mouse cursors, one for each compositor. - windowSystemCursorEnabled: output.isNestedCompositor - - Image { - id: background - - anchors.fill: parent - fillMode: Image.Tile - source: "qrc:/images/background.jpg" - smooth: true - - // ![repeater] - Repeater { - model: output.shellSurfaces - // Chrome displays a shell surface on the screen (See Chrome.qml) - Chrome { - shellSurface: modelData - onDestroyAnimationFinished: output.shellSurfaces.remove(index) - } - } - // ![repeater] - } - - // Virtual Keyboard - // ![keyboard] - Loader { - anchors.fill: parent - source: "Keyboard.qml" - } - // ![keyboard] - - // Draws the mouse cursor for a given Wayland seat - WaylandCursorItem { - inputEventsEnabled: false - x: mouseTracker.mouseX - y: mouseTracker.mouseY - seat: output.compositor.defaultSeat - } - } - - Shortcut { - sequence: "Ctrl+Alt+Backspace" - onActivated: Qt.quit() - } - } -} diff --git a/examples/wayland/pure-qml/qml/Keyboard.qml b/examples/wayland/pure-qml/qml/Keyboard.qml deleted file mode 100644 index 2985ffcbd..000000000 --- a/examples/wayland/pure-qml/qml/Keyboard.qml +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -// ![keyboard] -import QtQuick -import QtQuick.VirtualKeyboard - -InputPanel { - visible: active - y: active ? parent.height - height : parent.height - anchors.left: parent.left - anchors.right: parent.right -} -// ![keyboard] - diff --git a/examples/wayland/pure-qml/qml/main.qml b/examples/wayland/pure-qml/qml/main.qml deleted file mode 100644 index 87feedf14..000000000 --- a/examples/wayland/pure-qml/qml/main.qml +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import QtWayland.Compositor -import QtWayland.Compositor.XdgShell -import QtWayland.Compositor.WlShell -import QtWayland.Compositor.IviApplication - -WaylandCompositor { - id: waylandCompositor - - CompositorScreen { id: screen; compositor: waylandCompositor } - - // ![shell extensions] - // Shell surface extension. Needed to provide a window concept for Wayland clients. - // I.e. requests and events for maximization, minimization, resizing, closing etc. - XdgShell { - onToplevelCreated: (toplevel, xdgSurface) => screen.handleShellSurface(xdgSurface) - } - - // Minimalistic shell extension. Mainly used for embedded applications. - IviApplication { - onIviSurfaceCreated: (iviSurface) => screen.handleShellSurface(iviSurface) - } - - // Deprecated shell extension, still used by some clients - WlShell { - onWlShellSurfaceCreated: (shellSurface) => screen.handleShellSurface(shellSurface) - } - // ![shell extensions] - - // Extension for Input Method (QT_IM_MODULE) support at compositor-side - // ![text input] - TextInputManager {} - QtTextInputMethodManager {} - // ![text input] -} |