render wallpaper on every connected display#14
Conversation
Previously the macOS backend only created a window on NSScreen.mainScreen, so users with multiple displays saw the wallpaper on a single screen. - Enumerate NSScreen.screens() and build one borderless window plus one AVPlayerLayer per display. A single AVPlayer is shared across every layer so all screens stay in sync and the decoder only runs once. - Use each screen's backingScaleFactor for its layer's contentsScale so mixed Retina / non-Retina setups render at native resolution. - ScreenObserver now holds Vecs of windows and layers and re-applies geometry on NSApplicationDidChangeScreenParametersNotification by asking each window for its current screen(), so windows track their display across rearrangements. - Extract per-screen window/layer construction into build_wallpaper_window so run() stays readable as orchestration.
|
Thank you for your contribution! I'd like to extend this to pick which displays each wallpaper would be rendered on. While I don't use a second monitor myself, I would imagine that users would benefit from being able to pick wallpapers or extend their wallpaper across monitors. If @ploMP4 aggrees, we can merge this for the time being and extend this afterwards. I will most probably spend some time tomorrow on setting the API around it. |
ploMP4
left a comment
There was a problem hiding this comment.
Code looks good, @tharropoulos if you are ok with it and works you can go ahead and merge.
tharropoulos
left a comment
There was a problem hiding this comment.
A couple of small things noticed while reading through.
| frame.size.height as u32, | ||
| backing_scale, | ||
| ); | ||
| for (window, layer) in ivars.windows.iter().zip(ivars.layers.iter()) { |
There was a problem hiding this comment.
This only repositions existing windows. If a new display is plugged in after launch, no window or layer gets created for it and that screen stays bare. Worth a follow up to rebuild the list when screen parameters change.
| // AVAsset resolves relative paths against the process cwd, which isn't | ||
| // what users expect from `phonto ./video.mp4`. | ||
| let abs = Path::new(&video_path) | ||
| .canonicalize() |
There was a problem hiding this comment.
The original comment about why we canonicalize got dropped in this refactor. It explained that AVAsset resolves relative paths against the process cwd, which isn't what users expect from phonto ./video.mp4. Worth restoring.
| window.setOpaque(false); | ||
| window.setBackgroundColor(Some(&NSColor::clearColor())); | ||
| window.setHasShadow(false); | ||
| window.setSharingType(NSWindowSharingType::ReadOnly); |
There was a problem hiding this comment.
The original comment about why we use ReadOnly rather than None got dropped. It noted that ReadOnly lets screen capture and screen sharing still read us, while None blocks them. Worth restoring.
Previously the macOS backend only created a window on NSScreen.mainScreen, so users with multiple displays saw the wallpaper on a single screen.