summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-05-24 10:52:11 +0200
committerJohan Helsing <johan.helsing@qt.io>2018-05-28 08:25:47 +0000
commitd579651f7ef737d480791a2680eb57aa0e29c260 (patch)
tree0d51197b7c1a9d0092213f40a5193cab321e1d92 /examples
parent0794607a3a0dc68994b43dd5c605c23304e21138 (diff)
Revamp overview-compositor example
- Switch to xdg-shell v6 - Use autoCreatePopupItems - Follow QML coding conventions - Support for screen dpr != 1 Task-number: QTBUG-60661 Change-Id: Iad9547c0d7529c0fce8e9303c55b5c0b0ee0e27b Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/wayland/overview-compositor/main.qml39
1 files changed, 23 insertions, 16 deletions
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));
}
}
}