summaryrefslogtreecommitdiffstats
path: root/examples/wayland/fancy-compositor/qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/wayland/fancy-compositor/qml')
-rw-r--r--examples/wayland/fancy-compositor/qml/Chrome.qml68
-rw-r--r--examples/wayland/fancy-compositor/qml/CompositorScreen.qml83
-rw-r--r--examples/wayland/fancy-compositor/qml/Keyboard.qml15
-rw-r--r--examples/wayland/fancy-compositor/qml/main.qml38
4 files changed, 204 insertions, 0 deletions
diff --git a/examples/wayland/fancy-compositor/qml/Chrome.qml b/examples/wayland/fancy-compositor/qml/Chrome.qml
new file mode 100644
index 000000000..b8d71c756
--- /dev/null
+++ b/examples/wayland/fancy-compositor/qml/Chrome.qml
@@ -0,0 +1,68 @@
+// 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/fancy-compositor/qml/CompositorScreen.qml b/examples/wayland/fancy-compositor/qml/CompositorScreen.qml
new file mode 100644
index 000000000..4b2ba36d6
--- /dev/null
+++ b/examples/wayland/fancy-compositor/qml/CompositorScreen.qml
@@ -0,0 +1,83 @@
+// 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/fancy-compositor/qml/Keyboard.qml b/examples/wayland/fancy-compositor/qml/Keyboard.qml
new file mode 100644
index 000000000..2985ffcbd
--- /dev/null
+++ b/examples/wayland/fancy-compositor/qml/Keyboard.qml
@@ -0,0 +1,15 @@
+// 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/fancy-compositor/qml/main.qml b/examples/wayland/fancy-compositor/qml/main.qml
new file mode 100644
index 000000000..87feedf14
--- /dev/null
+++ b/examples/wayland/fancy-compositor/qml/main.qml
@@ -0,0 +1,38 @@
+// 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]
+}