summaryrefslogtreecommitdiffstats
path: root/examples/wayland/pure-qml
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-05-02 10:36:36 +0200
committerJohan Helsing <johan.helsing@qt.io>2018-05-18 09:01:38 +0000
commit9ac2cdf96d36db9612effdbdb9669bd413b66b84 (patch)
tree7ed4bf33c3df76481aed2a6448aa2cc0eafba1d5 /examples/wayland/pure-qml
parent458dfb4c65dd959115416a5bc9d6dfc5e4936bd6 (diff)
Revamp pure-qml example
- Use a ListModel to manage shellSurfaces - Remove obsolete/deprecated extensions (QtWindowManager, XdgShellV5) - Remove no-ops (onSurfaceRequested created a default surface) - Remove dead code (primarySurfaceArea, output property on Window) - Add comments - Follow coding conventions (formatting, order of object attributes etc.) Task-number: QTBUG-60661 Change-Id: I4ffd2c4b5deff1d801a25efa96300fc5851d3359 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'examples/wayland/pure-qml')
-rw-r--r--examples/wayland/pure-qml/qml/Chrome.qml30
-rw-r--r--examples/wayland/pure-qml/qml/Keyboard.qml3
-rw-r--r--examples/wayland/pure-qml/qml/Screen.qml46
-rw-r--r--examples/wayland/pure-qml/qml/main.qml53
4 files changed, 62 insertions, 70 deletions
diff --git a/examples/wayland/pure-qml/qml/Chrome.qml b/examples/wayland/pure-qml/qml/Chrome.qml
index 2e2586c1b..a63ee705c 100644
--- a/examples/wayland/pure-qml/qml/Chrome.qml
+++ b/examples/wayland/pure-qml/qml/Chrome.qml
@@ -52,16 +52,28 @@ import QtQuick 2.0
import QtWayland.Compositor 1.0
ShellSurfaceItem {
- id: rootChrome
- autoCreatePopupItems: true
+ id: chrome
property bool isChild: parent.shellSurface !== undefined
+ signal destroyAnimationFinished
+
+ // If the client asks to show popups on this surface, automatically create child ShellSurfaceItems
+ autoCreatePopupItems: true
+
onSurfaceDestroyed: {
bufferLocked = true;
destroyAnimation.start();
}
+ transform: [
+ Scale {
+ id: scaleTransform
+ origin.x: chrome.width / 2
+ origin.y: chrome.height / 2
+ }
+ ]
+
Connections {
target: shellSurface
@@ -77,17 +89,19 @@ ShellSurfaceItem {
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: rootChrome; property: "opacity"; to: rootChrome.isChild ? 0 : 1; 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: { rootChrome.destroy(); } }
+ ScriptAction { script: destroyAnimationFinished() }
}
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 }
@@ -97,12 +111,4 @@ ShellSurfaceItem {
NumberAnimation { target: scaleTransform; property: "xScale"; to: 1; duration: 100; easing.type: Easing.InOutQuad }
}
}
-
- transform: [
- Scale {
- id:scaleTransform
- origin.x: rootChrome.width / 2
- origin.y: rootChrome.height / 2
- }
- ]
}
diff --git a/examples/wayland/pure-qml/qml/Keyboard.qml b/examples/wayland/pure-qml/qml/Keyboard.qml
index e1f0a8b19..b2586ffd4 100644
--- a/examples/wayland/pure-qml/qml/Keyboard.qml
+++ b/examples/wayland/pure-qml/qml/Keyboard.qml
@@ -52,9 +52,8 @@ import QtQuick 2.5
import QtQuick.VirtualKeyboard 2.1
InputPanel {
- id: inputPanel
visible: active
- y: active ? parent.height - inputPanel.height : parent.height
+ y: active ? parent.height - height : parent.height
anchors.left: parent.left
anchors.right: parent.right
}
diff --git a/examples/wayland/pure-qml/qml/Screen.qml b/examples/wayland/pure-qml/qml/Screen.qml
index 562eb86c5..b156cb434 100644
--- a/examples/wayland/pure-qml/qml/Screen.qml
+++ b/examples/wayland/pure-qml/qml/Screen.qml
@@ -54,49 +54,69 @@ import QtWayland.Compositor 1.0
WaylandOutput {
id: output
- property alias surfaceArea: background
- sizeFollowsWindow: true
- window: Window {
- id: screen
- property QtObject output
+ property ListModel shellSurfaces: ListModel {}
+ property bool isNestedCompositor: Qt.platform.pluginName.startsWith("wayland") || Qt.platform.pluginName === "xcb"
+
+ function handleShellSurface(shellSurface) {
+ shellSurfaces.append({shellSurface: shellSurface});
+ }
+
+ // 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
- windowSystemCursorEnabled: true
+ // 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 {
+ model: output.shellSurfaces
+ // Chrome displays a shell surface on the screen (See Chrome.qml)
+ Chrome {
+ shellSurface: modelData
+ onDestroyAnimationFinished: output.shellSurfaces.remove(index)
+ }
+ }
}
+
+ // Virtual Keyboard
Loader {
anchors.fill: parent
source: "Keyboard.qml"
}
+
+ // Draws the mouse cursor for a given Wayland seat
WaylandCursorItem {
- id: cursor
inputEventsEnabled: false
x: mouseTracker.mouseX
y: mouseTracker.mouseY
-
seat: output.compositor.defaultSeat
}
}
Shortcut {
- sequence: "Meta+F"
- onActivated: qtWindowManager.showIsFullScreen = !qtWindowManager.showIsFullScreen
- }
-
- Shortcut {
sequence: "Ctrl+Alt+Backspace"
onActivated: Qt.quit()
}
diff --git a/examples/wayland/pure-qml/qml/main.qml b/examples/wayland/pure-qml/qml/main.qml
index 7bf2a623c..b188ebbb5 100644
--- a/examples/wayland/pure-qml/qml/main.qml
+++ b/examples/wayland/pure-qml/qml/main.qml
@@ -52,54 +52,21 @@ import QtQuick 2.0
import QtWayland.Compositor 1.1
WaylandCompositor {
- id: comp
+ id: waylandCompositor
- property var primarySurfacesArea: null
-
- Screen {
- compositor: comp
- }
-
- Component {
- id: chromeComponent
- Chrome {
- }
- }
-
- Component {
- id: surfaceComponent
- WaylandSurface {
- }
- }
-
- QtWindowManager {
- id: qtWindowManager
- onShowIsFullScreenChanged: console.debug("Show is fullscreen hint for Qt applications:", showIsFullScreen)
- }
-
- WlShell {
- onWlShellSurfaceCreated: {
- chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": shellSurface } );
- }
- }
-
- XdgShellV5 {
- onXdgSurfaceCreated: {
- chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": xdgSurface } );
- }
- }
+ Screen { id: screen; compositor: waylandCompositor }
+ // Shell surface extension. Needed to provide a window concept for Wayland clients.
+ // I.e. requests and events for maximization, minimization, resizing, closing etc.
XdgShellV6 {
- onToplevelCreated: {
- chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": xdgSurface } );
- }
+ onToplevelCreated: screen.handleShellSurface(xdgSurface)
}
- TextInputManager {
+ // Deprecated shell extension, still used by some clients
+ WlShell {
+ onWlShellSurfaceCreated: screen.handleShellSurface(shellSurface)
}
- onSurfaceRequested: {
- var surface = surfaceComponent.createObject(comp, { } );
- surface.initialize(comp, client, id, version);
- }
+ // Extension for Virtual keyboard support
+ TextInputManager {}
}