summaryrefslogtreecommitdiffstats
path: root/examples/wayland/custom-extension/compositor/qml/CompositorScreen.qml
blob: 724c0975a1cb5c19b8ce23dc16495f06d74a7f56 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Window
import QtWayland.Compositor

WaylandOutput {
    id: output
    property alias surfaceArea: background
    sizeFollowsWindow: true
    window: Window {
        id: screen

        property QtObject output

        width: 1600
        height: 900
        visible: true

        Rectangle {
            id: sidebar
            width: 150
            anchors.left: parent.left
            anchors.top: parent.top
            anchors.bottom: parent.bottom
            color: "lightgray"
            Column {
                anchors.top: parent.top
                anchors.left: parent.left
                anchors.right: parent.right
                spacing: 5

                Repeater {
                    model: comp.itemList
                    Rectangle {
                        height: 36
                        width: sidebar.width - 5
                        color: "white"
                        radius: 5
                        Text {
                            text: "window: " + modelData.shellSurface.title + "[" + modelData.shellSurface.className
                                  + (modelData.isCustom ? "]\nfont size: " + modelData.fontSize :"]\n No extension")
                            color: modelData.isCustom ? "black" : "darkgray"
                        }
                        MouseArea {
                            enabled: modelData.isCustom
                            anchors.fill: parent
                            onWheel: {
                                if (wheel.angleDelta.y > 0)
                                    modelData.fontSize++
                                else if (wheel.angleDelta.y < 0 && modelData.fontSize > 3)
                                    modelData.fontSize--
                            }
                            onDoubleClicked: {
                                output.compositor.customExtension.close(modelData.surface)
                            }
                        }
                    }
                }
                Text {
                    visible: comp.itemList.length > 0
                    width: sidebar.width - 5
                    text: "Mouse wheel to change font size. Double click to close"
                    wrapMode: Text.Wrap
                }
            }
        }

        WaylandMouseTracker {
            id: mouseTracker
            anchors.left: sidebar.right
            anchors.right: parent.right
            anchors.top: parent.top
            anchors.bottom: parent.bottom

            windowSystemCursorEnabled: !clientCursor.visible
            Image {
                id: background
                anchors.fill: parent
                fillMode: Image.Tile
                source: "qrc:/images/background.png"
                smooth: false
            }
            WaylandCursorItem {
                id: clientCursor
                x: mouseTracker.mouseX
                y: mouseTracker.mouseY

                seat: output.compositor.defaultSeat
            }

            Rectangle {
                anchors.top: parent.top
                anchors.right: parent.right
                width: 100
                height: 100
                property bool on : true
                color: on ? "#DEC0DE" : "#FACADE"
                Text {
                    anchors.fill: parent
                    text: "Toggle window decorations"
                    wrapMode: Text.WordWrap
                }

                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        parent.on = !parent.on
                        comp.setDecorations(parent.on);
                    }
                }
            }
        }
    }
}