Prefer wallpapers with same aspect ratio as screen
ClosedPublic

Authored by antlarr on Sep 22 2016, 11:43 AM.

Details

Summary

The default wallpaper method is to scale the wallpaper, and the previous
algorithm in plasma choosed the wallpaper with closest area to the screen
area (w*h) giving a bit of preference to downscaling over upscaling.
The result was that in widescreens like 1280x720, a 1280x1024 wallpaper
was preferred to be scaled down, instead of scaling down the also
available 1920x1080 wallpaper, which had the same aspect ratio and so,
was not distorted.

This patch changes the Image::findPreferedImageInPackage method to do the
same closest-area algorithm first on wallpapers with the same
aspect ratio and if no wallpaper with same aspect ratio is found, then
fallback to the previous algorithm. Note I added some variables so both
happen in the same loop and we don't have to iterate twice
over the wallpapers.

This fixes https://bugzilla.opensuse.org/show_bug.cgi?id=990257

Test Plan

Make sure the wallpaper mode is in Scale. Choose a wallpaper with
1920x1080 and 1280x1024 resolutions which shows a perfect circle,
a recognizable object or a face. Then change the screen resolution to
1280x720. The wallpaper should appear with correct aspect ratio.

Diff Detail

Repository
R120 Plasma Workspace
Branch
Plasma/5.8
Lint
No Linters Available
Unit
No Unit Test Coverage
antlarr updated this revision to Diff 6873.Sep 22 2016, 11:43 AM
antlarr retitled this revision from to Prefer wallpapers with same aspect ratio as screen.
antlarr updated this object.
antlarr edited the test plan for this revision. (Show Details)
antlarr added a reviewer: Plasma.
Restricted Application added a project: Plasma. · View Herald TranscriptSep 22 2016, 11:43 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
davidedmundson accepted this revision.Sep 24 2016, 10:18 AM
davidedmundson added a reviewer: davidedmundson.
This revision is now accepted and ready to land.Sep 24 2016, 10:18 AM
antlarr closed this revision.Sep 27 2016, 8:02 AM