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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
/*
SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
ColumnLayout {
/* for margins */
ColumnLayout {
id: root
focus: true
Layout.margins: 20
function lock() {
org_kde_kwin_tests_pointerconstraints_backend.lockRequest(lockPersChck.checked, root.activRect());
}
function confine() {
org_kde_kwin_tests_pointerconstraints_backend.confineRequest(confPersChck.checked, root.activRect());
}
function unlock() {
org_kde_kwin_tests_pointerconstraints_backend.unlockRequest();
}
function unconfine() {
org_kde_kwin_tests_pointerconstraints_backend.unconfineRequest();
}
function hideAndConfine() {
org_kde_kwin_tests_pointerconstraints_backend.hideAndConfineRequest();
}
function undoHideAndConfine() {
org_kde_kwin_tests_pointerconstraints_backend.undoHideRequest();
}
property bool waylandNative: org_kde_kwin_tests_pointerconstraints_backend.mode === 0
Keys.onPressed: {
if (event.key === Qt.Key_L) {
root.lock();
event.accepted = true;
} else if (event.key === Qt.Key_C) {
root.confine();
event.accepted = true;
} else if (event.key === Qt.Key_K) {
root.unlock();
event.accepted = true;
} else if (event.key === Qt.Key_X) {
root.unconfine();
event.accepted = true;
} else if (event.key === Qt.Key_H) {
root.hideAndConfine();
event.accepted = true;
} else if (event.key === Qt.Key_G) {
root.undoHideAndConfine();
event.accepted = true;
}
}
function activRect() {
if (fullWindowChck.checked) {
return Qt.rect(0, 0, -1, -1);
}
return activArea.rect();
}
Connections {
target: org_kde_kwin_tests_pointerconstraints_backend
function onForceSurfaceCommit() {
forceCommitRect.visible = true
}
}
Rectangle {
id: forceCommitRect
width: 10
height: 10
color: "red"
visible: false
Timer {
interval: 500
running: forceCommitRect.visible
repeat: false
onTriggered: forceCommitRect.visible = false;
}
}
GridLayout {
columns: 2
rowSpacing: 10
columnSpacing: 10
Button {
id: lockButton
text: "Lock pointer"
onClicked: root.lock()
}
CheckBox {
id: lockPersChck
text: "Persistent lock"
checked: root.waylandNative
enabled: root.waylandNative
}
Button {
id: confButton
text: "Confine pointer"
onClicked: root.confine()
}
CheckBox {
id: confPersChck
text: "Persistent confine"
checked: root.waylandNative
enabled: root.waylandNative
}
Button {
id: hideConfButton
text: "Hide and confine pointer"
onClicked: root.hideAndConfine()
visible: !root.waylandNative
}
CheckBox {
id: confBeforeHideChck
text: "Confine first, then hide"
checked: false
visible: !root.waylandNative
}
}
CheckBox {
id: lockHintChck
text: "Send position hint on lock"
checked: root.waylandNative
enabled: root.waylandNative
onCheckedChanged: org_kde_kwin_tests_pointerconstraints_backend.lockHint = checked;
}
CheckBox {
id: restrAreaChck
text: "Restrict input area (not yet implemented)"
enabled: false
}
CheckBox {
id: fullWindowChck
text: "Full window area activates"
checked: !root.waylandNative
enabled: root.waylandNative
}
CheckBox {
id: errorsChck
text: "Allow critical errors"
checked: false
enabled: root.waylandNative
onCheckedChanged: org_kde_kwin_tests_pointerconstraints_backend.errorsAllowed = checked;
}
Item {
width: childrenRect.width
height: childrenRect.height
Rectangle {
id: activArea
width: 400
height: 200
enabled: root.waylandNative && !fullWindowChck.checked
function rect() {
const scenePosition = mapToItem(null, x, y);
return Qt.rect(scenePosition.x, scenePosition.y, width, height);
}
border.color: enabled ? "black" : "lightgrey"
border.width: 2
Label {
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
text: "Activation area"
}
}
Button {
id: unconfButton
anchors.horizontalCenter: activArea.horizontalCenter
anchors.verticalCenter: activArea.verticalCenter
text: "Unconfine pointer"
onClicked: root.unconfine()
}
}
Label {
text: "Lock: L / Unlock: K"
}
Label {
text: "Confine: C / Unconfine: X"
}
Label {
text: "Hide cursor and confine pointer: H / undo hide: G"
visible: !root.waylandNative
}
}
}
|