gardesk/gar / b00c4be

Browse files

tiled resize: larger detection zone, cursor feedback

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
b00c4be764e6d05a1392c5cd0659fe2183455039
Parents
0fded69
Tree
5d0c400

2 changed files

StatusFile+-
M gar/src/core/mod.rs 3 0
M gar/src/x11/events.rs 36 1
gar/src/core/mod.rsmodified
@@ -45,6 +45,8 @@ 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>,
4850
     /// garbar child process (managed automatically when gar.bar is configured)
4951
     pub garbar_process: Option<std::process::Child>,
5052
     /// Directional focus memory: (source_window, direction) -> last_target_window
@@ -145,6 +147,7 @@ impl WindowManager {
145147
             focus_history: Vec::new(),
146148
             dock_struts: HashMap::new(),
147149
             current_edge_cursor: None,
150
+            tiled_edge_cursor: None,
148151
             garbar_process: None,
149152
             directional_focus_memory: HashMap::new(),
150153
         })
gar/src/x11/events.rsmodified
@@ -896,6 +896,9 @@ impl WindowManager {
896896
             let window = event.event;
897897
             if self.windows.contains_key(&window) && self.is_floating(window) {
898898
                 self.update_edge_cursor(window, event.root_x, event.root_y)?;
899
+            } else {
900
+                // Check for tiled edge hover (for cursor feedback)
901
+                self.update_tiled_edge_cursor(event.root_x, event.root_y)?;
899902
             }
900903
             return Ok(());
901904
         }
@@ -1103,6 +1106,38 @@ impl WindowManager {
11031106
         Ok(())
11041107
     }
11051108
 
1109
+    /// Update cursor when hovering over tiled window edges/gaps.
1110
+    fn update_tiled_edge_cursor(&mut self, root_x: i16, root_y: i16) -> Result<()> {
1111
+        let work_area = self.work_area();
1112
+        let geometries = self.current_workspace().tree.calculate_geometries(work_area);
1113
+
1114
+        let edge = self.find_tiled_edge(root_x, root_y, &geometries);
1115
+
1116
+        let new_direction = edge.map(|(_, dir, _)| dir);
1117
+
1118
+        // Check if cursor state changed
1119
+        if new_direction == self.tiled_edge_cursor {
1120
+            return Ok(()); // No change
1121
+        }
1122
+
1123
+        if let Some(dir) = new_direction {
1124
+            // Set resize cursor on root
1125
+            let cursor = match dir {
1126
+                Direction::Left | Direction::Right => self.conn.cursor_left,
1127
+                Direction::Up | Direction::Down => self.conn.cursor_top,
1128
+            };
1129
+            self.conn.set_window_cursor(self.conn.root, cursor)?;
1130
+            self.conn.flush()?;
1131
+        } else if self.tiled_edge_cursor.is_some() {
1132
+            // Clear resize cursor from root
1133
+            self.conn.clear_window_cursor(self.conn.root)?;
1134
+            self.conn.flush()?;
1135
+        }
1136
+
1137
+        self.tiled_edge_cursor = new_direction;
1138
+        Ok(())
1139
+    }
1140
+
11061141
     fn handle_enter_notify(&mut self, event: EnterNotifyEvent) -> Result<()> {
11071142
         let window = event.event;
11081143
 
@@ -2327,7 +2362,7 @@ impl WindowManager {
23272362
         y: i16,
23282363
         geometries: &[(u32, Rect)],
23292364
     ) -> Option<(u32, Direction, u16)> {
2330
-        const TILED_EDGE_THRESHOLD: i16 = 8;
2365
+        const TILED_EDGE_THRESHOLD: i16 = 16;
23312366
         let gap_tolerance = self.config.gap_inner as i16 + 4;
23322367
 
23332368
         for (w1, r1) in geometries {