gardesk/gar / 8a1594a

Browse files

fix: use work_area for tiled edge detection

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
8a1594abaa30ca68f7a42933fb1b142dd890db64
Parents
35a4759
Tree
42eab95

3 changed files

StatusFile+-
M Cargo.lock 2 2
M gar/src/core/mod.rs 40 0
M gar/src/x11/events.rs 2 2
Cargo.lockmodified
@@ -202,7 +202,7 @@ checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41"
202
 
202
 
203
 [[package]]
203
 [[package]]
204
 name = "gar"
204
 name = "gar"
205
-version = "0.1.0"
205
+version = "0.2.0"
206
 dependencies = [
206
 dependencies = [
207
  "dirs",
207
  "dirs",
208
  "libc",
208
  "libc",
@@ -217,7 +217,7 @@ dependencies = [
217
 
217
 
218
 [[package]]
218
 [[package]]
219
 name = "garctl"
219
 name = "garctl"
220
-version = "0.1.0"
220
+version = "0.2.0"
221
 dependencies = [
221
 dependencies = [
222
  "clap",
222
  "clap",
223
  "serde",
223
  "serde",
gar/src/core/mod.rsmodified
@@ -167,6 +167,25 @@ impl WindowManager {
167
         self.monitors[self.focused_monitor].geometry
167
         self.monitors[self.focused_monitor].geometry
168
     }
168
     }
169
 
169
 
170
+    /// Get the work area for the focused monitor (accounting for struts and outer gaps).
171
+    pub fn work_area(&self) -> Rect {
172
+        let screen = self.screen_rect();
173
+        let gap_outer = self.config.gap_outer as i16;
174
+
175
+        // Calculate struts for focused monitor
176
+        let (strut_left, strut_right, strut_top, strut_bottom) =
177
+            self.calculate_struts(self.focused_monitor);
178
+
179
+        Rect::new(
180
+            screen.x + gap_outer + strut_left as i16,
181
+            screen.y + gap_outer + strut_top as i16,
182
+            screen.width
183
+                .saturating_sub(2 * gap_outer as u16 + strut_left as u16 + strut_right as u16),
184
+            screen.height
185
+                .saturating_sub(2 * gap_outer as u16 + strut_top as u16 + strut_bottom as u16),
186
+        )
187
+    }
188
+
170
     /// Get the rectangle for a specific workspace's monitor.
189
     /// Get the rectangle for a specific workspace's monitor.
171
     pub fn workspace_rect(&self, workspace_idx: usize) -> Rect {
190
     pub fn workspace_rect(&self, workspace_idx: usize) -> Rect {
172
         self.monitor_for_workspace(workspace_idx)
191
         self.monitor_for_workspace(workspace_idx)
@@ -184,6 +203,27 @@ impl WindowManager {
184
         self.monitors.iter().position(|m| m.active_workspace == workspace_idx)
203
         self.monitors.iter().position(|m| m.active_workspace == workspace_idx)
185
     }
204
     }
186
 
205
 
206
+    /// Calculate struts (reserved space for panels/docks) for a monitor.
207
+    fn calculate_struts(&self, _monitor_idx: usize) -> (u32, u32, u32, u32) {
208
+        if self.config.bar_height > 0 {
209
+            // Manual bar height overrides struts (assumes bar at top)
210
+            (0, 0, self.config.bar_height, 0)
211
+        } else {
212
+            // Accumulate struts from dock windows
213
+            let mut left: u32 = 0;
214
+            let mut right: u32 = 0;
215
+            let mut top: u32 = 0;
216
+            let mut bottom: u32 = 0;
217
+            for strut in self.dock_struts.values() {
218
+                left = left.max(strut.left);
219
+                right = right.max(strut.right);
220
+                top = top.max(strut.top);
221
+                bottom = bottom.max(strut.bottom);
222
+            }
223
+            (left, right, top, bottom)
224
+        }
225
+    }
226
+
187
     /// Refresh monitors (called on RandR screen change).
227
     /// Refresh monitors (called on RandR screen change).
188
     pub fn refresh_monitors(&mut self) -> Result<()> {
228
     pub fn refresh_monitors(&mut self) -> Result<()> {
189
         tracing::info!("Refreshing monitor configuration");
229
         tracing::info!("Refreshing monitor configuration");
gar/src/x11/events.rsmodified
@@ -723,8 +723,8 @@ impl WindowManager {
723
 
723
 
724
         // Check for edge resize on TILED windows (click on gap between windows, no mod key)
724
         // Check for edge resize on TILED windows (click on gap between windows, no mod key)
725
         if !has_mod && event.detail == 1 {
725
         if !has_mod && event.detail == 1 {
726
-            let screen = self.screen_rect();
726
+            let work_area = self.work_area();
727
-            let geometries = self.current_workspace().tree.calculate_geometries(screen);
727
+            let geometries = self.current_workspace().tree.calculate_geometries(work_area);
728
 
728
 
729
             if let Some((window, direction, container_size)) =
729
             if let Some((window, direction, container_size)) =
730
                 self.find_tiled_edge(event.root_x, event.root_y, &geometries)
730
                 self.find_tiled_edge(event.root_x, event.root_y, &geometries)