Skip to content

A lightweight, macOS-style dock for Windows 11, with glass visuals, smooth magnification, and Genie effect.

feat: add offline wallpaper gallery and improve window visibility handling

CristianOlivera10195682dcc51
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8f7fecd..b716652 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,12 @@ copia la sección de la versión que se publica a la release de GitHub.
### English
+- Added an offline wallpaper gallery to Appearance with 12 desktop backgrounds.
+ Selecting an image applies it through Windows; opening the gallery leaves the
+ current background untouched. Small lazy-loaded previews, serialized background
+ work and embedded originals keep the gallery independent of network access.
+- Intelligent hiding now measures only the visible part of the active window:
+ its invisible resize borders reaching into the Dock no longer hide it.
- The Genie minimize animation now defaults to Fast (0.35 s). Saved speed
choices remain unchanged.
- Fixed the "Show hidden icons" tooltip appearing over the desktop after closing
@@ -52,6 +58,12 @@ copia la sección de la versión que se publica a la release de GitHub.
### Español
+- Galería de 12 fondos de pantalla sin conexión en Apariencia. Elegir una imagen
+ la aplica mediante Windows; abrir la galería conserva el fondo actual.
+ Miniaturas ligeras bajo demanda, trabajo en segundo plano y originales
+ incluidos en Ajustes, sin dependencia de conexión ni consultas periódicas.
+- La ocultación inteligente mide solo la parte visible de la ventana activa:
+ sus bordes invisibles de redimensionado ya no ocultan el Dock al rozarlo.
- El efecto genio al minimizar ahora viene en velocidad Rápida (0,35 s).
Se conservan las velocidades guardadas.
- Corregido el globo «Mostrar iconos ocultos» que aparecía sobre el escritorio
diff --git a/Cargo.lock b/Cargo.lock
index 9e01888..b44ac60 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2299,6 +2299,7 @@ dependencies = [
"tauri-build",
"tauri-plugin-single-instance",
"tauri-plugin-updater",
+ "windows",
]
[[package]]
diff --git a/apps/dock/src/app/visibility.rs b/apps/dock/src/app/visibility.rs
index ba5c6bb..56cbad2 100644
--- a/apps/dock/src/app/visibility.rs
+++ b/apps/dock/src/app/visibility.rs
@@ -257,7 +257,9 @@ impl App {
if !self.windows.iter().any(|window| window.hwnd == front) {
return false;
}
- tracker::screen_rect(front).is_some_and(|(rect, _)| {
+ // What shows of it: its invisible resize borders reaching
+ // into the dock must not hide it.
+ tracker::visible_rect(front).is_some_and(|rect| {
rects_overlap(
stage.screen_rect(Rect {
x: 0.0,
diff --git a/apps/settings/src-tauri/Cargo.toml b/apps/settings/src-tauri/Cargo.toml
index 6f15a1e..c58d721 100644
--- a/apps/settings/src-tauri/Cargo.toml
+++ b/apps/settings/src-tauri/Cargo.toml
@@ -23,6 +23,7 @@ tauri-plugin-single-instance = "2"
serde_json = "1"
base64 = "0.23"
png = "0.18"
+windows = { workspace = true, features = ["Win32_System_Com", "Win32_UI_Shell"] }
[features]
# Serve the bundled front end instead of the Vite dev server. On by default so
diff --git a/apps/settings/src-tauri/src/main.rs b/apps/settings/src-tauri/src/main.rs
index 035597f..78b9976 100644
--- a/apps/settings/src-tauri/src/main.rs
+++ b/apps/settings/src-tauri/src/main.rs
@@ -7,6 +7,8 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
+mod wallpapers;
+
use std::{env, io, path::PathBuf, process::Command, sync::Mutex, time::Duration};
use muelle_config::Config;
@@ -344,7 +346,9 @@ fn main() {
install_update,
open_release_notes,
open_repository,
- wallpaper_preview
+ wallpaper_preview,
+ wallpapers::wallpaper_selection,
+ wallpapers::apply_wallpaper
])
.run(tauri::generate_context!());
if let Err(error) = result {
diff --git a/apps/settings/src-tauri/src/wallpapers.rs b/apps/settings/src-tauri/src/wallpapers.rs
new file mode 100644
index 0000000..321fbbf
--- /dev/null
+++ b/apps/settings/src-tauri/src/wallpapers.rs
@@ -0,0 +1,313 @@
+//! Optional offline gallery. Only an explicit apply command changes Windows.
+
+use std::{
+ env, fs,
+ io::{Read, Write},
+ path::{Path, PathBuf},
+ sync::atomic::{AtomicBool, AtomicU64, Ordering},
+};
+
+use windows::{
+ Win32::{
+ Foundation::RPC_E_CHANGED_MODE,
+ System::Com::{
+ CLSCTX_ALL, COINIT_MULTITHREADED, CoCreateInstance, CoInitializeEx, CoTaskMemFree,
+ CoUninitialize,
+ },
+ UI::Shell::{DesktopWallpaper, IDesktopWallpaper},
+ },
+ core::{HSTRING, PCWSTR, PWSTR},
+};
+
+struct Wallpaper {
+ name: &'static str,
+ bytes: &'static [u8],
+}
+
+macro_rules! wallpaper {
+ ($name:literal) => {
+ Wallpaper {
+ name: $name,
+ bytes: include_bytes!(concat!("../../wallpapers/", $name)),
+ }
+ };
+}
+
+// Originals are embedded once in Settings, not downloaded or decoded at startup.
+static CATALOG: [Wallpaper; 12] = [
+ wallpaper!("desktop-01.jpg"),
+ wallpaper!("desktop-02.jpg"),
+ wallpaper!("desktop-03.jpg"),
+ wallpaper!("desktop-04.jpg"),
+ wallpaper!("desktop-05.jpg"),
+ wallpaper!("desktop-06.jpg"),
+ wallpaper!("desktop-07.jpg"),
+ wallpaper!("desktop-08.jpg"),
+ wallpaper!("desktop-09.jpg"),
+ wallpaper!("desktop-10.jpg"),
+ wallpaper!("desktop-11.jpg"),
+ wallpaper!("desktop-12.jpg"),
+];
+static APPLYING: AtomicBool = AtomicBool::new(false);
+static TEMPORARY: AtomicU64 = AtomicU64::new(0);
+
+struct ApplyGuard;
+impl ApplyGuard {
+ fn acquire() -> Result<Self, String> {
+ APPLYING
+ .compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire)
+ .map(|_| Self)
+ .map_err(|_| "A wallpaper change is already in progress".into())
+ }
+}
+impl Drop for ApplyGuard {
+ fn drop(&mut self) {
+ APPLYING.store(false, Ordering::Release);
+ }
+}
+
+struct Apartment(bool);
+impl Apartment {
+ fn new() -> Result<Self, String> {
+ let status = unsafe { CoInitializeEx(None, COINIT_MULTITHREADED) };
+ if status.is_err() && status != RPC_E_CHANGED_MODE {
+ return Err(status.to_string());
+ }
+ Ok(Self(status.is_ok()))
+ }
+}
+impl Drop for Apartment {
+ fn drop(&mut self) {
+ if self.0 {
+ unsafe { CoUninitialize() };
+ }
+ }
+}
+
+struct Text(PWSTR);
+impl Drop for Text {
+ fn drop(&mut self) {
+ unsafe { CoTaskMemFree(Some(self.0.0.cast())) };
+ }
+}
+
+fn with_desktop<T>(
+ action: impl FnOnce(&IDesktopWallpaper) -> Result<T, String>,
+) -> Result<T, String> {
+ let _apartment = Apartment::new()?;
+ // The interface is released before its apartment, on this same worker.
+ let desktop: IDesktopWallpaper =
+ unsafe { CoCreateInstance(&DesktopWallpaper, None, CLSCTX_ALL) }
+ .map_err(|error| error.to_string())?;
+ action(&desktop)
+}
+
+fn cache_dir() -> Result<PathBuf, String> {
+ env::var_os("LOCALAPPDATA")
+ .map(|root| PathBuf::from(root).join("Muelle").join("Wallpapers"))
+ .ok_or_else(|| "The local application data folder is unavailable".into())
+}
+
+fn entry(id: u8) -> Result<&'static Wallpaper, String> {
+ id.checked_sub(1)
+ .and_then(|index| CATALOG.get(usize::from(index)))
+ .ok_or_else(|| "Unknown wallpaper".into())
+}
+
+fn selected_path(root: &Path, current: &Path) -> Option<u8> {
+ CATALOG
+ .iter()
+ .position(|asset| {
+ root.join(asset.name)
+ .to_string_lossy()
+ .eq_ignore_ascii_case(&current.to_string_lossy())
+ })
+ .map(|index| index as u8 + 1)
+}
+
+/// Read-only snapshot; an empty/multi-monitor/slideshow result is not a gallery selection.
+#[tauri::command]
+pub async fn wallpaper_selection() -> Result<Option<u8>, String> {
+ tauri::async_runtime::spawn_blocking(|| {
+ let root = cache_dir()?;
+ with_desktop(|desktop| {
+ let text = Text(
+ unsafe { desktop.GetWallpaper(PCWSTR::null()) }
+ .map_err(|error| error.to_string())?,
+ );
+ if text.0.is_null() {
+ return Ok(None);
+ }
+ let path = unsafe { text.0.to_string() }.map_err(|error| error.to_string())?;
+ Ok(selected_path(&root, Path::new(&path)))
+ })
+ })
+ .await
+ .map_err(|error| error.to_string())?
+}
+
+fn materialize(asset: &Wallpaper, root: &Path) -> Result<PathBuf, String> {
+ fs::create_dir_all(root).map_err(|error| error.to_string())?;
+ let destination = root.join(asset.name);
+ // Bound reads even if someone replaced our cached file with a larger one.
+ if let Ok(file) = fs::File::open(&destination)
+ && file
+ .metadata()
+ .is_ok_and(|metadata| metadata.len() == asset.bytes.len() as u64)
+ {
+ let mut bytes = Vec::with_capacity(asset.bytes.len());
+ if file
+ .take(asset.bytes.len() as u64 + 1)
+ .read_to_end(&mut bytes)
+ .is_ok()
+ && bytes == asset.bytes
+ {
+ return Ok(destination);
+ }
+ }
+ let temporary = root.join(format!(
+ ".{}-{}-{}.tmp",
+ asset.name,
+ std::process::id(),
+ TEMPORARY.fetch_add(1, Ordering::Relaxed)
+ ));
+ let result = (|| -> std::io::Result<()> {
+ let mut file = fs::OpenOptions::new()
+ .write(true)
+ .create_new(true)
+ .open(&temporary)?;
+ file.write_all(asset.bytes)?;
+ file.sync_all()?;
+ drop(file);
+ fs::rename(&temporary, &destination)
+ })();
+ if result.is_err() {
+ let _ = fs::remove_file(&temporary);
+ }
+ result.map_err(|error| error.to_string())?;
+ Ok(destination)
+}
+
+fn apply_at(
+ id: u8,
+ root: &Path,
+ set: impl FnOnce(&Path) -> Result<(), String>,
+) -> Result<(), String> {
+ let asset = entry(id)?;
+ let path = materialize(asset, root)?;
+ set(&path)
+}
+
+/// Only accepts a catalog ID, never a URL, caller-supplied path or executable.
+#[tauri::command]
+pub async fn apply_wallpaper(id: u8) -> Result<(), String> {
+ entry(id)?;
+ let guard = ApplyGuard::acquire()?;
+ tauri::async_runtime::spawn_blocking(move || {
+ let _guard = guard;
+ apply_at(id, &cache_dir()?, |path| {
+ with_desktop(|desktop| {
+ let path = HSTRING::from(path.as_os_str());
+ // NULL selects all monitors. Windows persists and broadcasts the change.
+ unsafe { desktop.SetWallpaper(PCWSTR::null(), &path) }
+ .map_err(|error| error.to_string())
+ })
+ })
+ })
+ .await
+ .map_err(|error| error.to_string())?
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn catalog_is_complete_and_every_original_decodes_with_bounded_memory() -> Result<(), String> {
+ let _apartment = Apartment::new()?;
+ for id in 1..=12 {
+ let asset = entry(id)?;
+ assert_eq!(asset.name, format!("desktop-{id:02}.jpg"));
+ let image = muelle_shell::imagery::decode(asset.bytes, 128, 40_000_000)
+ .ok_or("invalid packaged wallpaper")?;
+ assert!(image.width <= 128 && image.height <= 128);
+ }
+ Ok(())
+ }
+
+ #[test]
+ fn arbitrary_ids_are_rejected_before_writes_or_system_changes() {
+ let root =
+ env::temp_dir().join(format!("muelle-wallpaper-rejected-{}", std::process::id()));
+ for id in [0, 13, 255] {
+ let result = apply_at(id, &root, |_| panic!("invalid ID must never reach Windows"));
+ assert!(result.is_err());
+ }
+ assert!(!root.exists());
+ }
+
+ #[test]
+ fn cache_is_durable_reused_and_repaired_and_failed_apply_is_reported() -> Result<(), String> {
+ let root = env::temp_dir().join(format!(
+ "muelle-wallpaper-cache-{}-{}",
+ std::process::id(),
+ TEMPORARY.fetch_add(1, Ordering::Relaxed)
+ ));
+ let asset = entry(1)?;
+ let path = materialize(asset, &root)?;
+ let modified = fs::metadata(&path)
+ .and_then(|metadata| metadata.modified())
+ .map_err(|error| error.to_string())?;
+ materialize(asset, &root)?;
+ assert_eq!(
+ fs::metadata(&path)
+ .and_then(|metadata| metadata.modified())
+ .map_err(|error| error.to_string())?,
+ modified
+ );
+ fs::write(&path, b"damaged cache").map_err(|error| error.to_string())?;
+ materialize(asset, &root)?;
+ assert_eq!(
+ fs::read(&path).map_err(|error| error.to_string())?,
+ asset.bytes
+ );
+ let result = apply_at(1, &root, |actual| {
+ assert_eq!(actual, path);
+ Err("Windows refused the change".into())
+ });
+ assert_eq!(result, Err("Windows refused the change".into()));
+ assert_eq!(selected_path(&root, &path), Some(1));
+ assert_eq!(
+ selected_path(&root, &root.join("elsewhere/desktop-01.jpg")),
+ None
+ );
+ fs::remove_file(path)
+ .and_then(|()| fs::remove_dir(root))
+ .map_err(|error| error.to_string())?;
+ Ok(())
+ }
+
+ #[test]
+ fn apply_guard_rejects_overlap_and_is_released_after_failure() -> Result<(), String> {
+ let guard = ApplyGuard::acquire()?;
+ assert!(ApplyGuard::acquire().is_err());
+ drop(guard);
+ drop(ApplyGuard::acquire()?);
+ Ok(())
+ }
+
+ #[test]
+ #[ignore = "Read-only Windows wallpaper service probe; never changes the user's background"]
+ fn native_wallpaper_service_can_read_the_current_background() -> Result<(), String> {
+ with_desktop(|desktop| {
+ let value = Text(
+ unsafe { desktop.GetWallpaper(PCWSTR::null()) }
+ .map_err(|error| error.to_string())?,
+ );
+ if !value.0.is_null() {
+ let _ = unsafe { value.0.to_string() }.map_err(|error| error.to_string())?;
+ }
+ Ok(())
+ })
+ }
+}
diff --git a/apps/settings/src/App.tsx b/apps/settings/src/App.tsx
index 20d23d3..3bbaf4c 100644
--- a/apps/settings/src/App.tsx
+++ b/apps/settings/src/App.tsx
@@ -34,6 +34,7 @@ import { Card, Row, Segmented, Select, Slider, SubRow, Toggle, VisualChoices } f
import { DockDensityPreview, DockPreview, IslandPreview, SettingIcon, SpeedPreview, ThemePreview } from "./visuals";
import { type SectionId, SectionIcon } from "./icons";
import { UpdateBanner } from "./UpdateBanner";
+import { WallpaperGallery } from "./WallpaperGallery";
import en from "./i18n/en.json";
import es from "./i18n/es.json";
import fr from "./i18n/fr.json";
@@ -93,7 +94,7 @@ export function App() {
const [wallpaper, setWallpaper] = useState<string | null>(null);
useEffect(() => {
let alive = true;
- loadWallpaperPreview().then((image) => { if (alive) setWallpaper(image); });
+ loadWallpaperPreview().then((image) => { if (alive) setWallpaper((current) => current ?? image); });
return () => { alive = false; };
}, []);
/** "Later" hides the banner until Settings is opened again. */
@@ -384,6 +385,7 @@ export function App() {
/>
<p className="card-note row-hint">{t.themeHint}</p>
</Card>
+ <WallpaperGallery texts={t} onApplied={setWallpaper} />
</>
) : section === "dock" ? (
<>
diff --git a/apps/settings/src/WallpaperGallery.tsx b/apps/settings/src/WallpaperGallery.tsx
new file mode 100644
index 0000000..2d043eb
--- /dev/null
+++ b/apps/settings/src/WallpaperGallery.tsx
@@ -0,0 +1,81 @@
+import { useEffect, useRef, useState } from "react";
+import { Card } from "./controls";
+import { applyWallpaper, loadWallpaperSelection } from "./config";
+import { WALLPAPERS } from "./wallpaper-catalog";
+
+interface WallpaperTexts {
+ wallpaperGalleryTitle: string;
+ wallpaperGalleryHint: string;
+ wallpaperApplyLabel: string;
+ wallpaperApplying: string;
+ wallpaperApplied: string;
+ wallpaperApplyError: string;
+ wallpaperNames: readonly string[];
+}
+
+/** Mounted only in Appearance. No polling, full-size image decoding or remote URLs. */
+export function WallpaperGallery({ texts, onApplied }: { texts: WallpaperTexts; onApplied: (preview: string) => void }) {
+ const [selected, setSelected] = useState<number | null>(null);
+ const [pending, setPending] = useState<number | null>(null);
+ const [failed, setFailed] = useState(false);
+ const [applied, setApplied] = useState(false);
+ const busy = useRef(false);
+ const revision = useRef(0);
+ const mounted = useRef(true);
+
+ useEffect(() => {
+ let alive = true;
+ mounted.current = true;
+ const current = revision.current;
+ loadWallpaperSelection().then((id) => {
+ if (alive && revision.current === current) setSelected(id);
+ }).catch(() => { /* An unavailable read must not prevent an explicit choice. */ });
+ return () => { alive = false; mounted.current = false; };
+ }, []);
+
+ const choose = async (id: number, preview: string) => {
+ // A ref closes the gap before React paints the disabled buttons.
+ if (busy.current) return;
+ busy.current = true;
+ revision.current += 1;
+ setPending(id);
+ setFailed(false);
+ setApplied(false);
+ try {
+ await applyWallpaper(id, preview);
+ // Keep other Settings previews current even if the user has navigated away.
+ onApplied(preview);
+ if (mounted.current) { setSelected(id); setApplied(true); }
+ } catch {
+ if (mounted.current) setFailed(true);
+ } finally {
+ busy.current = false;
+ if (mounted.current) setPending(null);
+ }
+ };
+
+ return <Card title={texts.wallpaperGalleryTitle}>
+ <p className="wallpaper-hint">{texts.wallpaperGalleryHint}</p>
+ <div className="wallpaper-grid">
+ {WALLPAPERS.map(({ id, preview }) => {
+ const name = texts.wallpaperNames[id - 1];
+ return <button type="button" className="wallpaper-choice" key={id}
+ data-wallpaper-id={id} title={name}
+ aria-label={texts.wallpaperApplyLabel.replace("{name}", name)}
+ aria-pressed={selected === id} aria-busy={pending === id || undefined}
+ disabled={pending !== null} onClick={() => choose(id, preview)}>
+ <span className="wallpaper-image">
+ <img src={preview} width="400" height="225" loading="lazy" decoding="async" alt="" />
+ {selected === id ? <span className="wallpaper-check" aria-hidden="true">
+ <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="2"><path d="m4 8 2.5 2.5L12 5" /></svg>
+ </span> : null}
+ </span>
+ <span className="wallpaper-name">{name}</span>
+ </button>;
+ })}
+ </div>
+ <p className="wallpaper-status" role={failed ? "alert" : "status"}>
+ {pending !== null ? texts.wallpaperApplying : failed ? texts.wallpaperApplyError : applied ? texts.wallpaperApplied : ""}
+ </p>
+ </Card>;
+}
diff --git a/apps/settings/src/config.ts b/apps/settings/src/config.ts
index 4ac5a5b..9ec14d8 100644
--- a/apps/settings/src/config.ts
+++ b/apps/settings/src/config.ts
@@ -89,4 +89,20 @@ let wallpaperRequest: Promise<string | null> | undefined;
/** One bounded native read per Settings process, including React StrictMode. */
export const loadWallpaperPreview = () =>
wallpaperRequest ??= invoke<string | null>("wallpaper_preview").catch(() => null);
+let wallpaperSelectionRequest: Promise<number | null> | undefined;
+/** Share overlapping reads from StrictMode or quick section navigation. */
+export const loadWallpaperSelection = () => {
+ if (wallpaperSelectionRequest) return wallpaperSelectionRequest;
+ const request = invoke<number | null>("wallpaper_selection").finally(() => {
+ if (wallpaperSelectionRequest === request) wallpaperSelectionRequest = undefined;
+ });
+ wallpaperSelectionRequest = request;
+ return request;
+};
+export const applyWallpaper = async (id: number, preview: string) => {
+ await invoke<void>("apply_wallpaper", { id });
+ // Original images stay in native storage; Settings uses only the small preview.
+ wallpaperRequest = Promise.resolve(preview);
+ wallpaperSelectionRequest = undefined;
+};
export const installUpdate = () => invoke<void>("install_update");
diff --git a/apps/settings/src/i18n/en.json b/apps/settings/src/i18n/en.json
index d633cc5..f2965d6 100644
--- a/apps/settings/src/i18n/en.json
+++ b/apps/settings/src/i18n/en.json
@@ -125,5 +125,25 @@
"dockHidingIntelligent": "Intelligent",
"dockHidingVisibleHint": "Keep the Dock visible while you work.",
"dockHidingAutomaticHint": "Hidden until you rest the pointer at its edge, even on the desktop.",
- "dockHidingIntelligentHint": "Visible on the desktop. Hides when the active window overlaps it."
+ "dockHidingIntelligentHint": "Visible on the desktop. Hides when the active window overlaps it.",
+ "wallpaperGalleryTitle": "Wallpapers",
+ "wallpaperGalleryHint": "Choose an image to replace the Windows background on your displays.",
+ "wallpaperApplyLabel": "Use {name} as wallpaper",
+ "wallpaperApplying": "Applying wallpaper…",
+ "wallpaperApplied": "Wallpaper applied.",
+ "wallpaperApplyError": "Could not change the wallpaper. Try again.",
+ "wallpaperNames": [
+ "Purple peaks",
+ "Color waves",
+ "Green hills",
+ "Aurora",
+ "Golden dunes",
+ "Sunset dunes",
+ "Sunset sky",
+ "Spectrum",
+ "Cherry blossoms",
+ "Meadow at sunrise",
+ "Horizon",
+ "Blue sky"
+ ]
}
diff --git a/apps/settings/src/i18n/es.json b/apps/settings/src/i18n/es.json
index d20a693..6d0a637 100644
--- a/apps/settings/src/i18n/es.json
+++ b/apps/settings/src/i18n/es.json
@@ -125,5 +125,25 @@
"dockHidingIntelligent": "Inteligente",
"dockHidingVisibleHint": "Mantiene el Dock visible mientras trabajas.",
"dockHidingAutomaticHint": "Se oculta hasta que dejes el puntero en su borde, incluso en el escritorio.",
- "dockHidingIntelligentHint": "Visible en el escritorio. Se oculta si la ventana activa ocupa su espacio."
+ "dockHidingIntelligentHint": "Visible en el escritorio. Se oculta si la ventana activa ocupa su espacio.",
+ "wallpaperGalleryTitle": "Fondos de pantalla",
+ "wallpaperGalleryHint": "Elige una imagen para reemplazar el fondo de Windows en tus pantallas.",
+ "wallpaperApplyLabel": "Usar {name} como fondo",
+ "wallpaperApplying": "Aplicando fondo…",
+ "wallpaperApplied": "Fondo aplicado.",
+ "wallpaperApplyError": "No se pudo cambiar el fondo. Inténtalo de nuevo.",
+ "wallpaperNames": [
+ "Cumbres violetas",
+ "Ondas de color",
+ "Colinas verdes",
+ "Aurora",
+ "Dunas doradas",
+ "Dunas al atardecer",
+ "Cielo al atardecer",
+ "Espectro",
+ "Cerezos",
+ "Pradera al amanecer",
+ "Horizonte",
+ "Cielo azul"
+ ]
}
diff --git a/apps/settings/src/i18n/fr.json b/apps/settings/src/i18n/fr.json
index cdae1fb..20c6f54 100644
--- a/apps/settings/src/i18n/fr.json
+++ b/apps/settings/src/i18n/fr.json
@@ -125,5 +125,25 @@
"dockHidingIntelligent": "Intelligent",
"dockHidingVisibleHint": "Garde le Dock visible pendant votre travail.",
"dockHidingAutomaticHint": "Masqué jusqu’à ce que le pointeur reste sur son bord, même sur le bureau.",
- "dockHidingIntelligentHint": "Visible sur le bureau. Se masque si la fenêtre active le recouvre."
+ "dockHidingIntelligentHint": "Visible sur le bureau. Se masque si la fenêtre active le recouvre.",
+ "wallpaperGalleryTitle": "Fonds d’écran",
+ "wallpaperGalleryHint": "Choisissez une image pour remplacer le fond Windows sur vos écrans.",
+ "wallpaperApplyLabel": "Utiliser {name} comme fond",
+ "wallpaperApplying": "Application du fond…",
+ "wallpaperApplied": "Fond appliqué.",
+ "wallpaperApplyError": "Impossible de changer le fond. Réessayez.",
+ "wallpaperNames": [
+ "Sommets violets",
+ "Vagues de couleurs",
+ "Collines vertes",
+ "Aurore",
+ "Dunes dorées",
+ "Dunes au couchant",
+ "Ciel au couchant",
+ "Spectre",
+ "Cerisiers",
+ "Prairie à l’aube",
+ "Horizon",
+ "Ciel bleu"
+ ]
}
diff --git a/apps/settings/src/styles.css b/apps/settings/src/styles.css
index 6a0fd65..1e68a31 100644
--- a/apps/settings/src/styles.css
+++ b/apps/settings/src/styles.css
@@ -685,3 +685,21 @@ input:focus-visible {
.preview-density { display: grid; place-items: center; width: 100%; height: 72px; }
.preview-density .preview-dock { --mini-icon: 18px; position: static; border-radius: 9px; }
.preview-density .preview-dock i { flex: 0 0 var(--mini-icon); border-radius: 4px; }
+
+
+.wallpaper-hint { margin: 14px 14px 12px; color: var(--text-dim); font-size: 12px; line-height: 1.5; }
+.wallpaper-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; padding: 0 14px; }
+.wallpaper-choice { min-width: 0; padding: 0; border: 0; color: var(--text); background: none; font: inherit; text-align: left; cursor: default; }
+.wallpaper-image { position: relative; display: block; overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 8px; background: var(--hover); }
+.wallpaper-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
+.wallpaper-choice:hover .wallpaper-image { border-color: var(--text-dim); }
+.wallpaper-choice[aria-pressed="true"] .wallpaper-image { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
+.wallpaper-choice:focus-visible { outline: none; }
+.wallpaper-choice:focus-visible .wallpaper-image { outline: 2px solid var(--accent); outline-offset: 4px; }
+.wallpaper-choice:disabled { opacity: .65; }
+.wallpaper-name { display: block; margin-top: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
+.wallpaper-check { position: absolute; right: 6px; top: 6px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: #fff; background: var(--accent); box-shadow: 0 1px 3px #0004; }
+.wallpaper-check svg { width: 13px; height: 13px; }
+.wallpaper-status { min-height: 1.5em; margin: 10px 14px 12px; color: var(--text-dim); font-size: 11px; line-height: 1.5; }
+.wallpaper-status[role="alert"] { color: #e55b55; }
+@media (min-width: 1100px) { .wallpaper-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
diff --git a/apps/settings/src/vite-env.d.ts b/apps/settings/src/vite-env.d.ts
new file mode 100644
index 0000000..11f02fe
--- /dev/null
+++ b/apps/settings/src/vite-env.d.ts
@@ -0,0 +1 @@
+/// <reference types="vite/client" />
diff --git a/apps/settings/src/wallpaper-catalog.ts b/apps/settings/src/wallpaper-catalog.ts
new file mode 100644
index 0000000..cdc3b0f
--- /dev/null
+++ b/apps/settings/src/wallpaper-catalog.ts
@@ -0,0 +1,28 @@
+// Small offline previews. Full-resolution originals are embedded only in Settings native code.
+import preview1 from "./assets/wallpapers/desktop-01.jpg";
+import preview2 from "./assets/wallpapers/desktop-02.jpg";
+import preview3 from "./assets/wallpapers/desktop-03.jpg";
+import preview4 from "./assets/wallpapers/desktop-04.jpg";
+import preview5 from "./assets/wallpapers/desktop-05.jpg";
+import preview6 from "./assets/wallpapers/desktop-06.jpg";
+import preview7 from "./assets/wallpapers/desktop-07.jpg";
+import preview8 from "./assets/wallpapers/desktop-08.jpg";
+import preview9 from "./assets/wallpapers/desktop-09.jpg";
+import preview10 from "./assets/wallpapers/desktop-10.jpg";
+import preview11 from "./assets/wallpapers/desktop-11.jpg";
+import preview12 from "./assets/wallpapers/desktop-12.jpg";
+
+export const WALLPAPERS = [
+ { id: 1, preview: preview1 },
+ { id: 2, preview: preview2 },
+ { id: 3, preview: preview3 },
+ { id: 4, preview: preview4 },
+ { id: 5, preview: preview5 },
+ { id: 6, preview: preview6 },
+ { id: 7, preview: preview7 },
+ { id: 8, preview: preview8 },
+ { id: 9, preview: preview9 },
+ { id: 10, preview: preview10 },
+ { id: 11, preview: preview11 },
+ { id: 12, preview: preview12 },
+] as const;
diff --git a/apps/settings/tests/app.test.mjs b/apps/settings/tests/app.test.mjs
index 74a7f81..c2764e1 100644
--- a/apps/settings/tests/app.test.mjs
+++ b/apps/settings/tests/app.test.mjs
@@ -41,10 +41,12 @@ function* elements(node) {
else if (React.isValidElement(node)) { yield node; yield* elements(node.props.children); }
}
-function fixture(section = "menubar", config = {}, save = async () => {}) {
+function fixture(section = "menubar", config = {}, save = async () => {}, galleryNative = {}) {
const states = [], refs = [], effects = [], timers = new Map(), calls = [], listeners = new Map();
let stateIndex = 0, refIndex = 0, nextTimer = 0, close;
const loaded = { ...base, ...config };
+ const gallery = section === "gallery";
+ const wallpaperCalls = [], wallpaperPreviews = [];
const browser = {
addEventListener(event, callback) { assert.ok(!listeners.has(event)); listeners.set(event, callback); },
removeEventListener(event) { listeners.delete(event); },
@@ -56,7 +58,7 @@ function fixture(section = "menubar", config = {}, save = async () => {}) {
...React,
useState(initial) {
const index = stateIndex++;
- if (!(index in states)) states[index] = index === 0 ? { ...loaded } : initial === "dock" ? section : initial;
+ if (!(index in states)) states[index] = !gallery && index === 0 ? { ...loaded } : !gallery && initial === "dock" ? section : initial;
return [states[index], (value) => { states[index] = typeof value === "function" ? value(states[index]) : value; }];
},
useRef(initial) { const index = refIndex++; return refs[index] ??= { current: initial }; },
@@ -78,6 +80,8 @@ function fixture(section = "menubar", config = {}, save = async () => {}) {
case "get_autostart": return false;
case "windows_preferences": return { animations: true };
case "wallpaper_preview": return null;
+ case "wallpaper_selection": return typeof galleryNative.selection === "function" ? galleryNative.selection() : galleryNative.selection ?? null;
+ case "apply_wallpaper": wallpaperCalls.push({ ...args }); return galleryNative.apply?.(args.id);
case "default_config": return { ...base, autoHide: false, smartHide: true };
case "set_config": calls.push({ ...args.patch }); return save(args.patch);
default: throw new Error(`Unexpected native call: ${command}`);
@@ -88,10 +92,11 @@ function fixture(section = "menubar", config = {}, save = async () => {}) {
function load(filename) {
if (modules.has(filename)) return modules.get(filename).exports;
if (filename.endsWith(".json")) return JSON.parse(readFileSync(filename, "utf8"));
+ if (filename.endsWith(".jpg")) return `file:///${filename.replaceAll("\\", "/")}`;
const module = { exports: {} };
modules.set(filename, module);
compiled.get(filename)((id) => {
- if (id === "react" && filename === path.join(source, "App.tsx")) return hooks;
+ if (id === "react" && (filename === path.join(source, "App.tsx") || gallery && filename === path.join(source, "WallpaperGallery.tsx"))) return hooks;
if (id in mocks) return mocks[id];
if (!id.startsWith(".")) return require(id);
const resolved = path.resolve(path.dirname(filename), id);
@@ -100,16 +105,20 @@ function fixture(section = "menubar", config = {}, save = async () => {}) {
return module.exports;
}
const { App } = load(path.join(source, "App.tsx"));
- function render() { stateIndex = refIndex = 0; effects.length = 0; return App(); }
+ const { WallpaperGallery } = load(path.join(source, "WallpaperGallery.tsx"));
+ function render() {
+ stateIndex = refIndex = 0; effects.length = 0;
+ return gallery ? WallpaperGallery({ texts: texts[loaded.language], onApplied: (preview) => wallpaperPreviews.push(preview) }) : App();
+ }
function find(predicate) { const node = [...elements(render())].find(predicate); assert.ok(node); return node; }
return {
- calls, timers, render, themes: nativeWindow.themes,
+ calls, timers, render, themes: nativeWindow.themes, wallpaperCalls, wallpaperPreviews,
external(patch) { Object.assign(loaded, patch); },
async focus() { listeners.get("focus")?.(); await settle(); },
async mount() { render(); const cleanup = effects.map((effect) => effect()); await settle(); return () => cleanup.forEach((fn) => fn?.()); },
change(label, value) { find((node) => node.props.label === label && typeof node.props.onChange === "function").props.onChange(value); },
button(text) { find((node) => node.type === "button" && node.props.children === text).props.onClick(); },
- body() { return find((node) => node.props.className === "content-body"); },
+ body() { return gallery ? render() : find((node) => node.props.className === "content-body"); },
fire(delay) { for (const [id, timer] of [...timers]) if (timer.delay === delay) { timers.delete(id); timer.callback(); } },
async close() { let prevented = false; await close({ preventDefault() { prevented = true; } }); return prevented; },
};
@@ -132,6 +141,75 @@ test("each section renders only its own controls, in every language and visibili
}
});
+const wallpaperButtons = (view) => [...elements(view.body())].filter((node) => node.type === "button" && "data-wallpaper-id" in node.props);
+
+test("the offline wallpaper gallery is optional and appears only inside Appearance", () => {
+ for (const language of Object.keys(texts)) {
+ assert.equal(texts[language].wallpaperNames.length, 12);
+ for (const section of ["appearance", "dock", "windows", "menubar", "system"]) {
+ const view = fixture(section, { language });
+ const html = renderToStaticMarkup(view.body());
+ assert.equal((html.match(/class="wallpaper-choice"/g) ?? []).length, section === "appearance" ? 12 : 0);
+ if (section === "appearance") {
+ assert.equal((html.match(/loading="lazy"/g) ?? []).length, 12);
+ assert.doesNotMatch(html, /https:\/\/openvid\.dev/);
+ }
+ assert.deepEqual(view.wallpaperCalls, [], "rendering must never change the desktop");
+ }
+ }
+});
+
+test("wallpapers follow the Windows selection and serialize rapid clicks until success", async () => {
+ let finish;
+ const view = fixture("gallery", {}, undefined, {
+ selection: 3, apply: () => new Promise((resolve) => { finish = resolve; }),
+ });
+ const unmount = await view.mount();
+ try {
+ assert.equal(wallpaperButtons(view).find((button) => button.props["aria-pressed"]).props["data-wallpaper-id"], 3);
+ const buttons = wallpaperButtons(view);
+ const operation = buttons[3].props.onClick();
+ await buttons[4].props.onClick(); // Simulate a second click before React repaints.
+ assert.deepEqual(view.wallpaperCalls, [{ id: 4 }]);
+ assert.ok(wallpaperButtons(view).every((button) => button.props.disabled));
+ assert.equal(view.wallpaperPreviews.length, 0);
+ finish(); await operation; await settle();
+ assert.equal(wallpaperButtons(view).find((button) => button.props["aria-pressed"]).props["data-wallpaper-id"], 4);
+ assert.equal(view.wallpaperPreviews.length, 1);
+ assert.ok(wallpaperButtons(view).every((button) => !button.props.disabled));
+ } finally { unmount(); }
+});
+
+test("a rejected wallpaper change preserves the previous selection and can be retried", async () => {
+ let reject = true;
+ const view = fixture("gallery", {}, undefined, {
+ selection: 2, apply: async () => { if (reject) throw new Error("Windows denied the change"); },
+ });
+ const unmount = await view.mount();
+ try {
+ await wallpaperButtons(view)[8].props.onClick();
+ assert.equal(wallpaperButtons(view).find((button) => button.props["aria-pressed"]).props["data-wallpaper-id"], 2);
+ assert.equal(view.wallpaperPreviews.length, 0);
+ assert.ok(renderToStaticMarkup(view.body()).includes(texts.en.wallpaperApplyError));
+ reject = false;
+ await wallpaperButtons(view)[8].props.onClick();
+ assert.equal(wallpaperButtons(view).find((button) => button.props["aria-pressed"]).props["data-wallpaper-id"], 9);
+ assert.deepEqual(view.wallpaperCalls, [{ id: 9 }, { id: 9 }]);
+ } finally { unmount(); }
+});
+
+test("a late initial wallpaper read cannot overwrite an explicit successful choice", async () => {
+ let read;
+ const view = fixture("gallery", {}, undefined, { selection: () => new Promise((resolve) => { read = resolve; }) });
+ const unmount = await view.mount();
+ try {
+ await wallpaperButtons(view)[11].props.onClick();
+ read(1); await settle();
+ assert.equal(wallpaperButtons(view).find((button) => button.props["aria-pressed"]).props["data-wallpaper-id"], 12);
+ assert.deepEqual(view.wallpaperCalls, [{ id: 12 }]);
+ } finally { unmount(); }
+});
+
test("Bluetooth has no duplicate setting even with an old saved visibility override", () => {
for (const language of Object.keys(texts)) for (const menuBarBluetooth of [false, true]) {
const view = fixture("menubar", { language, menuBar: true, menuBarBluetooth });
diff --git a/apps/settings/wallpapers/SOURCES.md b/apps/settings/wallpapers/SOURCES.md
index dc64d68..a173d30 100644
--- a/apps/settings/wallpapers/SOURCES.md
+++ b/apps/settings/wallpapers/SOURCES.md
@@ -18,3 +18,7 @@ Date: 2026-11-23. The originals are preserved without recompression.
| desktop-10.jpg | 1034545 | 4c8456065b5f51ed43a30271c7c6c3c8c4ccfbcaa0d8859d15c2b9537ee4b4b9 |
| desktop-11.jpg | 17350 | 55496164efe3f7dceba85b0f7a742007c76bcd95c7da47bf2796b58a631c5919 |
| desktop-12.jpg | 805497 | d64ec224c1a6b3c2aa5360f6deb8fab6706523c1d09110c612846b7e1b0bc17c |
+
+The small previews under `../src/assets/wallpapers/` are derived JPEGs,
+400 pixels wide at quality 82. They total 152,326 bytes. Windows receives
+the original selected JPEG; these reduced copies are only used in Settings.
diff --git a/crates/muelle-shell/src/tracker.rs b/crates/muelle-shell/src/tracker.rs
index a6e2752..fbc3661 100644
--- a/crates/muelle-shell/src/tracker.rs
+++ b/crates/muelle-shell/src/tracker.rs
@@ -10,7 +10,10 @@ use windows::{
Win32::{
Foundation::{CloseHandle, HWND, LPARAM, POINT, RECT, WPARAM},
Graphics::{
- Dwm::{DWM_CLOAKED_SHELL, DWMWA_CLOAKED, DwmGetWindowAttribute},
+ Dwm::{
+ DWM_CLOAKED_SHELL, DWMWA_CLOAKED, DWMWA_EXTENDED_FRAME_BOUNDS,
+ DwmGetWindowAttribute,
+ },
Gdi::ClientToScreen,
},
Storage::{
@@ -173,6 +176,27 @@ pub fn screen_rect(hwnd: isize) -> Option<(RECT, bool)> {
}
}
+/// The part of a window that shows on screen: its frame without the
+/// invisible resize borders Windows 10 and 11 put around it (some 7 px on
+/// each side but the top at 100 %), which `screen_rect` includes. `None`
+/// while it is minimized.
+#[must_use]
+pub fn visible_rect(hwnd: isize) -> Option<RECT> {
+ let window = HWND(hwnd as *mut _);
+ let (whole, _) = screen_rect(hwnd)?;
+ let mut rect = RECT::default();
+ // SAFETY: `rect` is a valid output of the attribute's size.
+ let framed = unsafe {
+ DwmGetWindowAttribute(
+ window,
+ DWMWA_EXTENDED_FRAME_BOUNDS,
+ (&raw mut rect).cast(),
+ size_of::<RECT>() as u32,
+ )
+ };
+ Some(if framed.is_ok() { rect } else { whole })
+}
+
/// Where a window that has just started minimizing was on screen, which by
/// then it no longer says itself: it is already at -32000.
///