diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/wayland/minimal-qml/main.qml | 1 | ||||
-rw-r--r-- | examples/wayland/overview-compositor/main.qml | 39 | ||||
-rw-r--r-- | examples/wayland/pure-qml/qml/Chrome.qml | 29 | ||||
-rw-r--r-- | examples/wayland/pure-qml/qml/Keyboard.qml | 3 | ||||
-rw-r--r-- | examples/wayland/pure-qml/qml/Screen.qml | 46 | ||||
-rw-r--r-- | examples/wayland/pure-qml/qml/main.qml | 67 | ||||
-rw-r--r-- | examples/wayland/spanning-screens/main.qml | 75 | ||||
-rw-r--r-- | examples/wayland/wayland.pro | 1 |
8 files changed, 114 insertions, 147 deletions
diff --git a/examples/wayland/minimal-qml/main.qml b/examples/wayland/minimal-qml/main.qml index 0f0ca61bc..85c8c5783 100644 --- a/examples/wayland/minimal-qml/main.qml +++ b/examples/wayland/minimal-qml/main.qml @@ -67,6 +67,7 @@ WaylandCompositor { // resize/move, and forwarding of mouse and keyboard // events to the client process. ShellSurfaceItem { + autoCreatePopupItems: true shellSurface: modelData onSurfaceDestroyed: shellSurfaces.remove(index) } diff --git a/examples/wayland/overview-compositor/main.qml b/examples/wayland/overview-compositor/main.qml index 6e5cec985..18589e50a 100644 --- a/examples/wayland/overview-compositor/main.qml +++ b/examples/wayland/overview-compositor/main.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** 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. @@ -49,8 +49,8 @@ ****************************************************************************/ import QtQuick 2.7 -import QtWayland.Compositor 1.0 -import QtQuick.Window 2.0 +import QtWayland.Compositor 1.1 +import QtQuick.Window 2.3 import QtQuick.Controls 2.0 WaylandCompositor { @@ -58,18 +58,24 @@ WaylandCompositor { sizeFollowsWindow: true window: Window { id: win + + property int pixelWidth: width * screen.devicePixelRatio + property int pixelHeight: height * screen.devicePixelRatio + visible: true width: 1280 height: 720 + Grid { id: grid - anchors.fill: parent - columns: Math.ceil(Math.sqrt(shellSurfaces.count)) + property bool overview: true property int selected: 0 property int selectedColumn: selected % columns property int selectedRow: selected / columns + anchors.fill: parent + columns: Math.ceil(Math.sqrt(toplevels.count)) transform: [ Scale { xScale: grid.overview ? (1.0/grid.columns) : 1 @@ -86,15 +92,16 @@ WaylandCompositor { ] Repeater { - model: shellSurfaces + model: toplevels Item { width: win.width height: win.height - WaylandQuickItem { + ShellSurfaceItem { anchors.fill: parent + shellSurface: xdgSurface + autoCreatePopupItems: true sizeFollowsSurface: false - surface: modelData.surface - onSurfaceDestroyed: shellSurfaces.remove(index) + onSurfaceDestroyed: toplevels.remove(index) } MouseArea { enabled: grid.overview @@ -116,19 +123,19 @@ WaylandCompositor { } Shortcut { sequence: "space"; onActivated: grid.overview = !grid.overview } - Shortcut { sequence: "right"; onActivated: grid.selected = Math.min(grid.selected+1, shellSurfaces.count-1) } + Shortcut { sequence: "right"; onActivated: grid.selected = Math.min(grid.selected+1, toplevels.count-1) } Shortcut { sequence: "left"; onActivated: grid.selected = Math.max(grid.selected-1, 0) } Shortcut { sequence: "up"; onActivated: grid.selected = Math.max(grid.selected-grid.columns, 0) } - Shortcut { sequence: "down"; onActivated: grid.selected = Math.min(grid.selected+grid.columns, shellSurfaces.count-1) } + Shortcut { sequence: "down"; onActivated: grid.selected = Math.min(grid.selected+grid.columns, toplevels.count-1) } } } - ListModel { id: shellSurfaces } + ListModel { id: toplevels } - WlShell { - onWlShellSurfaceCreated: { - shellSurfaces.append({shellSurface: shellSurface}); - shellSurface.sendConfigure(Qt.size(win.width, win.height), WlShellSurface.NoneEdge); + XdgShellV6 { + onToplevelCreated: { + toplevels.append({xdgSurface}); + toplevel.sendFullscreen(Qt.size(win.pixelWidth, win.pixelHeight)); } } } diff --git a/examples/wayland/pure-qml/qml/Chrome.qml b/examples/wayland/pure-qml/qml/Chrome.qml index e6fe97476..a63ee705c 100644 --- a/examples/wayland/pure-qml/qml/Chrome.qml +++ b/examples/wayland/pure-qml/qml/Chrome.qml @@ -52,15 +52,28 @@ import QtQuick 2.0 import QtWayland.Compositor 1.0 ShellSurfaceItem { - id: rootChrome + 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 @@ -76,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 } @@ -96,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 77ed3ecd9..b188ebbb5 100644 --- a/examples/wayland/pure-qml/qml/main.qml +++ b/examples/wayland/pure-qml/qml/main.qml @@ -52,68 +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 } ); - } - } - - property variant viewsBySurface: ({}) - - XdgShellV5 { - onXdgSurfaceCreated: { - var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": xdgSurface } ); - viewsBySurface[xdgSurface.surface] = item; - } - onXdgPopupCreated: { - var parentView = viewsBySurface[xdgPopup.parentSurface]; - var item = chromeComponent.createObject(parentView, { "shellSurface": xdgPopup } ); - viewsBySurface[xdgPopup.surface] = item; - } - } + 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: { - var item = chromeComponent.createObject(defaultOutput.surfaceArea, { "shellSurface": xdgSurface } ); - viewsBySurface[xdgSurface.surface] = item; - } - onPopupCreated: { - var parentView = viewsBySurface[popup.parentXdgSurface.surface]; - var item = chromeComponent.createObject(parentView, { "shellSurface": xdgSurface } ); - viewsBySurface[xdgSurface.surface] = item; - } + 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 {} } diff --git a/examples/wayland/spanning-screens/main.qml b/examples/wayland/spanning-screens/main.qml index c978f589e..a3230806b 100644 --- a/examples/wayland/spanning-screens/main.qml +++ b/examples/wayland/spanning-screens/main.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** 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. @@ -50,20 +50,22 @@ import QtQuick 2.6 import QtQuick.Window 2.3 -import QtWayland.Compositor 1.0 +import QtWayland.Compositor 1.1 WaylandCompositor { - id: wlcompositor - WaylandOutput { - compositor: wlcompositor sizeFollowsWindow: true window: Window { id: topSurfaceArea + + property int pixelHeight: screen.devicePixelRatio * height + property int pixelWidth: screen.devicePixelRatio * width + width: 1024 height: 768 visible: true color: "#1337af" + Text { text: "Top screen" } // Enable the following to make the output target an actual screen, @@ -74,14 +76,18 @@ WaylandCompositor { } WaylandOutput { - compositor: wlcompositor sizeFollowsWindow: true window: Window { id: bottomSurfaceArea + + property int pixelHeight: screen.devicePixelRatio * height + property int pixelWidth: screen.devicePixelRatio * width + width: 1024 height: 768 visible: true color: "#1abacc" + Text { text: "Bottom screen" } // Enable the following to make the output target an actual screen, @@ -93,56 +99,29 @@ WaylandCompositor { Component { id: chromeComponent - WaylandQuickItem { - onSurfaceDestroyed: destroy() - } - } - - Component { - id: xdgPopupComponent ShellSurfaceItem { + autoCreatePopupItems: true onSurfaceDestroyed: destroy() } } - WlShell { - onWlShellSurfaceCreated: handleShellSurfaceCreated(shellSurface) - } + XdgShellV6 { + onToplevelCreated: { + const shellSurface = xdgSurface; - property variant viewsBySurface: ({}) + const topItem = chromeComponent.createObject(topSurfaceArea, { + shellSurface + }); - XdgShellV5 { - onXdgSurfaceCreated: handleShellSurfaceCreated(xdgSurface) - onXdgPopupCreated: { - var parentViews = viewsBySurface[xdgPopup.parentSurface]; - xdgPopupComponent.createObject(parentViews.top, { "shellSurface": xdgPopup } ); - xdgPopupComponent.createObject(parentViews.bottom, { "shellSurface": xdgPopup } ); - } - } + const bottomItem = chromeComponent.createObject(bottomSurfaceArea, { + shellSurface, + y: Qt.binding(function() { return -topSurfaceArea.height;}) + }); - function handleShellSurfaceCreated(shellSurface) { - var topItem = chromeComponent.createObject(topSurfaceArea, { - "surface": shellSurface.surface - }); - - var bottomItem = chromeComponent.createObject(bottomSurfaceArea, { - "surface": shellSurface.surface, - "y": Qt.binding(function() { return -topSurfaceArea.height;}) - }); - - viewsBySurface[shellSurface.surface] = { - top: topItem, - bottom: bottomItem - }; - - var height = bottomSurfaceArea.height + topSurfaceArea.height; - var width = Math.max(bottomSurfaceArea.width, topSurfaceArea.width); - var size = Qt.size(width, height); - - if (shellSurface.sendFullscreen) { - shellSurface.sendFullscreen(size); - } else if (shellSurface.sendConfigure) { - shellSurface.sendConfigure(size, WlShellSurface.NoneEdge); + const height = topSurfaceArea.pixelHeight + bottomSurfaceArea.pixelHeight; + const width = Math.max(bottomSurfaceArea.pixelWidth, topSurfaceArea.pixelWidth); + const size = Qt.size(width, height); + toplevel.sendFullscreen(size); } } } diff --git a/examples/wayland/wayland.pro b/examples/wayland/wayland.pro index a8eef8266..0cb050cca 100644 --- a/examples/wayland/wayland.pro +++ b/examples/wayland/wayland.pro @@ -12,6 +12,7 @@ qtHaveModule(quick) { SUBDIRS += pure-qml SUBDIRS += multi-output SUBDIRS += multi-screen + SUBDIRS += overview-compositor SUBDIRS += ivi-compositor qtHaveModule(waylandclient) { SUBDIRS += \ |