2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
|
2018-06-09 13:19:50 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2023-03-11 10:29:24 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
2018-06-09 13:19:50 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2018-07-18 07:06:56 +00:00
|
|
|
Connections {
|
|
|
|
target: org_kde_kwin_tests_pointerconstraints_backend
|
2020-11-11 16:44:38 +00:00
|
|
|
function onForceSurfaceCommit() {
|
2018-07-18 07:06:56 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-09 13:19:50 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-18 07:06:56 +00:00
|
|
|
CheckBox {
|
|
|
|
id: lockHintChck
|
|
|
|
text: "Send position hint on lock"
|
|
|
|
checked: root.waylandNative
|
|
|
|
enabled: root.waylandNative
|
|
|
|
onCheckedChanged: org_kde_kwin_tests_pointerconstraints_backend.lockHint = checked;
|
|
|
|
}
|
2018-06-09 13:19:50 +00:00
|
|
|
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() {
|
2024-01-23 11:47:05 +00:00
|
|
|
const scenePosition = mapToItem(null, x, y);
|
|
|
|
return Qt.rect(scenePosition.x, scenePosition.y, width, height);
|
2018-06-09 13:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
2018-06-10 17:50:23 +00:00
|
|
|
onClicked: root.unconfine()
|
2018-06-09 13:19:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|