use crate::wallpaper::WallpaperCache;
pub fn apply(
cache: &WallpaperCache,
monitors: &[String],
current_handles: &mut Vec<tokio::task::JoinHandle<()>>,
) {
for handle in current_handles.drain(..) {
handle.abort();
}
for monitor in monitors {
let img_path = cache
.pick_random()
.canonicalize()
.unwrap_or_else(|_| cache.pick_random().to_path_buf());
let monitor_name = monitor.clone();
let handle = tokio::task::spawn_blocking(move || {
if let Err(e) = crate::layer::render_wallpaper(&img_path, Some(&monitor_name)) {
log::error!("native renderer error on {monitor_name}: {e:#}");
}
});
current_handles.push(handle);
}
}