gardesk/gar / 90232b7

Browse files

Add bar_height config option to manually override struts

Useful when dock/panel struts are incorrect (e.g., notch offset on Asahi).
Set gar.set("bar_height", N) in config to reserve N pixels at top.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
90232b77e99250db065a3e214e9b17d3617f7dc4
Parents
ebfedd8
Tree
f376961

3 changed files

StatusFile+-
M gar/src/config/lua.rs 5 0
M gar/src/config/mod.rs 4 0
M gar/src/core/mod.rs 19 11
gar/src/config/lua.rsmodified
@@ -287,6 +287,11 @@ impl LuaConfig {
287287
                         state.config.mouse_follows_focus = v;
288288
                     }
289289
                 }
290
+                "bar_height" => {
291
+                    if let Value::Integer(v) = value {
292
+                        state.config.bar_height = v as u32;
293
+                    }
294
+                }
290295
                 _ => {
291296
                     tracing::warn!("Unknown config key: {}", key);
292297
                 }
gar/src/config/mod.rsmodified
@@ -19,6 +19,8 @@ pub struct Config {
1919
     // Behavior settings
2020
     pub follow_window_on_move: bool,
2121
     pub mouse_follows_focus: bool,
22
+    // Manual bar/panel reserved space (overrides struts)
23
+    pub bar_height: u32,
2224
 }
2325
 
2426
 impl Default for Config {
@@ -40,6 +42,8 @@ impl Default for Config {
4042
             follow_window_on_move: false,
4143
             // Behavior: warp mouse pointer to center of focused window
4244
             mouse_follows_focus: false,
45
+            // Manual bar height (0 = use struts from dock windows)
46
+            bar_height: 0,
4347
         }
4448
     }
4549
 }
gar/src/core/mod.rsmodified
@@ -645,17 +645,25 @@ impl WindowManager {
645645
         let gap_inner = self.config.gap_inner as i16;
646646
         let half_gap = gap_inner / 2;
647647
 
648
-        // Calculate combined struts from all dock windows
649
-        let mut strut_left: u32 = 0;
650
-        let mut strut_right: u32 = 0;
651
-        let mut strut_top: u32 = 0;
652
-        let mut strut_bottom: u32 = 0;
653
-        for strut in self.dock_struts.values() {
654
-            strut_left = strut_left.max(strut.left);
655
-            strut_right = strut_right.max(strut.right);
656
-            strut_top = strut_top.max(strut.top);
657
-            strut_bottom = strut_bottom.max(strut.bottom);
658
-        }
648
+        // Calculate reserved space for bars/panels
649
+        // If bar_height is set, use it directly; otherwise use struts from dock windows
650
+        let (strut_left, strut_right, strut_top, strut_bottom) = if self.config.bar_height > 0 {
651
+            // Manual bar height overrides struts (assumes bar at top)
652
+            (0u32, 0u32, self.config.bar_height, 0u32)
653
+        } else {
654
+            // Calculate combined struts from all dock windows
655
+            let mut left: u32 = 0;
656
+            let mut right: u32 = 0;
657
+            let mut top: u32 = 0;
658
+            let mut bottom: u32 = 0;
659
+            for strut in self.dock_struts.values() {
660
+                left = left.max(strut.left);
661
+                right = right.max(strut.right);
662
+                top = top.max(strut.top);
663
+                bottom = bottom.max(strut.bottom);
664
+            }
665
+            (left, right, top, bottom)
666
+        };
659667
 
660668
         // Collect visible workspaces (one per monitor)
661669
         let visible_workspaces: Vec<(usize, Rect)> = self.monitors