summaryrefslogtreecommitdiffstats
path: root/tests/manual/scaling-compositor/main.qml
blob: f173de3a0c58b77337b3cae13c266791e73c8e8e (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
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQuick 2.15
import QtQuick.Window 2.2
import QtWayland.Compositor 1.3
import QtWayland.Compositor.WlShell
import QtWayland.Compositor.XdgShell

WaylandCompositor {
    id: comp
    WaylandOutput {
        id: output
        compositor: comp
        sizeFollowsWindow: true
        scaleFactor: 2
        window: Window {
            id: win
            width: 500
            height: 500
            visible: true
            title: "Scaling compositor x" + output.scaleFactor

            Repeater {
                model: shellSurfaces
                ShellSurfaceItem {
                    shellSurface: modelData
                    onSurfaceDestroyed: shellSurfaces.remove(index);
                }
            }

            Rectangle {
                id: incrementButton
                color: "#c0f0d0"
                Text {
                    text: "+"
                }
                width: 100
                height: 30
                TapHandler {
                    onTapped: ++output.scaleFactor
                }
            }

            Rectangle {
                id: decrementButton
                color: "#f0d0c0"
                Text {
                    text: "-"
                }
                width: 100
                height: 30
                TapHandler {
                    onTapped: output.scaleFactor = Math.max(1, output.scaleFactor - 1)
                }
                anchors.left: incrementButton.right
            }
        }
    }

    ListModel { id: shellSurfaces }

    WlShell {
        onWlShellSurfaceCreated: shellSurfaces.append({shellSurface: shellSurface});
    }
    XdgShell {
        onToplevelCreated:
            shellSurfaces.append({shellSurface: xdgSurface});
    }
}