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: {
const output = wallpaperSizeOutputCollector.text
const [width, height] = output.split(" ").map(Number);
const [screenWidth, screenHeight] = [bgRoot.screen.width, bgRoot.screen.height];
bgRoot.wallpaperWidth = width
bgRoot.wallpaperHeight = height
bgRoot.effectiveWallpaperScale = Math.max(1, Math.min(
bgRoot.preferredWallpaperScale,
width / bgRoot.screen.width,
height / bgRoot.screen.height
));
if (width <= screenWidth || height <= screenHeight) { // Undersized/perfectly sized wallpapers
bgRoot.effectiveWallpaperScale = Math.max(screenWidth / width, screenHeight / height);
} else { // Oversized = can be zoomed for parallax, yay
bgRoot.effectiveWallpaperScale = Math.min(
bgRoot.preferredWallpaperScale,
width / screenWidth, height / screenHeight
);
}
bgRoot.updateClockPosition()
}