summaryrefslogtreecommitdiffstats
path: root/examples/wayland
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-05-24 10:32:21 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-05-29 16:48:43 +0000
commit5cba07a66225d6ecedb1d9e952d272e236f30aa8 (patch)
tree61463a8f78e331bacb3b350603a7acf7d662d282 /examples/wayland
parent7a74426e10d209f716114c14d658cc6086f9023a (diff)
Use WaylandCursorItem over clients, window system cursor otherwise
The pre-existing binding visible: cursorItem.surface != null implied that the surface would often be null; but in practice it was only null at startup. After entering a client window, whatever cursor it set would be retained when the mouse left the window. With client- side decorations, this could go unnoticed, because often the mouse would go across the titlebar or edge decorations on exit, and those would set the cursor back to a standard arrow. But in compositors that implement a lot of Qt Quick content of their own (server-side decorations and/or built-in features such as menus, docks etc.), that content cannot change the cursor that the WaylandCursorItem shows. Instead, we need the underlying window system cursor to be shown whenever the mouse is not hovering over a client window. As a drive-by, remove the inputEventsEnabled: false declarations from the examples, because WaylandCursorItem already does that internally. The pure-qml example is not fixed; it shows the window system cursor only when the compositor is a nested compositor. When it's not nested, you just have to move the mouse slowly enough to avoid "jumping over" the window edges. Or run clients that don't change the cursor. Fixes: QTBUG-84391 Change-Id: I3e677f3e4314d01e5d27d8eea49b4cb315c29d03 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io> (cherry picked from commit 0b253e8c595b596f44959d21124887545ab0b021) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/wayland')
-rw-r--r--examples/wayland/custom-extension/compositor/qml/Screen.qml5
-rw-r--r--examples/wayland/multi-output/qml/ShellScreen.qml7
-rw-r--r--examples/wayland/multi-screen/qml/Screen.qml5
3 files changed, 8 insertions, 9 deletions
diff --git a/examples/wayland/custom-extension/compositor/qml/Screen.qml b/examples/wayland/custom-extension/compositor/qml/Screen.qml
index 1e6d3e402..9c46a2035 100644
--- a/examples/wayland/custom-extension/compositor/qml/Screen.qml
+++ b/examples/wayland/custom-extension/compositor/qml/Screen.qml
@@ -121,7 +121,7 @@ WaylandOutput {
anchors.top: parent.top
anchors.bottom: parent.bottom
- windowSystemCursorEnabled: true
+ windowSystemCursorEnabled: !clientCursor.visible
Image {
id: background
anchors.fill: parent
@@ -130,8 +130,7 @@ WaylandOutput {
smooth: false
}
WaylandCursorItem {
- id: cursor
- inputEventsEnabled: false
+ id: clientCursor
x: mouseTracker.mouseX
y: mouseTracker.mouseY
diff --git a/examples/wayland/multi-output/qml/ShellScreen.qml b/examples/wayland/multi-output/qml/ShellScreen.qml
index aa9b4b29b..20a0e80ac 100644
--- a/examples/wayland/multi-output/qml/ShellScreen.qml
+++ b/examples/wayland/multi-output/qml/ShellScreen.qml
@@ -66,7 +66,7 @@ WaylandOutput {
id: mouseTracker
anchors.fill: parent
- windowSystemCursorEnabled: true
+ windowSystemCursorEnabled: !clientCursor.visible
Image {
id: background
anchors.fill: parent
@@ -75,11 +75,10 @@ WaylandOutput {
smooth: true
}
WaylandCursorItem {
- id: cursor
- inputEventsEnabled: false
+ id: clientCursor
x: mouseTracker.mouseX
y: mouseTracker.mouseY
-
+ visible: surface !== null && mouseTracker.containsMouse
seat : output.compositor.defaultSeat
}
}
diff --git a/examples/wayland/multi-screen/qml/Screen.qml b/examples/wayland/multi-screen/qml/Screen.qml
index 21f2d1266..edf842c0c 100644
--- a/examples/wayland/multi-screen/qml/Screen.qml
+++ b/examples/wayland/multi-screen/qml/Screen.qml
@@ -74,7 +74,7 @@ WaylandOutput {
WaylandMouseTracker {
id: mouseTracker
anchors.fill: parent
- windowSystemCursorEnabled: false
+ windowSystemCursorEnabled: !clientCursor.visible
Rectangle {
anchors.fill: parent
@@ -88,11 +88,12 @@ WaylandOutput {
}
WaylandCursorItem {
+ id: clientCursor
inputEventsEnabled: false
x: mouseTracker.mouseX
y: mouseTracker.mouseY
seat: comp.defaultSeat
- visible: mouseTracker.containsMouse
+ visible: surface !== null && mouseTracker.containsMouse
}
}
Shortcut {