background: fix small wallpapers going off the screen

This commit is contained in:
end-4
2025-08-12 11:20:02 +07:00
parent fc31d5fd2f
commit d095cb7812
@@ -91,13 +91,19 @@ Variants {
onStreamFinished: { onStreamFinished: {
const output = wallpaperSizeOutputCollector.text const output = wallpaperSizeOutputCollector.text
const [width, height] = output.split(" ").map(Number); const [width, height] = output.split(" ").map(Number);
const [screenWidth, screenHeight] = [bgRoot.screen.width, bgRoot.screen.height];
bgRoot.wallpaperWidth = width bgRoot.wallpaperWidth = width
bgRoot.wallpaperHeight = height bgRoot.wallpaperHeight = height
bgRoot.effectiveWallpaperScale = Math.max(1, Math.min(
bgRoot.preferredWallpaperScale, if (width <= screenWidth || height <= screenHeight) { // Undersized/perfectly sized wallpapers
width / bgRoot.screen.width, bgRoot.effectiveWallpaperScale = Math.max(screenWidth / width, screenHeight / height);
height / bgRoot.screen.height } else { // Oversized = can be zoomed for parallax, yay
)); bgRoot.effectiveWallpaperScale = Math.min(
bgRoot.preferredWallpaperScale,
width / screenWidth, height / screenHeight
);
}
bgRoot.updateClockPosition() bgRoot.updateClockPosition()
} }