From dff2b8eb7416d30ae57d348bea4aca360c846080 Mon Sep 17 00:00:00 2001 From: Sumir Seth Date: Mon, 30 Nov 2026 17:44:59 +0530 Subject: [PATCH] Make window previews the default window list New configs start on previews. A config still on the old default, "multiple", moves to previews once at startup, keeping its comments; a marker file in the data folder keeps a later choice of titles. Settings lists Previews first and names the title modes as titles. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 6 ++++ src/app.rs | 3 ++ src/config.rs | 78 +++++++++++++++++++++++++++++++++++++++-- src/default-config.toml | 6 ++-- src/native_settings.rs | 10 +++--- src/settings_config.rs | 2 +- 6 files changed, 93 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ec5ee3..7eca153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ User-facing changes in each release. Each release on GitHub lists these notes and its pull requests. +## Unreleased + +### Changes + +- Window previews are now the default **Window list**, also for configs still on the old default. To go back, choose **Titles, for multiple windows** in Settings. + ## 0.9.1 - 2026-11-30 ### New diff --git a/src/app.rs b/src/app.rs index d0a06b6..56b53a0 100644 --- a/src/app.rs +++ b/src/app.rs @@ -262,6 +262,9 @@ pub fn run() -> Result<()> { // Config::load creates the config on first run. let first_run = !Config::path().exists(); + if let Err(error) = Config::adopt_previews() { + eprintln!("Window previews default: {error}"); + } let (config, config_error) = Config::load(); let (events_tx, events_rx) = channel(); let (files_tx, files_rx) = channel(); diff --git a/src/config.rs b/src/config.rs index 2049a36..e09bd1d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,6 +9,10 @@ use crate::util; use crate::config_write as write; +/// Created once `window_list` moved from "multiple" to previews, so a later +/// choice of "multiple" stays. +const PREVIEWS_MARKER: &str = "window-list-previews"; + /// Native Settings uses the same defaults. const DEFAULT_CONFIG: &str = include_str!("default-config.toml"); /// Values for missing keys that differ from the default config, shared with native Settings. @@ -43,9 +47,9 @@ pub enum Position { #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Default)] #[serde(rename_all = "kebab-case")] pub enum WindowListMode { - #[default] Multiple, Always, + #[default] Thumbnails, Off, } @@ -173,6 +177,31 @@ impl Config { Ok(config) } + /// Moves a config still on the old default window list, "multiple", to + /// previews. Runs once per install; comments are kept. + pub fn adopt_previews() -> Result<(), String> { + Self::adopt_previews_at(&Self::path(), &util::data_dir().join(PREVIEWS_MARKER)) + } + + fn adopt_previews_at(path: &std::path::Path, marker: &std::path::Path) -> Result<(), String> { + if marker.exists() { + return Ok(()); + } + match std::fs::read_to_string(path) { + Ok(text) => { + let mut doc: toml_edit::DocumentMut = + text.parse().map_err(|error: toml_edit::TomlError| error.to_string())?; + if doc.get("window_list").and_then(|value| value.as_str()) == Some("multiple") { + write::replace(&mut doc, "window_list", "thumbnails".into()); + write::save(path, &doc)?; + } + } + Err(error) if error.kind() == std::io::ErrorKind::NotFound => {} + Err(error) => return Err(format!("Cannot read config.toml: {error}")), + } + std::fs::write(marker, "").map_err(|error| error.to_string()) + } + /// Rereads the user's file and edits only the row order, preserving comments. pub fn save_order(names: &[&str]) -> Result<(), String> { Self::write_order(&Self::path(), names) @@ -268,11 +297,11 @@ mod tests { fn configs_with_removed_settings_still_load() { let config = Config::parse("dock = true\ndock_apps = ['old.app']").unwrap(); assert!(config.dock); - assert_eq!(config.window_list, super::WindowListMode::Multiple); + assert_eq!(config.window_list, super::WindowListMode::Thumbnails); } #[test] - fn window_list_modes_deserialize_and_older_config_defaults_to_multiple() { + fn window_list_modes_deserialize_and_older_config_defaults_to_previews() { for (value, expected) in [ ("multiple", super::WindowListMode::Multiple), ("always", super::WindowListMode::Always), @@ -284,6 +313,49 @@ mod tests { } } + #[test] + fn the_old_default_window_list_moves_to_previews_once() { + let dir = tempfile::tempdir().unwrap(); + let (path, marker) = (dir.path().join("config.toml"), dir.path().join("marker")); + std::fs::write( + &path, + "# mine +window_list = \"multiple\" # titles +", + ) + .unwrap(); + Config::adopt_previews_at(&path, &marker).unwrap(); + let text = std::fs::read_to_string(&path).unwrap(); + assert!(text.contains("# mine") && text.contains("window_list = \"thumbnails\"")); + // Choosing titles again afterwards sticks. + std::fs::write( + &path, + "window_list = \"multiple\" +", + ) + .unwrap(); + Config::adopt_previews_at(&path, &marker).unwrap(); + assert_eq!( + std::fs::read_to_string(&path).unwrap(), + "window_list = \"multiple\" +" + ); + // Other choices are left alone. + let other = dir.path().join("other.toml"); + std::fs::write( + &other, + "window_list = \"off\" +", + ) + .unwrap(); + Config::adopt_previews_at(&other, &dir.path().join("marker2")).unwrap(); + assert_eq!( + std::fs::read_to_string(&other).unwrap(), + "window_list = \"off\" +" + ); + } + #[test] fn missing_keys_keep_a_config_from_before_the_dock() { // A Wisp 0.3 config has none of the dock's keys and keeps the taskbar. diff --git a/src/default-config.toml b/src/default-config.toml index 885c5c4..4ea6930 100644 --- a/src/default-config.toml +++ b/src/default-config.toml @@ -67,9 +67,9 @@ dock_screen = "pointer" dock_search_button = true # App window list shown when hovering a running app icon: -# "multiple" (only when the app has multiple windows), "always", "thumbnails" -# (live previews of the app's windows), or "off". -window_list = "multiple" +# "thumbnails" (live previews of the app's windows), "multiple" (titles, only +# when the app has multiple windows), "always" (titles), or "off". +window_list = "thumbnails" # App icons in the dock, in DIPs (24 to 40). dock_icon_size = 32 diff --git a/src/native_settings.rs b/src/native_settings.rs index 6ad6b95..a39482a 100644 --- a/src/native_settings.rs +++ b/src/native_settings.rs @@ -472,9 +472,9 @@ impl Settings { pins > 0, ); let choices = vec![ - ("multiple".into(), "Only for multiple windows".into()), - ("always".into(), "Always".into()), - ("thumbnails".into(), "Previews for every app".into()), + ("thumbnails".into(), "Previews".into()), + ("multiple".into(), "Titles, for multiple windows".into()), + ("always".into(), "Titles, always".into()), ("off".into(), "Off".into()), ]; let selected = choices.iter().position(|(v, _)| v == &c.window_list).unwrap_or(0); @@ -2207,7 +2207,7 @@ mod tests { assert!(c.dock_dodge_windows); assert!(!c.dock_search_button); assert_eq!(c.dock_icon_size, 40); - assert_eq!(c.window_list, "always"); + assert_eq!(c.window_list, "multiple"); assert!(!c.hide_taskbar); assert_eq!(c.position, "center"); assert!(!c.check_for_updates); @@ -2222,7 +2222,7 @@ mod tests { fn window_list_choices_cycle_through_previews_and_off() { let dir = tempfile::tempdir().unwrap(); let mut s = fixture(dir.path().join("config.toml")); - for expected in ["always", "thumbnails", "off", "multiple"] { + for expected in ["multiple", "always", "off", "thumbnails"] { activate(&mut s, "window_list", 1); assert_eq!(s.store.load().unwrap().window_list, expected); } diff --git a/src/settings_config.rs b/src/settings_config.rs index d8ab7b3..75996f7 100644 --- a/src/settings_config.rs +++ b/src/settings_config.rs @@ -402,7 +402,7 @@ mod tests { assert!(!old.dock && !old.hide_taskbar); assert_eq!(old.position, "center"); assert_eq!(old.max_results, config.max_results); - assert_eq!(config.window_list, "multiple"); + assert_eq!(config.window_list, "thumbnails"); assert_eq!(Config::from_document(&DEFAULT_CONFIG.parse().unwrap()).unwrap(), config); }