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 {
287
                         state.config.mouse_follows_focus = v;
287
                         state.config.mouse_follows_focus = v;
288
                     }
288
                     }
289
                 }
289
                 }
290
+                "bar_height" => {
291
+                    if let Value::Integer(v) = value {
292
+                        state.config.bar_height = v as u32;
293
+                    }
294
+                }
290
                 _ => {
295
                 _ => {
291
                     tracing::warn!("Unknown config key: {}", key);
296
                     tracing::warn!("Unknown config key: {}", key);
292
                 }
297
                 }
gar/src/config/mod.rsmodified
@@ -19,6 +19,8 @@ pub struct Config {
19
     // Behavior settings
19
     // Behavior settings
20
     pub follow_window_on_move: bool,
20
     pub follow_window_on_move: bool,
21
     pub mouse_follows_focus: bool,
21
     pub mouse_follows_focus: bool,
22
+    // Manual bar/panel reserved space (overrides struts)
23
+    pub bar_height: u32,
22
 }
24
 }
23
 
25
 
24
 impl Default for Config {
26
 impl Default for Config {
@@ -40,6 +42,8 @@ impl Default for Config {
40
             follow_window_on_move: false,
42
             follow_window_on_move: false,
41
             // Behavior: warp mouse pointer to center of focused window
43
             // Behavior: warp mouse pointer to center of focused window
42
             mouse_follows_focus: false,
44
             mouse_follows_focus: false,
45
+            // Manual bar height (0 = use struts from dock windows)
46
+            bar_height: 0,
43
         }
47
         }
44
     }
48
     }
45
 }
49
 }
gar/src/core/mod.rsmodified
@@ -645,17 +645,25 @@ impl WindowManager {
645
         let gap_inner = self.config.gap_inner as i16;
645
         let gap_inner = self.config.gap_inner as i16;
646
         let half_gap = gap_inner / 2;
646
         let half_gap = gap_inner / 2;
647
 
647
 
648
-        // Calculate combined struts from all dock windows
648
+        // Calculate reserved space for bars/panels
649
-        let mut strut_left: u32 = 0;
649
+        // If bar_height is set, use it directly; otherwise use struts from dock windows
650
-        let mut strut_right: u32 = 0;
650
+        let (strut_left, strut_right, strut_top, strut_bottom) = if self.config.bar_height > 0 {
651
-        let mut strut_top: u32 = 0;
651
+            // Manual bar height overrides struts (assumes bar at top)
652
-        let mut strut_bottom: u32 = 0;
652
+            (0u32, 0u32, self.config.bar_height, 0u32)
653
-        for strut in self.dock_struts.values() {
653
+        } else {
654
-            strut_left = strut_left.max(strut.left);
654
+            // Calculate combined struts from all dock windows
655
-            strut_right = strut_right.max(strut.right);
655
+            let mut left: u32 = 0;
656
-            strut_top = strut_top.max(strut.top);
656
+            let mut right: u32 = 0;
657
-            strut_bottom = strut_bottom.max(strut.bottom);
657
+            let mut top: u32 = 0;
658
-        }
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
+        };
659
 
667
 
660
         // Collect visible workspaces (one per monitor)
668
         // Collect visible workspaces (one per monitor)
661
         let visible_workspaces: Vec<(usize, Rect)> = self.monitors
669
         let visible_workspaces: Vec<(usize, Rect)> = self.monitors