summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-05-24 09:17:27 +0200
committerJohan Helsing <johan.helsing@qt.io>2018-05-28 08:05:05 +0000
commitb3f0603ee7bf5b286056885eea5b80ebcc26cdca (patch)
tree77dbad9416078c3d0ae7583da21133c1a24d4ef1 /examples
parent3eb609a0a140650226483e02e9f0bed700853d6a (diff)
downloadqtwayland-b3f0603ee7bf5b286056885eea5b80ebcc26cdca.tar.gz
Revamp spanning-screens example
- Switch to xdg-shell v6 - Use autoCreatePopupItems - Follow QML coding conventions - Remove redundant compositor bindings - Support for screen dpr != 1 Task-number: QTBUG-60661 Change-Id: I9447aca2e21732de4361c0cf53a2f09216a75dc8 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/wayland/spanning-screens/main.qml75
1 files changed, 27 insertions, 48 deletions
diff --git a/examples/wayland/spanning-screens/main.qml b/examples/wayland/spanning-screens/main.qml
index c978f589..a3230806 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);
}
}
}