srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/core/src/window.rs
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2025-11-16 21:46:00 +0200
committersrdusr <[email protected]>2025-11-16 21:46:00 +0200
commit354ce158575388d17ca9c58587e8cdde02332779 (patch)
tree446232fa1d502bc4e5e2ce49a17a504bac381429 /crates/core/src/window.rs
parent16950c4cfc13bbffad07254f0d994d10a1a88774 (diff)
downloadsrdwm-354ce158575388d17ca9c58587e8cdde02332779.tar.gz
srdwm-354ce158575388d17ca9c58587e8cdde02332779.zip
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 <bool> - 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.
Diffstat (limited to 'crates/core/src/window.rs')
-rw-r--r--crates/core/src/window.rs32
1 files changed, 32 insertions, 0 deletions
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<ButtonOrder> {
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::<Vec<_>>()
+ .join(",")
+}
+
#[cfg(test)]
mod button_order_tests {
use super::*;
@@ -869,6 +886,21 @@ mod button_order_tests {
}
#[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);
}