From f54d10c335504ddafb2d253dfb5136f9dd14cfae Mon Sep 17 00:00:00 2001 From: Bjarne Oeverli Date: Fri, 30 Oct 2026 13:54:48 +0100 Subject: [PATCH 1/2] Keep the still on screen until OWE takes a video background A switch from a still to a video cleared the shell's still at once. The background layer turned transparent before OWE had a frame, so the desktop showed an old frame of OWE's parked renderer or an empty background. OWE then drew the still again and faded it into the video, so the switch flickered before the fade. The layer now keeps the current still when the next background is a video, until OWE suspends the layer after the video's first frame. OWE fades from the same still, so the switch is one fade. A switch with a suspended layer, an instant switch, and a switch from a video work as before. test/shell.d/background-video-keeps-still-test.sh checks both cases. --- shell/plugins/background/Background.qml | 12 ++++++ .../background-video-keeps-still-test.sh | 25 ++++++++++++ .../background-video-keeps-still/shell.qml | 38 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100755 test/shell.d/background-video-keeps-still-test.sh create mode 100644 test/shell.d/fixtures/background-video-keeps-still/shell.qml diff --git a/shell/plugins/background/Background.qml b/shell/plugins/background/Background.qml index 283e99c70eae..1e982f15a003 100644 --- a/shell/plugins/background/Background.qml +++ b/shell/plugins/background/Background.qml @@ -122,6 +122,18 @@ Item { revealAnimation.stop() finishingTransition = false + // 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. + if (!instant && !root.suspended && displayedBackground && isVideo(path) && !isVideo(displayedBackground)) { + if (incomingBackground) displayedBackground = incomingBackground + oldBackground = "" + incomingBackground = "" + preparedBackground = "" + revealProgress = 1 + return + } + // Video frames are not fed through the image-only reveal stack. Switching // instantly also avoids decoding two full videos during a transition. if (instant || !displayedBackground || isVideo(path) || isVideo(displayedBackground)) { diff --git a/test/shell.d/background-video-keeps-still-test.sh b/test/shell.d/background-video-keeps-still-test.sh new file mode 100755 index 000000000000..b26e8db4f4e3 --- /dev/null +++ b/test/shell.d/background-video-keeps-still-test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" +require_compositor "background still kept for a video" +require_command quickshell +require_command magick + +stage=$(mktemp -d) +trap 'rm -rf "$stage"' EXIT +mkdir -p "$stage/home/.local/state/omarchy/current" +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" +ln -s "$stage/still.png" "$stage/home/.local/state/omarchy/current/background" +cp "$SHELL_TEST_DIR/fixtures/background-video-keeps-still/shell.qml" "$stage/shell.qml" + +output=$(HOME="$stage/home" timeout 6 quickshell -p "$stage" --no-color 2>&1) || fail "video selection fixture exits cleanly" "$output" +[[ $output == *"RESULT pass"* && $output != *"RESULT fail"* ]] || fail "the still stays on screen until OWE suspends the layer" "$output" +if rg -q 'ReferenceError|TypeError|Unable to assign|Binding loop' <<<"$output"; then + fail "video selection fixture has no QML errors" "$output" +fi +pass "a video selection keeps the still on screen until OWE suspends the layer" diff --git a/test/shell.d/fixtures/background-video-keeps-still/shell.qml b/test/shell.d/fixtures/background-video-keeps-still/shell.qml new file mode 100644 index 000000000000..d7ce1867633e --- /dev/null +++ b/test/shell.d/fixtures/background-video-keeps-still/shell.qml @@ -0,0 +1,38 @@ +import QtQuick +import Quickshell +import "background" as BackgroundPlugin + +ShellRoot { + id: test + property bool failed: false + function check(ok, message) { + if (!ok) { + failed = true + console.log("RESULT fail " + message) + } + } + + BackgroundPlugin.Background { id: background } + + Timer { + interval: 600 + running: true + onTriggered: { + test.check(background.displayedBackground.endsWith("/still.png"), "the still is on screen") + + // OWE fades this still into the video, so the layer keeps it until OWE + // has the first frame and suspends the layer. + background.setBackground("/backgrounds/clip.mp4", false) + test.check(background.currentBackground === "/backgrounds/clip.mp4", "the video is the current background") + test.check(background.displayedBackground.endsWith("/still.png"), "the still stays on screen for the video") + + // A suspended layer shows nothing, so a video replaces the still at once. + background.suspended = true + background.setBackground("/backgrounds/other.mp4", false) + test.check(background.displayedBackground === "/backgrounds/other.mp4", "a suspended layer takes the video at once") + + if (!test.failed) console.log("RESULT pass") + Qt.quit() + } + } +} From 8117b0e28ffc1742e7633caad0d5afbc0eae5535 Mon Sep 17 00:00:00 2001 From: Bjarne Oeverli Date: Fri, 30 Oct 2026 14:18:07 +0100 Subject: [PATCH 2/2] Let a reveal finish when a video is chosen during it A video chosen during a reveal between 2 stills switched the base image to the incoming still and cleared the reveal's images at once. The base image loads on its own, so the desktop could show a blank frame or an old frame of OWE's renderer. The video selection now leaves a running or pending reveal alone. The reveal finishes on its incoming still, and the reveal's images cover the desktop until the base image is ready. That still is the one OWE fades from. At the end of the reveal, a video as the current background no longer replaces the still. The test moves into background-pending-theme-test.sh and reuses its setup and Quickshell launch. It chooses a video while a reveal is pending and checks that the stills stay on screen and that the reveal ends on its still. --- shell/plugins/background/Background.qml | 23 +++++------ test/shell.d/background-pending-theme-test.sh | 4 +- .../background-video-keeps-still-test.sh | 25 ------------ .../background-pending-theme/shell.qml | 35 ++++++++++++++--- .../background-video-keeps-still/shell.qml | 38 ------------------- 5 files changed, 43 insertions(+), 82 deletions(-) delete mode 100755 test/shell.d/background-video-keeps-still-test.sh delete mode 100644 test/shell.d/fixtures/background-video-keeps-still/shell.qml diff --git a/shell/plugins/background/Background.qml b/shell/plugins/background/Background.qml index 1e982f15a003..6585d4abc82c 100644 --- a/shell/plugins/background/Background.qml +++ b/shell/plugins/background/Background.qml @@ -119,20 +119,14 @@ Item { failedBackground = "" revealStartedVersion = -1 - revealAnimation.stop() - finishingTransition = false - // 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. - if (!instant && !root.suspended && displayedBackground && isVideo(path) && !isVideo(displayedBackground)) { - if (incomingBackground) displayedBackground = incomingBackground - oldBackground = "" - incomingBackground = "" - preparedBackground = "" - revealProgress = 1 - return - } + // 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 // Video frames are not fed through the image-only reveal stack. Switching // instantly also avoids decoding two full videos during a transition. @@ -338,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/background-video-keeps-still-test.sh b/test/shell.d/background-video-keeps-still-test.sh deleted file mode 100755 index b26e8db4f4e3..000000000000 --- a/test/shell.d/background-video-keeps-still-test.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" -require_compositor "background still kept for a video" -require_command quickshell -require_command magick - -stage=$(mktemp -d) -trap 'rm -rf "$stage"' EXIT -mkdir -p "$stage/home/.local/state/omarchy/current" -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" -ln -s "$stage/still.png" "$stage/home/.local/state/omarchy/current/background" -cp "$SHELL_TEST_DIR/fixtures/background-video-keeps-still/shell.qml" "$stage/shell.qml" - -output=$(HOME="$stage/home" timeout 6 quickshell -p "$stage" --no-color 2>&1) || fail "video selection fixture exits cleanly" "$output" -[[ $output == *"RESULT pass"* && $output != *"RESULT fail"* ]] || fail "the still stays on screen until OWE suspends the layer" "$output" -if rg -q 'ReferenceError|TypeError|Unable to assign|Binding loop' <<<"$output"; then - fail "video selection fixture has no QML errors" "$output" -fi -pass "a video selection keeps the still on screen until OWE suspends the layer" 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() } } diff --git a/test/shell.d/fixtures/background-video-keeps-still/shell.qml b/test/shell.d/fixtures/background-video-keeps-still/shell.qml deleted file mode 100644 index d7ce1867633e..000000000000 --- a/test/shell.d/fixtures/background-video-keeps-still/shell.qml +++ /dev/null @@ -1,38 +0,0 @@ -import QtQuick -import Quickshell -import "background" as BackgroundPlugin - -ShellRoot { - id: test - property bool failed: false - function check(ok, message) { - if (!ok) { - failed = true - console.log("RESULT fail " + message) - } - } - - BackgroundPlugin.Background { id: background } - - Timer { - interval: 600 - running: true - onTriggered: { - test.check(background.displayedBackground.endsWith("/still.png"), "the still is on screen") - - // OWE fades this still into the video, so the layer keeps it until OWE - // has the first frame and suspends the layer. - background.setBackground("/backgrounds/clip.mp4", false) - test.check(background.currentBackground === "/backgrounds/clip.mp4", "the video is the current background") - test.check(background.displayedBackground.endsWith("/still.png"), "the still stays on screen for the video") - - // A suspended layer shows nothing, so a video replaces the still at once. - background.suspended = true - background.setBackground("/backgrounds/other.mp4", false) - test.check(background.displayedBackground === "/backgrounds/other.mp4", "a suspended layer takes the video at once") - - if (!test.failed) console.log("RESULT pass") - Qt.quit() - } - } -}