Files
omarchy/test/shell.d/lock-wallpaper-preload-test.sh
T
David Heinemeier HanssonandClaude Opus 5.5 387fcf599a Keep the lock wallpaper decoded so waking shows it with the password field (#13431)
The lock started decoding its wallpaper only once locked, with the cache
off, and first at the view's unsized native resolution. A machine
suspending right after locking froze that decode partway, so waking
showed the password field on a bare background and the wallpaper
popped in after it. On this machine the wallpaper took ~208ms to become
ready, and the suspend followed the lock by 66ms.

The lock service now keeps each screen's lock wallpaper decoded in the
image cache, as the lock view requests it: same URL, the screen's
logical size, PreserveAspectCrop. The view waits for its size and reads
from the cache, so the wallpaper is ready within ~3ms of the lock
starting. The version in the cached URL follows the file's mtime and
size, so a wallpaper overwritten in place still reloads.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 20:00:08 +02:00

43 lines
2.1 KiB
Bash

#!/bin/bash
set -euo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
run_node_test <<'JS'
const fs = require('fs')
const read = (file) => fs.readFileSync(path.join(root, file), 'utf8')
const media = read('shell/Ui/BackgroundMedia.qml')
const view = read('shell/plugins/lock/LockView.qml')
const service = read('shell/plugins/lock/Service.qml')
// The lock draws its wallpaper on the first frame only if the image it asks
// for is already in the cache: same URL, same requested size, same fill mode.
assert(
media.includes('property bool cached: version === 0') && media.includes('cache: root.cached'),
'background media caches unversioned images, and versioned ones on request'
)
assert(
/version: root\.backgroundVersion\s*(\/\/.*\n\s*)*cached: true\s*constrainDecode: true\s*decodeSize: Qt\.size\(width, height\)/.test(view),
'the lock wallpaper waits for its size and reads from the cache'
)
assert(
service.includes('readonly property string lockWallpaperPath: videoBackground ? videoPosterPath : backgroundPath') &&
service.includes('? Util.fileUrl(lockWallpaperPath) + (backgroundVersion ? "?v=" + backgroundVersion : "")') &&
media.includes('Util.fileUrl(path) + (version ? "?v=" + version : "")'),
'the lock service preloads the exact URL the lock view requests'
)
assert(
/model: Quickshell\.screens\s*Image \{\s*required property var modelData\s*visible: false\s*source: root\.lockWallpaperUrl\s*sourceSize\.width: modelData\.width\s*sourceSize\.height: modelData\.height\s*fillMode: Image\.PreserveAspectCrop\s*asynchronous: true\s*cache: true/.test(service),
'the lock service keeps each screen\'s lock wallpaper decoded at the lock\'s size and fill'
)
// A wallpaper overwritten in place keeps its path, so the version, which is
// part of the cached URL, follows the file's mtime and size as well.
assert(
service.includes('stat -Lc %Y:%s') &&
/\} else if \(signature !== root\.backgroundSignature\) \{\s*root\.backgroundSignature = signature\s*root\.backgroundVersion \+= 1/.test(service),
'an overwritten wallpaper bumps the lock wallpaper version'
)
JS