From cb8fc00afb2d1c554cfcbf604490155b438776b2 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 31 Oct 2026 10:42:45 -0700 Subject: [PATCH] refactor(mac-bar): converge komorebi.rs config text and komorebi_layout.rs onto the Windows source Schema-text differences only, so that the config types can move into the core: the macOS KomorebiLayout gets `#[serde(untagged)]` (its Deserialize is hand-written and nothing in the bar serializes a layout, so no runtime effect; it only changes the generated schema and the derived Serialize), `eyre::Result` and `1.0_f32`; KomorebiFocusedContainerConfig::show_icon gets the Windows `#[deprecated]` and doc (with `#[allow(deprecated)]` at the one use). The macOS schema view already sets the macOS text of KomorebiLayout and show_icon back, so komorebi-for-mac/schema.bar.json and nix/komorebi-bar-options.nix do not change. The coordinator asked to leave komorebi_layout alone: this was done because the evidence says it is not a behaviour difference (custom Deserialize, no serialization anywhere in the macOS bar: `grep to_string|to_value|to_writer` finds none); it is a separate revision and can be dropped. Verified: schema harness macOS and Windows byte-identical (3,774 / 9,091 lines); the two komorebi_layout.rs are byte-identical and the config region of the two komorebi.rs is identical; Windows clippy -D warnings --locked clean; macOS fake-CC check --locked 0 errors. --- komorebi-for-mac/komorebi-bar/src/widgets/komorebi.rs | 5 ++++- .../komorebi-bar/src/widgets/komorebi_layout.rs | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/komorebi-for-mac/komorebi-bar/src/widgets/komorebi.rs b/komorebi-for-mac/komorebi-bar/src/widgets/komorebi.rs index 0b9cbaf5..170c9c78 100644 --- a/komorebi-for-mac/komorebi-bar/src/widgets/komorebi.rs +++ b/komorebi-for-mac/komorebi-bar/src/widgets/komorebi.rs @@ -113,7 +113,8 @@ pub struct KomorebiWorkspaceLayerConfig { pub struct KomorebiFocusedContainerConfig { /// Enable the Komorebi Focused Container widget pub enable: bool, - /// DEPRECATED: use 'display' instead (Show the icon of the currently focused container) + /// DEPRECATED: use `display` instead (Show the icon of the currently focused container) + #[deprecated(note = "Use `display` instead")] pub show_icon: Option, /// Display format of the currently focused container pub display: Option, @@ -530,7 +531,9 @@ impl FocusedContainerBar { if !value.enable { return None; } + // Handle legacy setting - convert show_icon to display format + #[allow(deprecated)] let format = value .display .unwrap_or(if value.show_icon.unwrap_or(false) { diff --git a/komorebi-for-mac/komorebi-bar/src/widgets/komorebi_layout.rs b/komorebi-for-mac/komorebi-bar/src/widgets/komorebi_layout.rs index c6b1c6a8..5c35246c 100644 --- a/komorebi-for-mac/komorebi-bar/src/widgets/komorebi_layout.rs +++ b/komorebi-for-mac/komorebi-bar/src/widgets/komorebi_layout.rs @@ -2,6 +2,7 @@ use crate::config::DisplayFormat; use crate::render::RenderConfig; use crate::selected_frame::SelectableFrame; use crate::widgets::komorebi::KomorebiLayoutConfig; +use color_eyre::eyre; use eframe::egui::Context; use eframe::egui::CornerRadius; use eframe::egui::FontId; @@ -24,6 +25,7 @@ use std::fmt::Formatter; #[derive(Copy, Clone, Debug, Serialize, PartialEq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[serde(untagged)] /// Komorebi layout kind pub enum KomorebiLayout { /// Predefined layout @@ -40,7 +42,7 @@ pub enum KomorebiLayout { } impl<'de> Deserialize<'de> for KomorebiLayout { - fn deserialize(deserializer: D) -> Result + fn deserialize(deserializer: D) -> eyre::Result where D: Deserializer<'de>, { @@ -146,7 +148,7 @@ impl KomorebiLayout { } else { ui.style().visuals.text_color() }; - let stroke = Stroke::new(1.0, color); + let stroke = Stroke::new(1.0_f32, color); let mut rect = response.rect; let rounding = CornerRadius::same((rect.width() * 0.1) as u8); rect = rect.shrink(stroke.width);