blob: 5e6930d20add759b640630d406cb5c8edbbb4e44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtWayland.Compositor
import QtWayland.Compositor.XdgShell
import QtQuick.Window
import QtQuick.Controls 2.0
WaylandCompositor {
WaylandOutput {
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
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))
// ![zoom transform]
transform: [
Scale {
xScale: grid.overview ? (1.0/grid.columns) : 1
yScale: grid.overview ? (1.0/grid.columns) : 1
Behavior on xScale { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 200 } }
Behavior on yScale { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 200 } }
},
Translate {
x: grid.overview ? 0 : win.width * -grid.selectedColumn
y: grid.overview ? 0 : win.height * -grid.selectedRow
Behavior on x { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 200 } }
Behavior on y { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 200 } }
}
]
// ![zoom transform]
// ![toplevels repeater]
Repeater {
model: toplevels
Item {
width: win.width
height: win.height
ShellSurfaceItem {
anchors.fill: parent
shellSurface: xdgSurface
onSurfaceDestroyed: toplevels.remove(index)
}
MouseArea {
enabled: grid.overview
anchors.fill: parent
onClicked: {
grid.selected = index;
grid.overview = false;
}
}
}
}
// ![toplevels repeater]
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
text: "Toggle overview";
onClicked: grid.overview = !grid.overview
}
Shortcut { sequence: "space"; onActivated: grid.overview = !grid.overview }
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, toplevels.count-1) }
}
}
ListModel { id: toplevels }
// ![XdgShell]
XdgShell {
onToplevelCreated: {
toplevels.append({xdgSurface});
toplevel.sendFullscreen(Qt.size(win.pixelWidth, win.pixelHeight));
}
}
// ![XdgShell]
}
|