Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions shell/Ui/BackgroundMedia.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Item {

property string path: ""
property int version: 0
property size sourceSize: Qt.size(version > 0 ? width : 0, version > 0 ? height : 0)
property bool playbackEnabled: true
property bool audioEnabled: false
// Bumped when the file behind an unchanged path may have been replaced.
Expand Down Expand Up @@ -80,8 +81,7 @@ Item {
fillMode: Image.PreserveAspectCrop
asynchronous: true
cache: root.version === 0
sourceSize.width: root.version > 0 ? width : 0
sourceSize.height: root.version > 0 ? height : 0
sourceSize: root.sourceSize
}
}
}
8 changes: 8 additions & 0 deletions shell/plugins/background/Background.qml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ Item {
reloads: root.displayedReloads
playbackEnabled: !root.sessionObscured && !root.powerSaverActive && !panel.fullscreenHere
audioEnabled: panel.firstScreen
// Decode still wallpapers near the screen resolution. The 1.6x box
// leaves room to crop wide images without scaling them back up.
sourceSize.width: Math.ceil(width * Screen.devicePixelRatio * 1.6)
sourceSize.height: Math.ceil(height * Screen.devicePixelRatio * 1.6)
onReadyChanged: {
if (ready && root.finishingTransition) {
root.incomingBackground = ""
Expand All @@ -284,6 +288,8 @@ Item {
cache: false
smooth: true
mipmap: true
sourceSize.width: base.sourceSize.width
sourceSize.height: base.sourceSize.height
visible: root.oldBackground !== "" && root.revealProgress < 1
onStatusChanged: panel.maybeStartReveal()
}
Expand All @@ -310,6 +316,8 @@ Item {
cache: false
smooth: true
mipmap: true
sourceSize.width: base.sourceSize.width
sourceSize.height: base.sourceSize.height
onStatusChanged: panel.maybeStartReveal()
}
}
Expand Down
31 changes: 31 additions & 0 deletions test/shell.d/background-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,34 @@ assert(
'background theme transition applies pending colors even if image reveal stalls'
)
JS

run_node_test <<'JS'
const fs = require('fs')

const backgroundQml = fs.readFileSync(path.join(root, 'shell/plugins/background/Background.qml'), 'utf8')

assert(
/sourceSize\.width: Math\.ceil\(width \* Screen\.devicePixelRatio \* 1\.6\)/.test(backgroundQml) &&
/sourceSize\.height: Math\.ceil\(height \* Screen\.devicePixelRatio \* 1\.6\)/.test(backgroundQml),
'background decodes the wallpaper to the screen size rather than the file size'
)

assert(
(backgroundQml.match(/sourceSize\.width: base\.sourceSize\.width/g) || []).length === 2 &&
(backgroundQml.match(/sourceSize\.height: base\.sourceSize\.height/g) || []).length === 2,
'background transition frames decode at the same size as the wallpaper they cross-fade'
)

const images = backgroundQml.split(/\bImage\s*\{/).slice(1)
assert(
images.length === 2 && images.every(image => image.includes('sourceSize.width') && image.includes('sourceSize.height')),
'both background transition Images cap their decode size'
)

const mediaQml = fs.readFileSync(path.join(root, 'shell/Ui/BackgroundMedia.qml'), 'utf8')
assert(
mediaQml.includes('property size sourceSize: Qt.size(version > 0 ? width : 0, version > 0 ? height : 0)') &&
mediaQml.includes('sourceSize: root.sourceSize'),
'BackgroundMedia forwards the wallpaper decode size while preserving the lock screen default'
)
JS