gardesk/gar / 79faba0

Browse files

fix: track specific windows for tiled edge cursor clearing

- find_tiled_edge now returns both windows sharing the edge
- tiled_edge_cursor tracks (w1, w2, direction) instead of just direction
- Only set/clear cursor on the two edge-adjacent windows, not all windows
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
79faba005a69767d20d9591c384b23945eebc7bd
Parents
eae66ae
Tree
831f05a

2 changed files

StatusFile+-
M gar/src/core/mod.rs 3 2
M gar/src/x11/events.rs 17 21
gar/src/core/mod.rsmodified
@@ -45,8 +45,9 @@ pub struct WindowManager {
4545
     pub dock_struts: HashMap<XWindow, Strut>,
4646
     /// Current edge being displayed (for cursor changes on floating window edges)
4747
     pub current_edge_cursor: Option<(XWindow, crate::x11::events::ResizeEdge)>,
48
-    /// Current tiled edge cursor direction (for cursor changes on tiled window gaps)
49
-    pub tiled_edge_cursor: Option<Direction>,
48
+    /// Current tiled edge cursor state: (window1, window2, direction)
49
+    /// Tracks which windows have cursor overrides so we can clear them
50
+    pub tiled_edge_cursor: Option<(XWindow, XWindow, Direction)>,
5051
     /// garbar child process (managed automatically when gar.bar is configured)
5152
     pub garbar_process: Option<std::process::Child>,
5253
     /// Directional focus memory: (source_window, direction) -> last_target_window
gar/src/x11/events.rsmodified
@@ -726,7 +726,7 @@ impl WindowManager {
726726
             let edge_result = self.find_tiled_edge(event.root_x, event.root_y, &geometries);
727727
             tracing::debug!("find_tiled_edge result: {:?}", edge_result);
728728
 
729
-            if let Some((window, direction, container_size)) = edge_result {
729
+            if let Some((window, _window2, direction, container_size)) = edge_result {
730730
                 // Get current ratio from tree
731731
                 let start_ratio = self
732732
                     .current_workspace()
@@ -1111,37 +1111,33 @@ impl WindowManager {
11111111
 
11121112
         let edge = self.find_tiled_edge(root_x, root_y, &geometries);
11131113
 
1114
-        let new_state = edge.map(|(w, dir, _)| (w, dir));
1114
+        let new_state = edge.map(|(w1, w2, dir, _)| (w1, w2, dir));
11151115
 
11161116
         // Check if cursor state changed
1117
-        if new_state.map(|(_, d)| d) == self.tiled_edge_cursor {
1117
+        if new_state == self.tiled_edge_cursor {
11181118
             return Ok(()); // No change
11191119
         }
11201120
 
1121
-        // Clear old cursor state
1122
-        if self.tiled_edge_cursor.is_some() {
1123
-            // Clear cursor on all tiled windows and root
1124
-            for (win, _) in &geometries {
1125
-                self.conn.clear_window_cursor(*win)?;
1126
-            }
1121
+        // Clear old cursor state on the specific windows that had it
1122
+        if let Some((old_w1, old_w2, _)) = self.tiled_edge_cursor {
1123
+            self.conn.clear_window_cursor(old_w1)?;
1124
+            self.conn.clear_window_cursor(old_w2)?;
11271125
             self.conn.clear_window_cursor(self.conn.root)?;
11281126
         }
11291127
 
1130
-        if let Some((_, dir)) = new_state {
1131
-            // Set resize cursor on all tiled windows AND root
1132
-            // This ensures cursor shows even when mouse is over a window
1128
+        if let Some((w1, w2, dir)) = new_state {
1129
+            // Set resize cursor on the two windows sharing the edge AND root
11331130
             let cursor = match dir {
11341131
                 Direction::Left | Direction::Right => self.conn.cursor_h_double,
11351132
                 Direction::Up | Direction::Down => self.conn.cursor_v_double,
11361133
             };
1137
-            for (win, _) in &geometries {
1138
-                self.conn.set_window_cursor(*win, cursor)?;
1139
-            }
1134
+            self.conn.set_window_cursor(w1, cursor)?;
1135
+            self.conn.set_window_cursor(w2, cursor)?;
11401136
             self.conn.set_window_cursor(self.conn.root, cursor)?;
1141
-            self.conn.flush()?;
11421137
         }
1138
+        self.conn.flush()?;
11431139
 
1144
-        self.tiled_edge_cursor = new_state.map(|(_, d)| d);
1140
+        self.tiled_edge_cursor = new_state;
11451141
         Ok(())
11461142
     }
11471143
 
@@ -2361,14 +2357,14 @@ impl WindowManager {
23612357
     }
23622358
 
23632359
     /// Find if cursor is in the gap between two adjacent tiled windows.
2364
-    /// Returns (window, direction, container_size) if on a valid shared edge.
2360
+    /// Returns (window1, window2, direction, container_size) if on a valid shared edge.
23652361
     /// Only matches gaps between windows, NOT outer edges.
23662362
     fn find_tiled_edge(
23672363
         &self,
23682364
         x: i16,
23692365
         y: i16,
23702366
         geometries: &[(u32, Rect)],
2371
-    ) -> Option<(u32, Direction, u16)> {
2367
+    ) -> Option<(u32, u32, Direction, u16)> {
23722368
         const TILED_EDGE_THRESHOLD: i16 = 16;
23732369
         let gap_tolerance = self.config.gap_inner as i16 + 4;
23742370
 
@@ -2391,7 +2387,7 @@ impl WindowManager {
23912387
                         let gap_center = (r1_right + r2.x) / 2;
23922388
                         if (x - gap_center).abs() <= TILED_EDGE_THRESHOLD {
23932389
                             let container_width = (r1.width + r2.width) as u16;
2394
-                            return Some((*w1, Direction::Right, container_width));
2390
+                            return Some((*w1, *w2, Direction::Right, container_width));
23952391
                         }
23962392
                     }
23972393
                 }
@@ -2409,7 +2405,7 @@ impl WindowManager {
24092405
                         let gap_center = (r1_bottom + r2.y) / 2;
24102406
                         if (y - gap_center).abs() <= TILED_EDGE_THRESHOLD {
24112407
                             let container_height = (r1.height + r2.height) as u16;
2412
-                            return Some((*w1, Direction::Down, container_height));
2408
+                            return Some((*w1, *w2, Direction::Down, container_height));
24132409
                         }
24142410
                     }
24152411
                 }