summaryrefslogtreecommitdiffstats
path: root/examples/wayland/multi-screen
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-10-07 11:15:32 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2016-11-23 14:32:31 +0000
commit2f841b18ce6553f027e80fa8da878ea409af280a (patch)
treeb0a515292a373243367304c3b238fd7b7231e6f0 /examples/wayland/multi-screen
parent767ee09aba517b0c680dd67a0f213a483429b65f (diff)
multi-screen example: create an output for each screen
Use Instantiator to create an output for each screen that exists. Change-Id: Ice74632c36a9e0d55bd9e8b6d04022f5c10de6f0 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'examples/wayland/multi-screen')
-rw-r--r--examples/wayland/multi-screen/qml/Screen.qml13
-rw-r--r--examples/wayland/multi-screen/qml/main.qml56
2 files changed, 36 insertions, 33 deletions
diff --git a/examples/wayland/multi-screen/qml/Screen.qml b/examples/wayland/multi-screen/qml/Screen.qml
index 7e2eb01dc..26132f754 100644
--- a/examples/wayland/multi-screen/qml/Screen.qml
+++ b/examples/wayland/multi-screen/qml/Screen.qml
@@ -40,18 +40,25 @@
import QtQuick 2.0
import QtWayland.Compositor 1.0
-import QtQuick.Window 2.2
+import QtQuick.Window 2.3
WaylandOutput {
id: screen
property variant viewsBySurface: ({})
property alias surfaceArea: background
property alias text: t.text
+ property alias targetScreen: win.targetScreen
sizeFollowsWindow: true
+ property bool windowed: false
+
window: Window {
- width: 1024
- height: 760
+ id: win
+ x: targetScreen.virtualX
+ y: targetScreen.virtualY
+ width: 800
+ height: 800
+ visibility: windowed ? Window.Windowed : Window.FullScreen
visible: true
WaylandMouseTracker {
diff --git a/examples/wayland/multi-screen/qml/main.qml b/examples/wayland/multi-screen/qml/main.qml
index 37350289e..25961c698 100644
--- a/examples/wayland/multi-screen/qml/main.qml
+++ b/examples/wayland/multi-screen/qml/main.qml
@@ -39,38 +39,37 @@
**
****************************************************************************/
+import QtQml 2.2
import QtQuick 2.0
+import QtQuick.Window 2.3 as Window
import QtWayland.Compositor 1.0
+import QtQml.Models 2.1
WaylandCompositor {
id: comp
- defaultOutput: middleScreen
- Screen {
- id: leftScreen
- position.x: -leftScreen.surfaceArea.width
- position.y: 0
- surfaceArea.color: "#f00"
- text: "Left"
- compositor: comp
+ ListModel {
+ id: emulatedScreens
+ ListElement { name: "left"; virtualX: 0; virtualY: 0; width: 800; height: 600 }
+ ListElement { name: "middle"; virtualX: 800; virtualY: 0; width: 800; height: 600 }
+ ListElement { name: "right"; virtualX: 1600; virtualY: 0; width: 800; height: 600 }
}
- Screen {
- id: middleScreen
- position.x: leftScreen.position.x + leftScreen.surfaceArea.width
- position.y: 0
- text: "Middle"
- surfaceArea.color: "#0f0"
- compositor: comp
- }
+ property bool emulated: Qt.application.screens.length < 2
+
+ Instantiator {
+ id: screens
+ model: emulated ? emulatedScreens : Qt.application.screens
- Screen {
- id: rightScreen
- position.x: middleScreen.position.x + middleScreen.surfaceArea.width
- position.y: 0
- surfaceArea.color: "#00f"
- text: "Right"
- compositor: comp
+ delegate: Screen {
+ surfaceArea.color: "lightsteelblue"
+ text: name
+ compositor: comp
+ targetScreen: modelData
+ Component.onCompleted: if (!comp.defaultOutput) comp.defaultOutput = this
+ position: Qt.point(virtualX, virtualY)
+ windowed: emulated
+ }
}
Component {
@@ -85,10 +84,6 @@ WaylandCompositor {
Item {
id: rootItem
- x: leftScreen.position.x
- y: leftScreen.position.y
- width: leftScreen.surfaceArea.width + middleScreen.surfaceArea.width + rightScreen.surfaceArea.width
- height: Math.max(leftScreen.surfaceArea.height, middleScreen.surfaceArea.height, rightScreen.surfaceArea.height)
}
WlShell {
@@ -117,11 +112,12 @@ WaylandCompositor {
function handleShellSurfaceCreated(shellSurface) {
var moveItem = moveItemComponent.createObject(rootItem, {
+ "x": screens.objectAt(0).position.x,
+ "y": screens.objectAt(0).position.y,
"width": Qt.binding(function() { return shellSurface.surface.width; }),
"height": Qt.binding(function() { return shellSurface.surface.height; })
});
- createShellSurfaceItem(shellSurface, moveItem, middleScreen);
- createShellSurfaceItem(shellSurface, moveItem, leftScreen);
- createShellSurfaceItem(shellSurface, moveItem, rightScreen);
+ for (var i = 0; i < screens.count; ++i)
+ createShellSurfaceItem(shellSurface, moveItem, screens.objectAt(i));
}
}