From 354ce158575388d17ca9c58587e8cdde02332779 Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Sun, 16 Nov 2025 21:46:00 +0200 Subject: Live-expose workspace.per_monitor, titlebar buttons, and desktop icons Closes the remaining "config-file only" gaps from the AGS capability survey. workspace.per_monitor gets srd set per_monitor - safe to flip live since a monitor with no per-monitor override already falls back to current_workspace regardless of mode, so nothing visually jumps on toggle. theme.decorations.title_bar.button_style/button_side/button_order and general.desktop_icons/desktop_icons_all_monitors all get the same live-set + SettingsResponse readback treatment as everything else this session. New srdwm_core::format_button_order is parse_button_order's exact inverse, so button_order's readback matches the same string shape srd set itself accepts. --- crates/core/src/lib.rs | 2 +- crates/core/src/window.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'crates/core/src') diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 7b728d9..ed24e78 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -24,7 +24,7 @@ pub use regex::Regex; pub use rules::{WindowMatch, WindowRule, WindowRuleActions}; pub use theme::{format_hex_color, parse_hex_color, ThemeConfig}; pub use window::{ - classify_menu_source, parse_button_order, ButtonOrder, GlobalMenu, MenuSource, ResizeEdge, TitlebarButton, TitlebarHit, Window, WindowId, + classify_menu_source, format_button_order, parse_button_order, ButtonOrder, GlobalMenu, MenuSource, ResizeEdge, TitlebarButton, TitlebarHit, Window, WindowId, BUTTON_CLUSTER_MARGIN, BUTTON_PITCH, RESIZE_MARGIN, TITLEBAR_HEIGHT, }; pub use workspace::{Workspace, WorkspaceId}; diff --git a/crates/core/src/window.rs b/crates/core/src/window.rs index a8de352..21faeff 100644 --- a/crates/core/src/window.rs +++ b/crates/core/src/window.rs @@ -838,6 +838,23 @@ pub fn parse_button_order(s: &str) -> Option { Some(order) } +/// [`parse_button_order`]'s exact inverse - `"close,minimize,maximize"`, +/// lowercase, comma-separated in the order the buttons actually render. +/// Exists for settings readback, same reasoning as `format_hex_color`: +/// a caller reading `button_order` back over IPC should get the identical +/// string shape `srd set button_order` itself accepts. +pub fn format_button_order(order: ButtonOrder) -> String { + order + .iter() + .map(|b| match b { + TitlebarButton::Close => "close", + TitlebarButton::Minimize => "minimize", + TitlebarButton::Maximize => "maximize", + }) + .collect::>() + .join(",") +} + #[cfg(test)] mod button_order_tests { use super::*; @@ -868,6 +885,21 @@ mod button_order_tests { assert_eq!(parse_button_order("close,close,maximize"), None); } + #[test] + fn format_button_order_round_trips_through_parse_button_order() { + for order in [ + [TitlebarButton::Close, TitlebarButton::Minimize, TitlebarButton::Maximize], + [TitlebarButton::Maximize, TitlebarButton::Minimize, TitlebarButton::Close], + ] { + assert_eq!(parse_button_order(&format_button_order(order)), Some(order)); + } + } + + #[test] + fn format_button_order_matches_the_exact_shape_set_accepts() { + assert_eq!(format_button_order([TitlebarButton::Close, TitlebarButton::Minimize, TitlebarButton::Maximize]), "close,minimize,maximize"); + } + #[test] fn rejects_an_unknown_token() { assert_eq!(parse_button_order("close,minimize,help"), None); -- cgit v1.2.3