git.lucas.co / cce-window-manager
window management library
git clone https://git.lucas.co/cce-window-manager.git

commit7db0f01a3cc5ba818c60ee0b17fe4db6fbb17081
parentf90814e9ec
authorLucas Galante <[email protected]>
date2026-08-05 08:24
feat: configurable status segment spacing (ArrangeParams::status_module_spacing)

The gap between adjacent status segments was the hardcoded SPACING
constant. It now threads through ArrangeParams → StatusBarLayoutParams
so the compositor can source it from config; the old value stays as
pub DEFAULT_STATUS_MODULE_SPACING (12).

Co-Authored-By: Claude Fable 5 <[email protected]>

 src/arrange.rs | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/arrange.rs b/src/arrange.rs
index 8c7f48a..01bd5c1 100644
--- a/src/arrange.rs
+++ b/src/arrange.rs
@@ -48,6 +48,9 @@ pub struct StatusBarLayoutParams {
     pub hide_mode: bool,
     /// Pixels of bar left peeking when hide_mode pushes top bars offscreen.
     pub hide_mode_preview: i32,
+    /// Gap between adjacent status segments (the bar's `module { spacing }`;
+    /// [`DEFAULT_STATUS_MODULE_SPACING`] when unconfigured).
+    pub spacing: i32,
 }
 
 /// The usable (tileable) area of an output: the layout box, shrunk by the
@@ -488,7 +491,9 @@ pub fn place_normal_window(
     }
 }
 
-const SPACING: i32 = 12;
+/// Default gap between adjacent status segments — the fallback for
+/// [`StatusBarLayoutParams::spacing`] / [`ArrangeParams::status_module_spacing`].
+pub const DEFAULT_STATUS_MODULE_SPACING: i32 = 12;
 const MARGIN: i32 = 12;
 
 const LEFT_ORDER: &[&str] = &["viewport", "window"];
@@ -524,7 +529,7 @@ pub fn layout_status_bars(
 ) -> Vec<Option<StatusBarPlacement>> {
     let wlr_box = p.output;
     let bar_h = p.bar_height;
-    let spacing = SPACING;
+    let spacing = p.spacing;
     let margin = MARGIN;
 
     let mut top_left: Vec<usize> = Vec::new();
@@ -777,6 +782,8 @@ pub struct ArrangeParams {
     pub bar_height: i32,
     pub status_hide_mode: bool,
     pub hide_mode_preview: i32,
+    /// Gap between adjacent status segments (see `StatusBarLayoutParams::spacing`).
+    pub status_module_spacing: i32,
     /// `status_background_blur > 0.001`.
     pub status_blur: bool,
     pub window_blur: bool,
@@ -1107,6 +1114,7 @@ pub fn arrange(
                 bar_height: p.bar_height as u32,
                 hide_mode: p.status_hide_mode,
                 hide_mode_preview: p.hide_mode_preview,
+                spacing: p.status_module_spacing,
             },
         );
 
@@ -1134,6 +1142,7 @@ mod tests {
             bar_height: 30,
             hide_mode: false,
             hide_mode_preview: 5,
+            spacing: DEFAULT_STATUS_MODULE_SPACING,
         }
     }
 
@@ -1516,6 +1525,7 @@ mod tests {
             bar_height: 30,
             status_hide_mode: false,
             hide_mode_preview: 5,
+            status_module_spacing: DEFAULT_STATUS_MODULE_SPACING,
             status_blur: true,
             window_blur: true,
             opacity_enabled: true,