A lightweight, macOS-style dock for Windows 11, with glass visuals, smooth magnification, and Genie effect.
feat: implement appearance settings for dock and menu bar
CristianOlivera1bc238e356d52
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1cf29f4..bfe4f5a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,11 @@ copia la sección de la versión que se publica a la release de GitHub.### English+- Fixed Dock hiding-policy transitions and pending input: automatic hiding takes+ precedence over intelligent hiding, which is visibly paused in Settings without+ discarding its saved choice. Returning to a visible mode clears stale hiding;+ menus and held clicks keep the Dock open, with the existing hide delay resumed+ after release/cancellation. Overlap checks are skipped in automatic mode.- Internal: split the dock coordinator into private modules by responsibility,keeping its shared state, event entry points, timers and behavior unchanged.- Battery percentage, Search, Task View and Widgets now follow Windows settings@@ -33,6 +38,11 @@ copia la sección de la versión que se publica a la release de GitHub.### Español+- Corregidas las transiciones de ocultación y pulsaciones pendientes del Dock:+ la automática tiene prioridad y la inteligente queda en pausa en Ajustes,+ conservando su preferencia. Volver a un modo visible limpia ocultaciones+ anteriores; menús y pulsaciones mantienen el Dock abierto y al terminar se+ retoma el retraso existente. Sin consultas de solapamiento en modo automático.- Interno: separado el coordinador del dock en módulos privados porresponsabilidad, conservando estado, eventos, temporizadores y comportamiento.- Porcentaje de batería, Búsqueda, Vista de tareas y Widgets siguen directamentediff --git a/apps/dock/src/app.rs b/apps/dock/src/app.rsindex 14ddb39..8d7cc2f 100644--- a/apps/dock/src/app.rs+++ b/apps/dock/src/app.rs@@ -522,8 +522,10 @@ struct StageKey {/// centred in the height below it.top_inset: i32,scale: f32,- light: bool,- glass: bool,+ /// The theme, which follows Windows unless Settings picked one. A+ /// backdrop brush made while Windows had transparency off stays black+ /// after it comes back, so its `glass` rebuilds the dock both ways.+ look: crate::appearance::Look,bin_full: bool,auto_hide: bool,smart_hide: bool,diff --git a/apps/dock/src/app/drag.rs b/apps/dock/src/app/drag.rsindex d9e07fe..b283b04 100644--- a/apps/dock/src/app/drag.rs+++ b/apps/dock/src/app/drag.rs@@ -523,6 +523,11 @@ impl App {// SAFETY: Our timer and the current thread's capture window.unsafe {let _ = KillTimer(Some(self.input), DRAG_TIMER);+ // The hide delay may have expired while a press held the dock+ // open. Resume it once capture/polling ends, including cancellation.+ if self.config.hides_automatically() && !self.hovering {+ SetTimer(Some(self.input), HIDE_TIMER, HIDE_DELAY_MS, None);+ }if GetCapture() == self.input {let _ = ReleaseCapture();}diff --git a/apps/dock/src/app/events.rs b/apps/dock/src/app/events.rsindex 0b8464d..51b5eee 100644--- a/apps/dock/src/app/events.rs+++ b/apps/dock/src/app/events.rs@@ -3,7 +3,7 @@use std::sync::atomic::Ordering;use anyhow::Result;-use muelle_shell::{power, system::uses_light_theme, tracker};+use muelle_shell::{power, tracker};use windows::Win32::{Foundation::{HWND, LPARAM, LRESULT, POINT, WPARAM},System::Ole::DROPEFFECT,@@ -104,7 +104,7 @@ pub fn menu_bar_clicked(x: f32, y: f32) {return Ok(Some(Outside::InputMenu {gfx: app.gfx.clone(),anchor,- dark: !uses_light_theme(),+ dark: !crate::appearance::light(),}));}bar.click(&app.gfx, x, y)?;diff --git a/apps/dock/src/app/groups.rs b/apps/dock/src/app/groups.rsindex ac93097..82ff2e4 100644--- a/apps/dock/src/app/groups.rs+++ b/apps/dock/src/app/groups.rs@@ -2,7 +2,6 @@use anyhow::Result;use muelle_core::magnify::magnify;-use muelle_shell::system::uses_light_theme;use windows::Win32::{Foundation::POINT,UI::{Input::KeyboardAndMouse::SetCapture, WindowsAndMessaging::SetTimer},@@ -46,7 +45,7 @@ impl App {};let anchor = stage.screen_rect(*rect);let (icon, scale) = (stage.icon.round(), stage.scale);- let theme = Theme::for_system(stage.key.light, stage.key.glass);+ let theme = Theme::new(stage.key.look);// The dock's own display, which a hidden dock can move between.let (screen, edge) = (stage.key.screen, stage.frame.edge);let items = self.group_items(id, icon as u32);@@ -217,7 +216,7 @@ impl App {items,anchor,placement: menu::Placement::Above,- dark: !uses_light_theme(),+ dark: !crate::appearance::light(),})))}}diff --git a/apps/dock/src/app/input.rs b/apps/dock/src/app/input.rsindex 20db02b..81d5fb7 100644--- a/apps/dock/src/app/input.rs+++ b/apps/dock/src/app/input.rs@@ -187,9 +187,11 @@ impl App {};let draggable = self.is_draggable(entry);self.press = entry.id.clone().map(|id| Press { id, at, draggable });- if draggable {+ if self.press.is_some() {// Capture is best effort: this non-activating window also polls// until release, including when the pointer leaves the dock.+ // Fixed icons need the same release/cancel path: otherwise a+ // button-up outside the dock can leave a press holding it open.// SAFETY: Both calls target our window on its owning thread.unsafe {SetCapture(self.input);diff --git a/apps/dock/src/app/lifecycle.rs b/apps/dock/src/app/lifecycle.rsindex 873bf1c..1ae018c 100644--- a/apps/dock/src/app/lifecycle.rs+++ b/apps/dock/src/app/lifecycle.rs@@ -199,6 +199,7 @@ pub fn run() -> Result<()> {muelle_config::migrate_legacy_folder();let config = load_config();strings::set_language(config.language);+ crate::appearance::set(config.appearance);let roster = roster_from(&config);let auto_hide = config.auto_hide;let slide_omega = config.dock_auto_hide_speed.omega();diff --git a/apps/dock/src/app/menus.rs b/apps/dock/src/app/menus.rsindex b246504..d96dfec 100644--- a/apps/dock/src/app/menus.rs+++ b/apps/dock/src/app/menus.rs@@ -4,9 +4,7 @@ use std::{env, sync::atomic::Ordering, thread};use anyhow::Result;use muelle_core::{layout::Rect, magnify::magnify};-use muelle_shell::{- end_task::PreparedEndTask, jumplist, launcher, pins, system::uses_light_theme, tracker,-};+use muelle_shell::{end_task::PreparedEndTask, jumplist, launcher, pins, tracker};use windows::Win32::Foundation::{HWND, POINT};use crate::{@@ -194,7 +192,7 @@ impl App {folder,anchor,placement,- dark: !uses_light_theme(),+ dark: !crate::appearance::light(),}))}@@ -319,7 +317,7 @@ impl App {items,anchor,placement: stage_placement,- dark: !uses_light_theme(),+ dark: !crate::appearance::light(),})))}diff --git a/apps/dock/src/app/preferences.rs b/apps/dock/src/app/preferences.rsindex faa5688..22572c2 100644--- a/apps/dock/src/app/preferences.rs+++ b/apps/dock/src/app/preferences.rs@@ -1,6 +1,6 @@//! Persisted dock preferences, pinned apps and menu-bar coordination.-use std::{env, time::Instant};+use std::env;use anyhow::{Context, Result};use muelle_config::{Config, DockGroup};@@ -178,6 +178,8 @@ impl App {// Labels are drawn text: redraw them in the new language.self.assets_for = (0.0, false, 0, DockEdge::Bottom);}+ // The dock and the menu bar key their looks on it: `refresh` redraws both.+ crate::appearance::set(config.appearance);if !config.genie {self.restore_transitions();self.snapshots.clear();@@ -189,15 +191,6 @@ impl App {apply_explorer_pin(&mut self.roster, config.pin_explorer);self.slide.omega = config.dock_auto_hide_speed.omega();self.config = config;- self.smart_hidden &= self.config.smart_hide;- if hiding_changed {- if self.config.auto_hide || self.smart_hidden {- self.hide_if_unused()?;- } else {- self.slide.target = 0.0;- self.last_frame = Instant::now();- }- }if moved {// A hidden dock comes out of its new edge on every display.self.apply_edge_settings();@@ -212,6 +205,10 @@ impl App {self.update_menu_bar_app()?;self.calm_windows();self.refresh()?;+ if hiding_changed {+ // refresh has recomputed overlap for the new policy and geometry.+ self.hide_if_unused()?;+ }self.sync_badge_visuals()?;self.render()}@@ -294,14 +291,9 @@ impl App {pub(super) fn toggle_hiding(&mut self) -> Result<()> {self.config.auto_hide = save_dock_config(&self.roster, &self.config, true)?.auto_hide;- self.slide.target = if self.config.auto_hide || self.smart_hidden {- 1.0- } else {- 0.0- };- self.last_frame = Instant::now();self.apply_edge_settings();self.refresh()?;+ self.hide_if_unused()?;self.update_fullscreen()}diff --git a/apps/dock/src/app/previews.rs b/apps/dock/src/app/previews.rsindex fa7e901..c8ac961 100644--- a/apps/dock/src/app/previews.rs+++ b/apps/dock/src/app/previews.rs@@ -132,7 +132,7 @@ impl App {edge: stage.frame.edge,},stage.scale,- Theme::for_system(stage.key.light, stage.key.glass),+ Theme::new(stage.key.look),self.config.show_preview_close_button,)?);// The view owns its animation and dismissal timer while it is open.diff --git a/apps/dock/src/app/rendering.rs b/apps/dock/src/app/rendering.rsindex 3fd24a1..d919ad7 100644--- a/apps/dock/src/app/rendering.rs+++ b/apps/dock/src/app/rendering.rs@@ -12,7 +12,7 @@ use muelle_core::{use muelle_shell::{appbar::Edge,power, recycle_bin,- system::{animations_enabled, primary_monitor, transparency_enabled, uses_light_theme},+ system::{animations_enabled, primary_monitor},};use windows::Win32::{Foundation::RECT, UI::WindowsAndMessaging::SetTimer};@@ -125,10 +125,7 @@ impl App {edge,top_inset: self.menu_bar_inset(monitor.screen, edge),scale: monitor.scale,- light: uses_light_theme(),- // A backdrop brush made while Windows had transparency off stays- // black after it comes back, so this rebuilds the dock both ways.- glass: transparency_enabled(),+ look: crate::appearance::current(),bin_full: self.bin_full,auto_hide: self.config.auto_hide,smart_hide: self.config.smart_hide,@@ -162,7 +159,7 @@ impl App {..Metrics::DEFAULT}.scaled(scale);- let theme = Theme::for_system(key.light, key.glass);+ let theme = Theme::new(key.look);let px = |logical: f32| (logical * scale).round();let screen = monitor.screen;let screen_width = (screen.right - screen.left) as f32;diff --git a/apps/dock/src/app/visibility.rs b/apps/dock/src/app/visibility.rsindex 971931c..ba5c6bb 100644--- a/apps/dock/src/app/visibility.rs+++ b/apps/dock/src/app/visibility.rs@@ -41,19 +41,34 @@ pub(super) fn rects_overlap(a: RECT, b: RECT) -> bool {impl App {pub(super) fn hide_if_unused(&mut self) -> Result<()> {- if !(self.config.auto_hide || self.smart_hidden)- || self.mascot.is_some()- || self.menu_open- || self.drag_over- || self.hovering- || self.drag.is_some()- || self.switching- || self.preview.is_some()- || self.group_view.is_some()+ // One decision for timer, settings and overlap changes. Automatic+ // hiding wins; intelligent hiding matters only in its absence.+ let hidden = self.config.auto_hide || (self.config.smart_hide && self.smart_hidden);+ if hidden+ && (self.mascot.is_some()+ || self.menu_open+ || self.press.is_some()+ || self.drag_over+ || self.hovering+ || self.drag.is_some()+ || self.switching+ || self.preview.is_some()+ || self.group_view.is_some()){return Ok(());}- self.slide.target = 1.0;+ if !hidden {+ // A queued hide must not survive returning to the desktop or+ // disabling a policy. Other interactions keep their own timers.+ unsafe {+ let _ = KillTimer(Some(self.input), HIDE_TIMER);+ }+ }+ let target = if hidden { 1.0 } else { 0.0 };+ if self.slide.target == target {+ return Ok(());+ }+ self.slide.target = target;self.last_frame = Instant::now();self.place_windows()}@@ -233,10 +248,15 @@ impl App {}pub(super) fn update_smart_hiding(&mut self) -> Result<()> {- let front = tracker::foreground_window();- let covered = self.config.smart_hide- && self.windows.iter().any(|window| window.hwnd == front)+ // Paused under automatic hiding: no competing overlap controller and+ // no native geometry query for a policy that cannot affect visibility.+ let covered = !self.config.auto_hide+ && self.config.smart_hide&& self.stage.as_ref().is_some_and(|stage| {+ let front = tracker::foreground_window();+ if !self.windows.iter().any(|window| window.hwnd == front) {+ return false;+ }tracker::screen_rect(front).is_some_and(|(rect, _)| {rects_overlap(stage.screen_rect(Rect {@@ -251,13 +271,7 @@ impl App {});if covered != self.smart_hidden {self.smart_hidden = covered;- if self.config.auto_hide || covered {- self.hide_if_unused()?;- } else {- self.slide.target = 0.0;- self.last_frame = Instant::now();- self.place_windows()?;- }+ self.hide_if_unused()?;self.render()?;}Ok(())@@ -350,3 +364,6 @@ impl App {}}}++#[cfg(test)]+mod tests;diff --git a/apps/dock/src/app/visibility/tests.rs b/apps/dock/src/app/visibility/tests.rsnew file mode 100644index 0000000..cc84351--- /dev/null+++ b/apps/dock/src/app/visibility/tests.rs@@ -0,0 +1,276 @@+//! Regression harness: hidden test-owned HWNDs, no taskbar takeover or settings writes.+use super::super::{ASSETS_READY, App, HOVER_OMEGA, Press, PreviewOrder};+use crate::{assets::Visuals, gfx::Gfx, thumbnails::Thumbnails};+use anyhow::Result;+use muelle_config::Config;+use muelle_core::{attention::Attention, frame::DockEdge, roster::Roster, spring::Spring};+use muelle_shell::{power, tracker::WindowTracker};+use std::{collections::HashMap, time::Instant};+use windows::{+ Win32::{+ Foundation::{HWND, POINT},+ System::WinRT::{+ Composition::ICompositorDesktopInterop, CreateDispatcherQueueController, DQTAT_COM_STA,+ DQTYPE_THREAD_CURRENT, DispatcherQueueOptions,+ },+ UI::WindowsAndMessaging::{+ CreateWindowExW, DestroyWindow, WS_EX_NOACTIVATE, WS_EX_NOREDIRECTIONBITMAP,+ WS_EX_TOOLWINDOW, WS_POPUP,+ },+ },+ core::{Interface, w},+};++struct Window(HWND);+impl Drop for Window {+ fn drop(&mut self) {+ unsafe {+ let _ = DestroyWindow(self.0);+ }+ }+}+struct Fixture {+ app: App,+ _windows: [Window; 2],+}+impl Fixture {+ fn new() -> Result<Self> {+ let create = || unsafe {+ CreateWindowExW(+ WS_EX_NOACTIVATE | WS_EX_NOREDIRECTIONBITMAP | WS_EX_TOOLWINDOW,+ w!("STATIC"),+ w!("Muelle hiding regression"),+ WS_POPUP,+ -32000,+ -32000,+ 1,+ 1,+ None,+ None,+ None,+ None,+ )+ .map(Window)+ };+ let windows = [create()?, create()?];+ let visual = windows[0].0;+ let input = windows[1].0;+ let gfx = Gfx::new()?;+ let target = unsafe {+ gfx.compositor+ .cast::<ICompositorDesktopInterop>()?+ .CreateDesktopWindowTarget(visual, true)?+ };+ let config = Config::default();+ let app = App {+ visual,+ input,+ gfx,+ target,+ appbar: None,+ taskbar_worker: None,+ taskbar_retry: false,+ taskbar_attempts: 0,+ fullscreen: false,+ smart_hidden: false,+ roster: Roster::default(),+ tracker: WindowTracker::default(),+ windows: Vec::new(),+ preview_order: PreviewOrder::default(),+ last_rects: HashMap::new(),+ entries: Vec::new(),+ icons: Visuals::new(visual, ASSETS_READY)?,+ downloads: None,+ bin_full: false,+ _bin_watch: None,+ _saver_watch: power::SaverWatch::new(input.0 as isize),+ pin_watch: None,+ badge_watch: None,+ attention: Attention::default(),+ attention_enabled: false,+ assets: HashMap::new(),+ assets_for: (0.0, false, 0, DockEdge::Bottom),+ placeholder: None,+ remove_label: None,+ config,+ slide: Spring::at(0.0, 24.0),+ press: None,+ drag: None,+ incoming: Vec::new(),+ incoming_pin: None,+ drag_over: false,+ spring: None,+ spring_opened_group: false,+ switching: false,+ switch_started: Instant::now(),+ switch_ended: None,+ launched: Instant::now(),+ update_tried: None,+ follow: None,+ pointed: false,+ pending_drop: None,+ bounces: HashMap::new(),+ minimized: Vec::new(),+ thumbnails: Thumbnails::new(visual),+ flights: Vec::new(),+ snapshots: Vec::new(),+ menubar: None,+ edge_watch: None,+ dock_display: None,+ names: HashMap::new(),+ calmed: Vec::new(),+ started: false,+ stage: None,+ hovering: false,+ hovered: None,+ preview_candidate: None,+ preview: None,+ group_view: None,+ group_was_open: None,+ ghost: None,+ menu_open: false,+ mascot: None,+ // Initial registration notifications establish the baseline after+ // the queue starts, without playing a startup charging/saver act.+ power_seen: None,+ charging_shown: None,+ cursor: 0.0,+ amount: Spring::at(0.0, HOVER_OMEGA),+ last_frame: Instant::now(),+ };+ Ok(Self {+ app,+ _windows: windows,+ })+ }+}+fn queue() -> windows::core::Result<windows::System::DispatcherQueueController> {+ unsafe {+ CreateDispatcherQueueController(DispatcherQueueOptions {+ dwSize: size_of::<DispatcherQueueOptions>() as u32,+ threadType: DQTYPE_THREAD_CURRENT,+ apartmentType: DQTAT_COM_STA,+ })+ }+}++#[test]+#[ignore = "Native hiding regression; only hidden test-owned windows, no user settings writes"]+fn native_hiding_reconciles_all_modes_when_the_desktop_returns() -> Result<()> {+ let _queue = queue()?;+ let mut fixture = Fixture::new()?;+ let app = &mut fixture.app;+ for auto in [false, true] {+ for smart in [false, true] {+ for overlap in [false, true] {+ app.config.auto_hide = auto;+ app.config.smart_hide = smart;+ app.smart_hidden = !auto && smart && overlap;+ let hidden = auto || (smart && overlap);+ app.slide = Spring::at(if hidden { 0.0 } else { 1.0 }, 24.0);+ app.hide_if_unused()?;+ assert_eq!(+ app.slide.target,+ if hidden { 1.0 } else { 0.0 },+ "auto={auto}, smart={smart}, overlap={overlap}"+ );+ }+ }+ }+ Ok(())+}++#[test]+#[ignore = "Native hiding regression; only hidden test-owned windows, no user settings writes"]+fn native_hiding_does_not_interrupt_a_pending_press_or_open_menu() -> Result<()> {+ let _queue = queue()?;+ let mut fixture = Fixture::new()?;+ let app = &mut fixture.app;+ for auto in [false, true] {+ app.config.auto_hide = auto;+ app.config.smart_hide = true;+ app.smart_hidden = !auto;+ app.slide = Spring::at(0.0, 24.0);+ app.press = Some(Press {+ id: "test-app".into(),+ at: POINT::default(),+ draggable: true,+ });+ app.hide_if_unused()?;+ assert_eq!(+ app.slide.target, 0.0,+ "a pending icon press must keep the dock visible"+ );+ app.press = None;+ app.menu_open = true;+ app.hide_if_unused()?;+ assert_eq!(+ app.slide.target, 0.0,+ "an open menu must keep the dock visible"+ );+ app.menu_open = false;+ app.hide_if_unused()?;+ assert_eq!(+ app.slide.target, 1.0,+ "hiding resumes once the interaction ends"+ );+ // A hide timeout can fire during the press. Releasing or cancelling+ // must rearm that same one-shot delay instead of leaving the dock up.+ app.slide = Spring::at(0.0, 24.0);+ app.press = Some(Press {+ id: "test-app".into(),+ at: POINT::default(),+ draggable: false,+ });+ assert!(app.on_release()?.is_none());+ assert!(unsafe {+ windows::Win32::UI::WindowsAndMessaging::KillTimer(+ Some(app.input),+ super::super::HIDE_TIMER,+ )+ .is_ok()+ });+ app.press = Some(Press {+ id: "test-app".into(),+ at: POINT::default(),+ draggable: false,+ });+ app.cancel_drag()?;+ assert!(unsafe {+ windows::Win32::UI::WindowsAndMessaging::KillTimer(+ Some(app.input),+ super::super::HIDE_TIMER,+ )+ .is_ok()+ });+ }+ Ok(())+}++#[test]+#[ignore = "Native hiding regression; only hidden test-owned windows, no user settings writes"]+fn native_hiding_clears_overlap_when_automatic_hiding_takes_precedence() -> Result<()> {+ let _queue = queue()?;+ let mut fixture = Fixture::new()?;+ let app = &mut fixture.app;+ app.config.auto_hide = true;+ app.config.smart_hide = true;+ app.smart_hidden = true; // Previous smart-only mode.+ app.slide = Spring::at(1.0, 24.0);+ app.update_smart_hiding()?;+ assert!(+ !app.smart_hidden,+ "automatic mode must not retain intelligent overlap state"+ );+ assert_eq!(+ app.slide.target, 1.0,+ "the desktop does not override automatic hiding"+ );+ app.config.auto_hide = false;+ app.hide_if_unused()?;+ assert_eq!(+ app.slide.target, 0.0,+ "smart-only mode shows an unobstructed desktop"+ );+ Ok(())+}diff --git a/apps/dock/src/appearance.rs b/apps/dock/src/appearance.rsnew file mode 100644index 0000000..3d43511--- /dev/null+++ b/apps/dock/src/appearance.rs@@ -0,0 +1,117 @@+//! The theme Settings chose for the dock, the menu bar and their menus and+//! panels. `Auto`, the default, follows Windows' light or dark mode; the+//! others fix both the material and whether content is drawn dark or light.+//!+//! It is process state, like the Windows theme it replaces: everything that+//! draws reads `current()` when it builds, and a change rebuilds through the+//! same keys a Windows theme change does.++use std::sync::atomic::{AtomicU8, Ordering};++use muelle_config::Appearance;+use muelle_shell::system::{transparency_enabled, uses_light_theme};++/// What the glass is made of.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum Material {+ /// The dock as it always was: the light or dark macOS glass.+ Standard,+ Frosted,+ Clear,+ Aurora,+}++#[cfg(test)]+impl Material {+ pub const ALL: [Self; 4] = [Self::Standard, Self::Frosted, Self::Clear, Self::Aurora];+}++/// What a surface is drawn for.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub struct Look {+ pub material: Material,+ /// Light surfaces with dark content; otherwise the reverse.+ pub light: bool,+ /// See `system::transparency_enabled`: without it every material is solid.+ pub glass: bool,+}++static CHOICE: AtomicU8 = AtomicU8::new(Appearance::Auto as u8);++pub fn set(choice: Appearance) {+ CHOICE.store(choice as u8, Ordering::Relaxed);+}++const CHOICES: [Appearance; 6] = [+ Appearance::Light,+ Appearance::Dark,+ Appearance::Frosted,+ Appearance::Clear,+ Appearance::Aurora,+ Appearance::Auto,+];++fn decode(stored: u8) -> Appearance {+ CHOICES+ .into_iter()+ .find(|choice| *choice as u8 == stored)+ .unwrap_or_default()+}++#[must_use]+pub fn resolve(choice: Appearance, system_light: bool, glass: bool) -> Look {+ let (material, light) = match choice {+ Appearance::Auto => (Material::Standard, system_light),+ Appearance::Light => (Material::Standard, true),+ Appearance::Dark => (Material::Standard, false),+ Appearance::Frosted => (Material::Frosted, true),+ Appearance::Clear => (Material::Clear, false),+ Appearance::Aurora => (Material::Aurora, false),+ };+ Look {+ material,+ light,+ glass,+ }+}++#[must_use]+pub fn current() -> Look {+ let choice = decode(CHOICE.load(Ordering::Relaxed));+ // Only `Auto` needs the Windows theme.+ let system_light = choice == Appearance::Auto && uses_light_theme();+ resolve(choice, system_light, transparency_enabled())+}++/// Whether menus and labels are drawn light, with dark content.+#[must_use]+pub fn light() -> bool {+ current().light+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn auto_follows_windows_and_the_others_do_not() {+ for system_light in [true, false] {+ assert_eq!(+ resolve(Appearance::Auto, system_light, true).light,+ system_light+ );+ assert!(resolve(Appearance::Light, system_light, true).light);+ assert!(resolve(Appearance::Frosted, system_light, true).light);+ for dark in [Appearance::Dark, Appearance::Clear, Appearance::Aurora] {+ assert!(!resolve(dark, system_light, true).light);+ }+ }+ }++ #[test]+ fn every_choice_decodes_as_itself() {+ for choice in CHOICES {+ assert_eq!(decode(choice as u8), choice);+ }+ }+}diff --git a/apps/dock/src/main.rs b/apps/dock/src/main.rsindex 76fa8e6..784fe37 100644--- a/apps/dock/src/main.rs+++ b/apps/dock/src/main.rs@@ -13,6 +13,7 @@mod accessories;mod app;+mod appearance;mod assets;mod bluetooth;mod drop;diff --git a/apps/dock/src/menubar.rs b/apps/dock/src/menubar.rsindex c4b3b4b..a6f9bb8 100644--- a/apps/dock/src/menubar.rs+++ b/apps/dock/src/menubar.rs@@ -70,7 +70,9 @@ use windows::{use windows_numerics::{Vector2, Vector3};use crate::{- accessories, app, bluetooth, edge_watch,+ accessories, app,+ appearance::{self, Material},+ bluetooth, edge_watch,gfx::{Gfx, Ink, LabelBrush},mascot,media::{self, Control as MediaControl, Track},@@ -208,6 +210,9 @@ struct Look {language: Language,screen: RECT,scale: f32,+ /// The theme's material; `light` and `glass` are its other two halves+ /// (see `appearance::Look`).+ material: Material,light: bool,/// See `system::transparency_enabled`.glass: bool,@@ -1905,6 +1910,7 @@ impl MenuBar {{usage.refresh(false);}+ let appearance = appearance::current();let look = Look {accessories: self.accessories.as_ref().map_or([None, None], |monitor| {accessory_readings(&monitor.snapshot())@@ -1912,8 +1918,9 @@ impl MenuBar {language: strings::language(),screen: monitor.screen,scale: monitor.scale,- light: system::uses_light_theme(),- glass: system::transparency_enabled(),+ material: appearance.material,+ light: appearance.light,+ glass: appearance.glass,app_name: self.app_name.clone(),clock: system::clock_text(),input: system::input_language(),@@ -2037,20 +2044,13 @@ impl MenuBar {let layers = root.Children()?;// Without transparency the bar is solid, as macOS draws it with// "Reduce transparency".- let tint = match (look.light, look.glass) {- (true, true) => rgba(255, 255, 255, 110),- (false, true) => rgba(24, 24, 26, 120),- (true, false) => rgba(236, 236, 238, 255),- (false, false) => rgba(36, 36, 38, 255),- };- let backdrop = if look.glass {- Some(c.CreateHostBackdropBrush()?.cast()?)- } else {- None- };- let fills: [windows::UI::Composition::CompositionBrush; 1] =- [c.CreateColorBrushWithColor(tint)?.cast()?];- for brush in backdrop.iter().chain(&fills) {+ let fills = Theme::for_bar(appearance::Look {+ material: look.material,+ light: look.light,+ glass: look.glass,+ })+ .fills(gfx)?;+ for brush in &fills {let fill = c.CreateSpriteVisual()?;fill.SetSize(Vector2 {X: width,diff --git a/apps/dock/src/multi_window_view.rs b/apps/dock/src/multi_window_view.rsindex 0d77ac5..1e3c072 100644--- a/apps/dock/src/multi_window_view.rs+++ b/apps/dock/src/multi_window_view.rs@@ -892,12 +892,20 @@ mod tests {}let windows: Vec<_> = sources.iter().map(|source| source.0.0 as isize).collect();let gfx = Gfx::new()?;- for theme in [- Theme::for_system(false, false),- Theme::for_system(false, true),- Theme::for_system(true, false),- Theme::for_system(true, true),- ] {+ let themes = crate::appearance::Material::ALL+ .into_iter()+ .flat_map(|material| {+ [(false, false), (false, true), (true, false), (true, true)].map(+ |(light, glass)| {+ Theme::new(crate::appearance::Look {+ material,+ light,+ glass,+ })+ },+ )+ });+ for theme in themes {let mut view = MultiWindowView::show(&gfx,"test".into(),diff --git a/apps/dock/src/scene.rs b/apps/dock/src/scene.rsindex 382ccee..f855e55 100644--- a/apps/dock/src/scene.rs+++ b/apps/dock/src/scene.rs@@ -21,7 +21,10 @@ use windows::{};use windows_numerics::{Vector2, Vector3};-use crate::gfx::{Gfx, LabelBrush};+use crate::{+ appearance::{Look, Material},+ gfx::{Gfx, LabelBrush},+};#[derive(Clone, Copy)]pub struct Theme {@@ -29,43 +32,117 @@ pub struct Theme {/// Blur what is behind the dock; without it the tint is drawn opaque.glass: bool,tint: Color,+ /// Aurora's colours, drawn over the tint from one corner to the other.+ glow: Option<[Color; 3]>,+ /// Folders and window cards hold text: a clear dock still gets a+ /// panel that keeps it readable.+ panel_tint: Color,+ /// Top of the light that falls on the glass, fading by the middle.+ sheen: u8,+ /// The rim's brightness at its corners and sides (see `GlassSurface`).+ rim: [u8; 4],separator: Color,shadow: Color,indicator: Color,}+/// Aurora: green, violet and pink lights over a night-blue tint.+const AURORA: [Color; 3] = [+ rgba(36, 214, 168, 120),+ rgba(118, 92, 255, 110),+ rgba(246, 96, 182, 105),+];+impl Theme {- /// `glass` is false while Windows has transparency off (or energy saver- /// on): the dock is then solid gray, as macOS draws it with "Reduce- /// transparency".- pub fn for_system(light: bool, glass: bool) -> Self {- if light {- Self {- light,- glass,- tint: if glass {- rgba(255, 255, 255, 46)- } else {- rgba(226, 226, 228, 255)- },- separator: rgba(0, 0, 0, 56),- shadow: rgba(0, 0, 0, 56),- indicator: rgba(0, 0, 0, 170),- }- } else {- Self {- light,- glass,- tint: if glass {- rgba(28, 28, 30, 82)- } else {- rgba(44, 44, 46, 255)- },- separator: rgba(255, 255, 255, 64),- shadow: rgba(0, 0, 0, 96),- indicator: rgba(255, 255, 255, 215),+ /// Without `look.glass` (Windows transparency off, or energy saver on)+ /// every material is solid, as macOS draws it with "Reduce transparency".+ pub fn new(look: Look) -> Self {+ let Look {+ material,+ light,+ glass,+ } = look;+ let pick = |clear: Color, solid: Color| if glass { clear } else { solid };+ let tint = match (material, light) {+ (Material::Standard, true) => pick(rgba(255, 255, 255, 46), rgba(226, 226, 228, 255)),+ (Material::Standard, false) => pick(rgba(28, 28, 30, 82), rgba(44, 44, 46, 255)),+ (Material::Frosted, _) => pick(rgba(250, 251, 253, 158), rgba(236, 238, 242, 255)),+ (Material::Clear, _) => pick(rgba(255, 255, 255, 14), rgba(38, 40, 46, 255)),+ (Material::Aurora, _) => pick(rgba(12, 16, 42, 92), rgba(22, 22, 50, 255)),+ };+ let (sheen, rim) = match material {+ Material::Standard | Material::Aurora => (38, [150, 40, 30, 105]),+ Material::Frosted => (70, [210, 70, 55, 150]),+ // All the light is on the edge, like a lens.+ Material::Clear => (56, [235, 80, 60, 190]),+ };+ let panel_tint = match material {+ Material::Clear => pick(rgba(24, 24, 28, 150), tint),+ _ => tint,+ };+ Self {+ light,+ glass,+ tint,+ glow: (material == Material::Aurora).then_some(AURORA),+ panel_tint,+ sheen,+ rim,+ separator: if light {+ rgba(0, 0, 0, 56)+ } else {+ rgba(255, 255, 255, 64)+ },+ shadow: if light {+ rgba(0, 0, 0, 56)+ } else {+ rgba(0, 0, 0, 96)+ },+ indicator: if light {+ rgba(0, 0, 0, 170)+ } else {+ rgba(255, 255, 255, 215)+ },+ }+ }++ /// The menu bar: the same material, a little denser so that the clock+ /// and the status items stay readable over any wallpaper.+ pub(crate) fn for_bar(look: Look) -> Self {+ let pick = |clear: Color, solid: Color| if look.glass { clear } else { solid };+ let tint = match (look.material, look.light) {+ (Material::Standard, true) => pick(rgba(255, 255, 255, 110), rgba(236, 236, 238, 255)),+ (Material::Standard, false) => pick(rgba(24, 24, 26, 120), rgba(36, 36, 38, 255)),+ (Material::Frosted, _) => pick(rgba(250, 251, 253, 178), rgba(238, 240, 244, 255)),+ (Material::Clear, _) => pick(rgba(0, 0, 0, 38), rgba(30, 32, 38, 255)),+ (Material::Aurora, _) => pick(rgba(10, 14, 38, 120), rgba(20, 20, 46, 255)),+ };+ Self {+ tint,+ ..Self::new(look)+ }+ }++ /// Brushes that fill a surface of this theme, bottom first: what is+ /// behind it (with glass), the tint, and Aurora's lights.+ pub(crate) fn fills(&self, gfx: &Gfx) -> Result<Vec<CompositionBrush>> {+ let c = &gfx.compositor;+ let mut fills = Vec::with_capacity(4);+ if self.glass {+ fills.push(c.CreateHostBackdropBrush()?.cast()?);+ }+ fills.push(c.CreateColorBrushWithColor(self.tint)?.cast()?);+ if let Some(colors) = self.glow {+ let glow = c.CreateLinearGradientBrush()?;+ glow.SetStartPoint(v2(0.0, 0.0))?;+ glow.SetEndPoint(v2(1.0, 1.0))?;+ let stops = glow.ColorStops()?;+ for (at, color) in [0.0, 0.5, 1.0].into_iter().zip(colors) {+ stops.Append(&c.CreateColorGradientStopWithOffsetAndColor(at, color)?)?;}+ fills.push(glow.cast()?);}+ Ok(fills)}/// Inside the frame around the icon a dragged app would join.@@ -79,9 +156,15 @@ impl Theme {/// Uses the context menu tint with the same rim and sheen as the window picker.pub(crate) fn for_popup(light: bool, glass: bool) -> Self {+ let tint = crate::menu::popup_tint(!light, glass);Self {- tint: crate::menu::popup_tint(!light, glass),- ..Self::for_system(light, glass)+ tint,+ panel_tint: tint,+ ..Self::new(Look {+ material: Material::Standard,+ light,+ glass,+ })}}@@ -94,7 +177,11 @@ impl Theme {scale: f32,) -> Result<ContainerVisual> {let stroke = scale.max(1.0);- let material = GlassSurface::build(gfx, *self, radius, stroke)?;+ let panel = Self {+ tint: self.panel_tint,+ ..*self+ };+ let material = GlassSurface::build(gfx, panel, radius, stroke)?;material.glass.SetSize(size)?;material.outline.SetSize(size)?;material.rim.SetSize(size)?;@@ -130,21 +217,15 @@ impl GlassSurface {sheen.SetStartPoint(v2(0.0, 0.0))?;sheen.SetEndPoint(v2(0.0, 1.0))?;let stops = sheen.ColorStops()?;- stops- .Append(&c.CreateColorGradientStopWithOffsetAndColor(0.0, rgba(255, 255, 255, 38))?)?;+ stops.Append(+ &c.CreateColorGradientStopWithOffsetAndColor(0.0, rgba(255, 255, 255, theme.sheen))?,+ )?;stops.Append(&c.CreateColorGradientStopWithOffsetAndColor(0.55, rgba(255, 255, 255, 0))?)?;- let backdrop: Option<CompositionBrush> = if theme.glass {- Some(c.CreateHostBackdropBrush()?.cast()?)- } else {- None- };- let fills = [- c.CreateColorBrushWithColor(theme.tint)?.cast()?,- sheen.cast()?,- ];- for brush in backdrop.iter().chain(&fills) {+ let mut fills = theme.fills(gfx)?;+ fills.push(sheen.cast()?);+ for brush in &fills {let fill = c.CreateSpriteVisual()?;fill.SetRelativeSizeAdjustment(v2(1.0, 1.0))?;fill.SetBrush(brush)?;@@ -156,7 +237,7 @@ impl GlassSurface {rim_brush.SetEndPoint(v2(1.0, 1.0))?;rim_brush.SetInterpolationSpace(CompositionColorSpace::RgbLinear)?;let stops = rim_brush.ColorStops()?;- for (at, alpha) in [(0.0, 150), (0.35, 40), (0.65, 30), (1.0, 105)] {+ for (at, alpha) in [0.0, 0.35, 0.65, 1.0].into_iter().zip(theme.rim) {stops.Append(&c.CreateColorGradientStopWithOffsetAndColor(at, rgba(255, 255, 255, alpha))?,)?;@@ -338,7 +419,10 @@ mod attention_tests {};let gfx = Gfx::new()?;for scale in [1.0, 1.25, 1.5, 2.0] {- for light in [false, true] {+ for (material, light) in crate::appearance::Material::ALL+ .into_iter()+ .flat_map(|material| [(material, false), (material, true)])+ {let layout = layout(&[ItemKind::Icon, ItemKind::Icon],&Metrics::DEFAULT.scaled(scale),@@ -349,7 +433,11 @@ mod attention_tests {&SceneInput {layout: &layout,contents: &contents,- theme: Theme::for_system(light, true),+ theme: Theme::new(Look {+ material,+ light,+ glass: true,+ }),scale,frame: DockFrame::new(DockEdge::Bottom, (0.0, 0.0), layout.height),remove_label: None,diff --git a/apps/settings/src/App.tsx b/apps/settings/src/App.tsxindex 6469053..5893d8b 100644--- a/apps/settings/src/App.tsx+++ b/apps/settings/src/App.tsx@@ -431,8 +431,8 @@ export function App() {onChange={(autoHide) => update({ autoHide })}/></Row>- <Row label={t.smartHide} hint={t.smartHideHint}>- <Toggle label={t.smartHide} checked={config.smartHide ?? false} onChange={(smartHide) => update({ smartHide })} />+ <Row label={t.smartHide} hint={config.autoHide ? t.smartHidePausedHint : t.smartHideHint}>+ <Toggle label={t.smartHide} checked={config.smartHide ?? false} disabled={config.autoHide} onChange={(smartHide) => update({ smartHide })} /></Row><SubRow label={t.dockAutoHideSpeed} open={config.autoHide || (config.smartHide ?? false)}><Segmented<DockAutoHideSpeed>diff --git a/apps/settings/src/controls.tsx b/apps/settings/src/controls.tsxindex 231d599..a190622 100644--- a/apps/settings/src/controls.tsx+++ b/apps/settings/src/controls.tsx@@ -61,10 +61,11 @@ interface ToggleProps {/** Undefined while an inherited system value is still being read. */checked: boolean | undefined;label: string;+ disabled?: boolean;onChange: (checked: boolean) => void;}-export function Toggle({ checked, label, onChange }: ToggleProps) {+export function Toggle({ checked, label, disabled = false, onChange }: ToggleProps) {const pending = checked === undefined;return (<button@@ -73,9 +74,9 @@ export function Toggle({ checked, label, onChange }: ToggleProps) {aria-checked={checked}aria-label={label}aria-busy={pending || undefined}- disabled={pending}+ disabled={pending || disabled}className="toggle"- onClick={() => { if (!pending) onChange(!checked); }}+ onClick={() => { if (!pending && !disabled) onChange(!checked); }}>{pending ? <span className="toggle-pending" aria-hidden="true">…</span> : <span className="toggle-knob" />}</button>diff --git a/apps/settings/src/i18n/en.json b/apps/settings/src/i18n/en.jsonindex 84946b2..5667098 100644--- a/apps/settings/src/i18n/en.json+++ b/apps/settings/src/i18n/en.json@@ -24,7 +24,7 @@"dockPositionBottom": "Bottom","dockPositionRight": "Right","autoHide": "Automatically hide",- "autoHideHint": "Rest the pointer at the Dock's edge to reveal it, on any display.",+ "autoHideHint": "Hide the Dock until you rest the pointer at its edge, even on the desktop.","genie": "Genie effect","genieHint": "While it is on, windows do not use the Windows animations for maximizing or closing.","genieSpeed": "Genie speed",@@ -116,5 +116,6 @@"githubStar": "Support with a star","githubError": "Could not open GitHub. Try again.","smartHide": "Intelligent hiding",- "smartHideHint": "Keep the Dock visible on the desktop; hide it when the active window overlaps it."+ "smartHideHint": "Keep the Dock visible on the desktop; hide it when the active window overlaps it.",+ "smartHidePausedHint": "Paused while automatic hiding is on. Turn it off to keep the Dock visible on the desktop."}diff --git a/apps/settings/src/i18n/es.json b/apps/settings/src/i18n/es.jsonindex 0b30e66..2da4927 100644--- a/apps/settings/src/i18n/es.json+++ b/apps/settings/src/i18n/es.json@@ -24,7 +24,7 @@"dockPositionBottom": "Abajo","dockPositionRight": "Derecha","autoHide": "Ocultar automáticamente",- "autoHideHint": "Deja el puntero en el borde del Dock para mostrarlo, en cualquier pantalla.",+ "autoHideHint": "Oculta el Dock hasta que dejes el puntero en su borde, incluso en el escritorio.","genie": "Efecto genio","genieHint": "Mientras está activo, las ventanas no usan las animaciones de Windows al maximizar ni al cerrar.","genieSpeed": "Velocidad del genio",@@ -116,5 +116,6 @@"githubStar": "Apoya con una estrella","githubError": "No se pudo abrir GitHub. Inténtalo otra vez.","smartHide": "Ocultación inteligente",- "smartHideHint": "Mantiene el Dock visible en el escritorio y lo oculta si la ventana activa ocupa su espacio."+ "smartHideHint": "Mantiene el Dock visible en el escritorio y lo oculta si la ventana activa ocupa su espacio.",+ "smartHidePausedHint": "En pausa mientras la ocultación automática esté activa. Desactívala para mantener el Dock visible en el escritorio."}diff --git a/apps/settings/src/i18n/fr.json b/apps/settings/src/i18n/fr.jsonindex 41cea42..2b00130 100644--- a/apps/settings/src/i18n/fr.json+++ b/apps/settings/src/i18n/fr.json@@ -24,7 +24,7 @@"dockPositionBottom": "Bas","dockPositionRight": "Droite","autoHide": "Masquer automatiquement",- "autoHideHint": "Laissez le pointeur sur le bord du Dock pour l'afficher, sur tout écran.",+ "autoHideHint": "Masque le Dock jusqu’à ce que le pointeur reste sur son bord, même sur le bureau.","genie": "Effet génie","genieHint": "Tant qu'il est activé, les fenêtres n'utilisent pas les animations de Windows pour l'agrandissement et la fermeture.","genieSpeed": "Vitesse du génie",@@ -116,5 +116,6 @@"githubStar": "Soutenir avec une étoile","githubError": "Impossible d'ouvrir GitHub. Réessayez.","smartHide": "Masquage intelligent",- "smartHideHint": "Garde le Dock visible sur le bureau et le masque si la fenêtre active le recouvre."+ "smartHideHint": "Garde le Dock visible sur le bureau et le masque si la fenêtre active le recouvre.",+ "smartHidePausedHint": "En pause pendant le masquage automatique. Désactivez-le pour garder le Dock visible sur le bureau."}diff --git a/apps/settings/src/styles.css b/apps/settings/src/styles.cssindex aa7660e..32cdcf7 100644--- a/apps/settings/src/styles.css+++ b/apps/settings/src/styles.css@@ -442,7 +442,7 @@ input:focus-visible {background: #34c759;}-.toggle[aria-busy="true"] { opacity: 0.55; }+.toggle:disabled { opacity: 0.55; }.toggle-pending { display: block; color: var(--text-dim); line-height: 18px; }.toggle-knob {diff --git a/apps/settings/tests/app.test.mjs b/apps/settings/tests/app.test.mjsindex 1547307..3eebeba 100644--- a/apps/settings/tests/app.test.mjs+++ b/apps/settings/tests/app.test.mjs@@ -173,6 +173,36 @@ test("other workspaces are opt-in and save without changing other window prefere} finally { unmount(); }});+test("automatic hiding pauses intelligent hiding without discarding its saved choice", async () => {+ for (const language of Object.keys(texts)) for (const smartHide of [false, true]) {+ const view = fixture("dock", { language, autoHide: true, smartHide });+ const unmount = await view.mount();+ const smartToggle = () => [...elements(view.body())].find((node) =>+ node.props.label === texts[language].smartHide && "checked" in node.props);+ try {+ let toggle = smartToggle();+ assert.equal(toggle.props.disabled, true);+ assert.equal(toggle.props.checked, smartHide);+ const button = toggle.type(toggle.props);+ assert.equal(button.props.disabled, true);+ assert.equal(button.props["aria-busy"], undefined);+ button.props.onClick(); // Disabled is not a loading state or a writable control.+ view.fire(60);+ await settle();+ assert.deepEqual(view.calls, []);+ const paused = renderToStaticMarkup(React.createElement("span", null, texts[language].smartHidePausedHint)).slice(6, -7);+ assert.ok(renderToStaticMarkup(view.body()).includes(paused));+ view.change(texts[language].autoHide, false);+ view.fire(60);+ await settle();+ toggle = smartToggle();+ assert.equal(toggle.props.disabled, false);+ assert.equal(toggle.props.checked, smartHide);+ assert.deepEqual(view.calls, [{ autoHide: false }]);+ } finally { unmount(); }+ }+});+test("failed writes remain retryable and prevent closing until saved", async () => {let fail = true;const view = fixture("menubar", {}, async () => { if (fail) throw new Error("disk busy"); });diff --git a/crates/muelle-config/src/lib.rs b/crates/muelle-config/src/lib.rsindex 856581c..3ed7b1f 100644--- a/crates/muelle-config/src/lib.rs+++ b/crates/muelle-config/src/lib.rs@@ -112,6 +112,9 @@ pub struct Config {/// computer, new versions are downloaded and installed without asking.pub auto_update: bool,pub language: Language,+ /// The look of the dock, the menu bar and their menus and panels.+ /// `Auto` (the default) follows Windows' light or dark mode.+ pub appearance: Appearance,/// A folder shown at the right of the dock whose contents open as a/// menu, with a submenu for each folder inside, like a Windows 10 taskbar/// toolbar. Only one: the user arranges the folder as they like.@@ -242,6 +245,26 @@ pub enum Language {Auto,}+/// The themes Settings offers, as macOS offers its appearances. Every glass+/// theme falls back to a solid one while Windows has transparency off.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "lowercase")]+pub enum Appearance {+ Light,+ Dark,+ /// Milky glass with a fine grain (issue #50). Dark content.+ Frosted,+ /// Barely tinted glass with a bright rim. Light content.+ Clear,+ /// Glass tinted with the colours of the northern lights. Light content.+ Aurora,+ /// Follow Windows' light or dark mode. Also what a theme added by a newer+ /// version reads as (serde needs this fallback last).+ #[default]+ #[serde(other)]+ Auto,+}+pub const ICON_SIZE_RANGE: (u32, u32) = (32, 96);pub const MAX_MAGNIFIED_SIZE: u32 = 160;@@ -314,6 +337,7 @@ impl Default for Config {check_updates: true,auto_update: true,language: Language::Auto,+ appearance: Appearance::Auto,shortcuts_folder: None,show_preview_close_button: true,notification_badges: true,@@ -849,6 +873,18 @@ mod tests {assert_eq!(left.dock_position, DockPosition::Left);}+ #[test]+ fn the_appearance_follows_windows_unless_chosen() {+ // Files from before the setting, and themes from newer versions.+ for json in [r#"{}"#, r#"{"appearance":"sepia"}"#] {+ let config: Config = serde_json::from_str(json).unwrap_or_default();+ assert_eq!(config.appearance, Appearance::Auto);+ }+ let frosted: Config =+ serde_json::from_str(r#"{"appearance":"frosted"}"#).unwrap_or_default();+ assert_eq!(frosted.appearance, Appearance::Frosted);+ }+#[test]fn genie_speed_keeps_the_original_speed_unless_chosen() {// Files from before the setting, and values from newer versions.