diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-05-24 10:32:21 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-05-29 18:21:57 +0200 |
commit | 0b253e8c595b596f44959d21124887545ab0b021 (patch) | |
tree | 95e15297ffae5472280014c297579644d53bbdb4 | |
parent | be7d24184f226fac9977e9d14e4b29ae3d5cd51f (diff) | |
download | qtwayland-0b253e8c595b596f44959d21124887545ab0b021.tar.gz |
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.
Pick-to: 5.15
Fixes: QTBUG-84391
Change-Id: I3e677f3e4314d01e5d27d8eea49b4cb315c29d03
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
4 files changed, 9 insertions, 9 deletions
diff --git a/examples/wayland/custom-extension/compositor/qml/Screen.qml b/examples/wayland/custom-extension/compositor/qml/Screen.qml index 1e6d3e40..9c46a203 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 aa9b4b29..20a0e80a 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 21f2d126..edf842c0 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 { diff --git a/src/compositor/compositor_api/qwaylandpointer.cpp b/src/compositor/compositor_api/qwaylandpointer.cpp index 38cb5d7f..9e8bfff1 100644 --- a/src/compositor/compositor_api/qwaylandpointer.cpp +++ b/src/compositor/compositor_api/qwaylandpointer.cpp @@ -93,6 +93,7 @@ void QWaylandPointerPrivate::sendLeave() enteredSurface = nullptr; localPosition = QPointF(); enteredSurfaceDestroyListener.reset(); + seat->cursorSurfaceRequest(nullptr, 0, 0); } void QWaylandPointerPrivate::ensureEntered(QWaylandSurface *surface) |