fix(qt): rename the Wallpaper field's platform flag off the handler namespace

The field's platform flag was named `onWayland`. With no `wayland` member
beside it the binding happens to work, but the on-prefixed property audit
(which qt-run.sh runs) rejects any `on<Upper>` name, and an instance
cannot assign it: `onWayland: false` is parsed as a handler for a
nonexistent signal and the component fails to load. It is `isWayland`
now, writable so a test can take the Wayland branch under the offscreen
platform, and a change of it also asks Rust to follow the window.

tst_wallpaper_field covers the Qt position on X11 / macOS / Windows, the
compositor rectangle picked by this window's size on Wayland (a
miniplayer-sized window is ignored, a move is followed), the centred
fallback, and an invisible field that reads nothing. It runs in the
runtime gate.

cc
This commit is contained in:
vicrodh committed 2026-09-14 06:07:14 -06:00
1 parent 354a38f16c
commit 6b1fcd30ab
6 files changed
+122 -7

No files matched your search

+2
View File
@@ -88,6 +88,7 @@ on:
- "scripts/test-library-folders-qml.sh"
- "scripts/test-array-model-qml.sh"
- "scripts/test-keyed-model-qml.sh"
- "scripts/test-wallpaper-field-qml.sh"
- "scripts/test-card-menu-qml.sh"
- "scripts/test-orbit-daemon.py"
- ".github/workflows/test-crates.yml"
@@ -119,6 +120,7 @@ on:
- "scripts/test-library-folders-qml.sh"
- "scripts/test-array-model-qml.sh"
- "scripts/test-keyed-model-qml.sh"
- "scripts/test-wallpaper-field-qml.sh"
- "scripts/test-card-menu-qml.sh"
- "scripts/test-orbit-daemon.py"
- ".github/workflows/test-crates.yml"
+10 -6
View File
@@ -36,23 +36,27 @@ Item {
clip: true
readonly property bool onWayland: Qt.platform.pluginName === "wayland"
/// Where the window's place comes from: the compositor's report on
/// Wayland, Qt everywhere else. Writable only so a test can take the
/// Wayland branch under the offscreen platform.
property bool isWayland: Qt.platform.pluginName === "wayland"
// Ask the compositor as soon as this field is actually painting on a
// Wayland session (idempotent on the Rust side; a no-op elsewhere).
function _track() {
if (root.visible && root.onWayland && root.source !== "")
if (root.visible && root.isWayland && root.source !== "")
QbzShell.trackWindowPosition()
}
onVisibleChanged: _track()
onSourceChanged: _track()
onIsWaylandChanged: _track()
Component.onCompleted: _track()
// Read only while this field is the background: the tracker keeps
// reporting moves after the mode is switched away, and an invisible item
// whose geometry changes still dirties the window (the repaint rule).
readonly property var compositorRects: {
if (!root.visible || !root.onWayland)
if (!root.visible || !root.isWayland)
return []
try {
var a = JSON.parse(QbzShell.wallpaperWindowsJson || "[]")
@@ -89,16 +93,16 @@ Item {
}
readonly property bool positionKnown: root.visible && root.hostWindow !== null
&& (!root.onWayland || root.compositorRect !== null)
&& (!root.isWayland || root.compositorRect !== null)
readonly property real screenW: Math.max(1, Screen.width)
readonly property real screenH: Math.max(1, Screen.height)
// The window's origin inside its screen; centred when unknown.
readonly property real offX: !root.positionKnown
? Math.max(0, (root.screenW - root.width) / 2)
: (root.onWayland ? root.compositorRect.x : root.hostWindow.x) - Screen.virtualX
: (root.isWayland ? root.compositorRect.x : root.hostWindow.x) - Screen.virtualX
readonly property real offY: !root.positionKnown
? Math.max(0, (root.screenH - root.height) / 2)
: (root.onWayland ? root.compositorRect.y : root.hostWindow.y) - Screen.virtualY
: (root.isWayland ? root.compositorRect.y : root.hostWindow.y) - Screen.virtualY
Image {
id: picture
@@ -7,4 +7,7 @@ QtObject {
property string restoreScope: ""
property real scrollRestore: 0
function reportScroll(scope, y) {}
property string themeJson: ""; property int ambientMode: 0 }
property string themeJson: ""; property int ambientMode: 0
property string wallpaperWindowsJson: "[]"
property int trackRequests: 0
function trackWindowPosition() { trackRequests++ } }
+85
View File
@@ -0,0 +1,85 @@
// WallpaperField: the wallpaper crop sits under the window. On X11 / macOS /
// Windows the offset is the window's own position; on Wayland it is the
// compositor's rectangle for this window (picked by size out of this
// process's windows); with neither, the crop is centred. An invisible field
// reads nothing and asks for nothing.
import QtQuick
import QtQuick.Window
import QtTest
import com.blitzfc.qbz
import "../../crates/qbz-qt/qml/shell"
Item {
id: root
width: 800; height: 600
QtObject {
id: fakeWindow
property real x: 300
property real y: 100
property real width: 800
property real height: 600
}
WallpaperField {
id: field
width: 800; height: 600
hostWindow: fakeWindow
source: Qt.resolvedUrl("fixtures/red.ppm")
isWayland: false
}
TestCase {
name: "WallpaperField"
when: windowShown
function init() {
QbzShell.wallpaperWindowsJson = "[]"
field.visible = true
field.isWayland = false
fakeWindow.x = 300
fakeWindow.y = 100
}
function test_a_x11_follows_the_window_position() {
compare(field.offX, 300 - Screen.virtualX)
compare(field.offY, 100 - Screen.virtualY)
fakeWindow.x = 20
compare(field.offX, 20 - Screen.virtualX)
}
function test_b_wayland_uses_the_compositor_rect_for_this_window() {
var before = QbzShell.trackRequests
field.isWayland = true
verify(QbzShell.trackRequests > before, "asks Rust to follow the window")
// Without a report the crop is centred.
verify(!field.positionKnown)
compare(field.offX, Math.max(0, (field.screenW - 800) / 2))
// Two of our windows: the miniplayer and the main window.
QbzShell.wallpaperWindowsJson = JSON.stringify([
{ "x": 10, "y": 10, "w": 320, "h": 96 },
{ "x": 640, "y": 120, "w": 800, "h": 600 }
])
verify(field.positionKnown)
compare(field.offX, 640 - Screen.virtualX)
compare(field.offY, 120 - Screen.virtualY)
// The window moved: the compositor says so.
QbzShell.wallpaperWindowsJson = JSON.stringify([{ "x": 900, "y": 40, "w": 800, "h": 600 }])
compare(field.offX, 900 - Screen.virtualX)
}
function test_c_wayland_ignores_windows_that_are_not_this_size() {
field.isWayland = true
QbzShell.wallpaperWindowsJson = JSON.stringify([{ "x": 10, "y": 10, "w": 320, "h": 96 }])
verify(!field.positionKnown, "the miniplayer is not this window")
}
function test_d_invisible_field_reads_nothing() {
field.isWayland = true
QbzShell.wallpaperWindowsJson = JSON.stringify([{ "x": 640, "y": 120, "w": 800, "h": 600 }])
field.visible = false
compare(field.compositorRects.length, 0)
verify(!field.positionKnown)
}
}
}
+1
View File
@@ -11,6 +11,7 @@ bash scripts/test-compact-seek-qml.sh
bash scripts/test-library-folders-qml.sh
bash scripts/test-array-model-qml.sh
bash scripts/test-keyed-model-qml.sh
bash scripts/test-wallpaper-field-qml.sh
bash scripts/test-card-menu-qml.sh
bash scripts/test-orbit-qml.sh
node scripts/test_qt_local_views.mjs
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# WallpaperField regression: the Wallpaper background's crop follows the
# window — Qt's position on X11/macOS/Windows, the compositor's rectangle for
# this window on Plasma Wayland, centred otherwise — and an invisible field
# reads nothing. Same run in CI and locally.
set -euo pipefail
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
if [[ -n "${QT_ROOT_DIR:-}" ]]; then
qt_wallpaper_bins="$QT_ROOT_DIR/bin"
else
qt_wallpaper_qmake="${QMAKE:-}"
if [[ -z "$qt_wallpaper_qmake" ]]; then
qt_wallpaper_qmake="$(command -v qmake6 || command -v qmake)"
fi
qt_wallpaper_bins="$("$qt_wallpaper_qmake" -query QT_INSTALL_BINS)"
fi
QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=software \
"$qt_wallpaper_bins/qmltestrunner" \
-input scripts/qml-tests/tst_wallpaper_field.qml \
-import scripts/qml-tests/imports