Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
78 changes: 75 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/default-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/native_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/settings_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading