diff --git a/shell/plugins/background/Background.qml b/shell/plugins/background/Background.qml index 283e99c70eae..6585d4abc82c 100644 --- a/shell/plugins/background/Background.qml +++ b/shell/plugins/background/Background.qml @@ -119,6 +119,12 @@ Item { failedBackground = "" revealStartedVersion = -1 + // OWE draws a video background and fades the last still into it. That + // still stays on screen until OWE has the first frame and suspends this + // layer, so the desktop does not show an empty background meanwhile. A + // running reveal finishes on its incoming still, which OWE fades from. + if (!instant && !root.suspended && displayedBackground && isVideo(path) && !isVideo(displayedBackground)) return + revealAnimation.stop() finishingTransition = false @@ -326,7 +332,10 @@ Item { easing.type: Easing.OutCubic onFinished: { if (root.incomingBackground) { - root.displayedBackground = root.currentBackground || root.incomingBackground + // After a video was chosen during the reveal, the incoming still + // stays until OWE takes the background. + root.displayedBackground = root.currentBackground && !root.isVideo(root.currentBackground) + ? root.currentBackground : root.incomingBackground root.finishingTransition = true } root.revealProgress = 1 diff --git a/test/shell.d/background-pending-theme-test.sh b/test/shell.d/background-pending-theme-test.sh index 8e82a0c823dd..5d48011ef81a 100755 --- a/test/shell.d/background-pending-theme-test.sh +++ b/test/shell.d/background-pending-theme-test.sh @@ -14,6 +14,7 @@ ln -s "$ROOT/shell/plugins/background" "$stage/background" ln -s "$ROOT/shell/Commons" "$stage/Commons" ln -s "$ROOT/shell/Ui" "$stage/Ui" magick -size 128x128 xc:magenta "$stage/still.png" +magick -size 128x128 xc:cyan "$stage/home/next.png" ln -s "$stage/still.png" "$stage/home/.local/state/omarchy/current/background" python3 - "$ROOT/shell/shell.qml" "$SHELL_TEST_DIR/fixtures/background-pending-theme/shell.qml" "$stage/shell.qml" <<'PY' import re @@ -26,5 +27,6 @@ fixture = Path(sys.argv[2]).read_text() Path(sys.argv[3]).write_text(fixture.replace(' // APPLY_THEME_FUNCTION', method.group())) PY output=$(HOME="$stage/home" timeout 10 quickshell -p "$stage" --no-color 2>&1) || fail "pending theme fixture exits cleanly" "$output" -[[ $output == *"RESULT pass"* && $output != *"RESULT fail"* ]] || fail "the authoritative palette survives the previous background fallback timer" "$output" +[[ $output == *"RESULT pass"* && $output != *"RESULT fail"* ]] || fail "the palette survives the fallback timer, and a still covers the desktop until OWE takes a video" "$output" pass "a pending still transition cannot restore old colors after the current theme is applied" +pass "a video chosen during a reveal keeps the stills on screen, and the reveal ends on its still" diff --git a/test/shell.d/fixtures/background-pending-theme/shell.qml b/test/shell.d/fixtures/background-pending-theme/shell.qml index 55b83f3febeb..831a52b37745 100644 --- a/test/shell.d/fixtures/background-pending-theme/shell.qml +++ b/test/shell.d/fixtures/background-pending-theme/shell.qml @@ -7,6 +7,13 @@ import "background" as BackgroundPlugin ShellRoot { id: shell function firstPartyServiceFor(id) { return id === "omarchy.background" ? background : null } + property bool failed: false + function check(ok, message) { + if (!ok) { + failed = true + console.log("RESULT fail " + message) + } + } BackgroundPlugin.Background { id: background } // APPLY_THEME_FUNCTION @@ -25,11 +32,29 @@ ShellRoot { interval: 1300 running: true onTriggered: { - if (Qt.colorEqual(Commons.Color.accent, "#123456")) { - console.log("RESULT pass") - } else { - console.log("RESULT fail previous colors returned: " + Commons.Color.accent) - } + shell.check(Qt.colorEqual(Commons.Color.accent, "#123456"), "previous colors returned: " + Commons.Color.accent) + + // OWE fades the last still into a video and suspends this layer after + // the video's first frame. Until then the stills must cover the desktop, + // also when the video is chosen during a reveal. + background.setBackground(Quickshell.env("HOME") + "/next.png", false) + background.setBackground("/backgrounds/clip.mp4", false) + shell.check(background.displayedBackground.endsWith("/still.png") && background.incomingBackground.endsWith("/next.png"), + "a video keeps the reveal's stills: " + background.displayedBackground) + revealEnd.running = true + } + } + Timer { + id: revealEnd + interval: 50 + repeat: true + property int ticks: 0 + onTriggered: { + ticks += 1 + if (background.incomingBackground && ticks < 80) return + running = false + shell.check(background.displayedBackground.endsWith("/next.png"), "the reveal ends on its still, not on the video: " + background.displayedBackground) + if (!shell.failed) console.log("RESULT pass") Qt.quit() } }