From d095cb7812830d0522f8e638ebf6bd41b4cab298 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Tue, 12 Aug 2025 11:20:02 +0700 Subject: [PATCH] background: fix small wallpapers going off the screen --- .../ii/modules/background/Background.qml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.config/quickshell/ii/modules/background/Background.qml b/.config/quickshell/ii/modules/background/Background.qml index b06b6294f..b9e96201f 100644 --- a/.config/quickshell/ii/modules/background/Background.qml +++ b/.config/quickshell/ii/modules/background/Background.qml @@ -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() }