gardesk/tarmac / 1136725

Browse files

state: inflate gaps by border_width via effective_gaps

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
1136725a0e4599b55fe35c9f4c8c69422768ea50
Parents
2a31cf7
Tree
bb4cbc2

2 changed files

StatusFile+-
M tarmac/src/core/state.rs 41 5
M tarmac/src/main.rs 1 1
tarmac/src/core/state.rsmodified
@@ -419,8 +419,23 @@ impl WmState {
419419
         }
420420
     }
421421
 
422
-    fn workspace_render_geometries(&self, ws_idx: usize, rect: Rect) -> Vec<(WindowId, Rect)> {
422
+    /// Inflate the user-configured gaps by ers's border width so the
423
+    /// configured value is the *visible* empty space between tiles, not
424
+    /// the gross window-rect-to-window-rect distance. Ers draws border
425
+    /// overlays 4px (or whatever `border_width` is) outside each window's
426
+    /// frame; with a raw 8px tile gap, two adjacent windows' 4px borders
427
+    /// fill the entire gap and visually touch. Adding 2 * border_width
428
+    /// to inner gaps and 1 * border_width to outer gaps reserves space
429
+    /// for the borders so the configured gap survives as visible empty
430
+    /// space.
431
+    pub fn effective_gaps(&self, ws_idx: usize) -> (f64, f64) {
423432
         let (gap_inner, gap_outer) = self.workspace_gaps(ws_idx);
433
+        let bw = self.borders.border_width.max(0.0);
434
+        (gap_inner + 2.0 * bw, gap_outer + bw)
435
+    }
436
+
437
+    fn workspace_render_geometries(&self, ws_idx: usize, rect: Rect) -> Vec<(WindowId, Rect)> {
438
+        let (gap_inner, gap_outer) = self.effective_gaps(ws_idx);
424439
         self.workspaces
425440
             .get(ws_idx)
426441
             .tree
@@ -428,7 +443,7 @@ impl WmState {
428443
     }
429444
 
430445
     fn workspace_focus_geometries(&self, ws_idx: usize, rect: Rect) -> Vec<(WindowId, Rect)> {
431
-        let (gap_inner, gap_outer) = self.workspace_gaps(ws_idx);
446
+        let (gap_inner, gap_outer) = self.effective_gaps(ws_idx);
432447
         self.workspaces
433448
             .get(ws_idx)
434449
             .tree
@@ -572,6 +587,27 @@ impl WmState {
572587
         let _ = crate::platform::skylight::set_window_group_system_alpha(wid, 1.0);
573588
         let _ = crate::platform::skylight::set_window_group_alpha(wid, 1.0);
574589
 
590
+        if let (Ok((ax, ay)), Ok((aw, ah))) = (ax_get_position(ax_ref), ax_get_size(ax_ref)) {
591
+            let dx = (ax - rect.x).abs();
592
+            let dy = (ay - rect.y).abs();
593
+            let dw = (aw - rect.width).abs();
594
+            let dh = (ah - rect.height).abs();
595
+            if dx > 1.0 || dy > 1.0 || dw > 1.0 || dh > 1.0 {
596
+                tracing::debug!(
597
+                    wid,
598
+                    req_x = rect.x,
599
+                    req_y = rect.y,
600
+                    req_w = rect.width,
601
+                    req_h = rect.height,
602
+                    got_x = ax,
603
+                    got_y = ay,
604
+                    got_w = aw,
605
+                    got_h = ah,
606
+                    "show_window mismatch"
607
+                );
608
+            }
609
+        }
610
+
575611
         // Restore AXEnhancedUserInterface
576612
         if was_eui == Some(true)
577613
             && let Some(app) = &app_ref
@@ -1654,7 +1690,7 @@ impl WmState {
16541690
         let window_under = if let Some(special_idx) = special_ws_idx {
16551691
             let sr = self.monitor_rect(mi);
16561692
             let ws = self.workspaces.get(special_idx);
1657
-            let (gap_inner, gap_outer) = self.workspace_gaps(special_idx);
1693
+            let (gap_inner, gap_outer) = self.effective_gaps(special_idx);
16581694
 
16591695
             // Look up config for this special workspace's overlay rect
16601696
             let special_name = match &ws.id {
@@ -2241,7 +2277,7 @@ impl WmState {
22412277
             let overlay_rect = Rect::new(overlay_x, overlay_y, overlay_w, overlay_h);
22422278
 
22432279
             // Compute geometries and collect data before calling self methods
2244
-            let (gap_inner, gap_outer) = self.workspace_gaps(special_idx);
2280
+            let (gap_inner, gap_outer) = self.effective_gaps(special_idx);
22452281
             let geoms =
22462282
                 ws.tree
22472283
                     .calculate_geometries_with_gaps(overlay_rect, gap_inner, gap_outer, true);
@@ -2441,7 +2477,7 @@ impl WmState {
24412477
 
24422478
         // Get target monitor's screen rect for layout
24432479
         let target_rect = self.monitor_rect(target_mi);
2444
-        let (target_gap_inner, target_gap_outer) = self.workspace_gaps(target_ws_idx);
2480
+        let (target_gap_inner, target_gap_outer) = self.effective_gaps(target_ws_idx);
24452481
 
24462482
         // Find which workspace the window is actually on
24472483
         let current_idx = match self.workspaces.find_window(focused) {
tarmac/src/main.rsmodified
@@ -702,7 +702,7 @@ fn process_ipc_command(
702702
                     .monitor_showing_workspace(ws_idx)
703703
                     .map(|mi| state.monitor_rect(mi))
704704
                     .unwrap_or_else(|| state.focused_rect());
705
-                let (gap_inner, gap_outer) = state.workspace_gaps(ws_idx);
705
+                let (gap_inner, gap_outer) = state.effective_gaps(ws_idx);
706706
                 let geoms = ws
707707
                     .tree
708708
                     .calculate_geometries_with_gaps(sr, gap_inner, gap_outer, true);