Draw the desktop picture as the backdrop - #3
Merged
Merged
Conversation
The saver painted a flat grey and nothing else, which is not what "the usual screen with a cat on it" looks like. It now draws the display's own wallpaper, on by default, with the grey slider as the fallback. Reading the file turns out to need no ceremony: legacyScreenSaver.appex holds com.apple.security.temporary-exception.files.absolute-path.read-only for `/` (alongside com.apple.security.assets.pictures.read-only), so a picture anywhere on disk opens without a security-scoped bookmark. `Wallpaper` still returns nil on anything it cannot read — a video wallpaper has no still frame — and the engine falls back to the grey. NSWorkspace also reports how the desktop lays the picture out, so Fill Screen, Fit to Screen, Stretch and Centre are all honoured, fill colour included, and the backdrop matches what was on screen a moment earlier. The wallpaper is per display and only the view knows which display it landed on, so the view supplies it and the engine stays free of NSScreen. It is read in startAnimation, by which point the view is in a window, and only when the setting asks for it — decoding a picture costs megabytes a grey backdrop has no use for. The litter ink used to flip on the background slider alone. It now renders the backdrop into a 16px thumbnail and averages it, so a letterboxed picture's fill colour counts for as much of the answer as it does of the screen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The saver painted a flat grey and nothing else, which is not what "the usual
screen, with a cat on it" looks like. It now draws the display's own wallpaper,
on by default, with the grey slider as the fallback.
The sandbox turned out not to be in the way
.saverbundles are loaded intolegacyScreenSaver.appex, so the worry was thatreading a picture would need an
NSOpenPaneland a security-scoped bookmark.Its entitlements say otherwise:
A read-only exception for
/covers a picture anywhere on disk — which matters,since a wallpaper is quite often somewhere other than
~/Pictures. No bookmarkplumbing needed.
Wallpaperstill returnsnilon anything it cannot read (a video wallpaper hasno still frame to load) and the engine falls back to the grey, so the setting can
be left on regardless.
Laid out the way the desktop lays it out
NSWorkspace.desktopImageOptions(for:)reports the scaling mode, the clippingflag and the fill colour, so Fill Screen, Fit to Screen, Stretch and Centre are
all honoured. The backdrop matches what was on screen a moment earlier rather
than approximating it.
Where it is read
The wallpaper is per display and only the view knows which display it landed on,
so the view supplies it and the engine stays free of
NSScreen. It is read instartAnimation, by which point the view is in a window, and only when thesetting asks for it — decoding a picture costs megabytes that a grey backdrop has
no use for.
Litter ink
It used to flip on the background slider alone, which says nothing once a picture
is in the way. The engine now renders the backdrop into a 16px-wide thumbnail and
averages its luma, so a letterboxed picture's fill colour counts for as much of
the answer as it does of the screen. Marks stay visible over a black screen and a
bright wallpaper alike.
Options
One new checkbox,
Desktop picture, on by default.Backgroundnow reads as thefallback grey.
Verified
swiftlint --strict,swiftlint analyze --strictand
swiftformat --lintare cleanand off — the picture lands exactly as Fill Screen puts it on the desktop, and
the ink flips to dark over a light wallpaper
Still not verified on a real machine in System Settings.
Not this
This is the wallpaper picture, not the live desktop. A screen saver is a window
covering the screen at
CGShieldingWindowLevel(), so nothing below it showsthrough — windows, icons and the menu bar are not part of it, and no amount of
transparency changes that.