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 {
45
     pub dock_struts: HashMap<XWindow, Strut>,
45
     pub dock_struts: HashMap<XWindow, Strut>,
46
     /// Current edge being displayed (for cursor changes on floating window edges)
46
     /// Current edge being displayed (for cursor changes on floating window edges)
47
     pub current_edge_cursor: Option<(XWindow, crate::x11::events::ResizeEdge)>,
47
     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
     /// garbar child process (managed automatically when gar.bar is configured)
50
     /// garbar child process (managed automatically when gar.bar is configured)
49
     pub garbar_process: Option<std::process::Child>,
51
     pub garbar_process: Option<std::process::Child>,
50
     /// Directional focus memory: (source_window, direction) -> last_target_window
52
     /// Directional focus memory: (source_window, direction) -> last_target_window
@@ -145,6 +147,7 @@ impl WindowManager {
145
             focus_history: Vec::new(),
147
             focus_history: Vec::new(),
146
             dock_struts: HashMap::new(),
148
             dock_struts: HashMap::new(),
147
             current_edge_cursor: None,
149
             current_edge_cursor: None,
150
+            tiled_edge_cursor: None,
148
             garbar_process: None,
151
             garbar_process: None,
149
             directional_focus_memory: HashMap::new(),
152
             directional_focus_memory: HashMap::new(),
150
         })
153
         })
gar/src/x11/events.rsmodified
@@ -896,6 +896,9 @@ impl WindowManager {
896
             let window = event.event;
896
             let window = event.event;
897
             if self.windows.contains_key(&window) && self.is_floating(window) {
897
             if self.windows.contains_key(&window) && self.is_floating(window) {
898
                 self.update_edge_cursor(window, event.root_x, event.root_y)?;
898
                 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)?;
899
             }
902
             }
900
             return Ok(());
903
             return Ok(());
901
         }
904
         }
@@ -1103,6 +1106,38 @@ impl WindowManager {
1103
         Ok(())
1106
         Ok(())
1104
     }
1107
     }
1105
 
1108
 
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
+
1106
     fn handle_enter_notify(&mut self, event: EnterNotifyEvent) -> Result<()> {
1141
     fn handle_enter_notify(&mut self, event: EnterNotifyEvent) -> Result<()> {
1107
         let window = event.event;
1142
         let window = event.event;
1108
 
1143
 
@@ -2327,7 +2362,7 @@ impl WindowManager {
2327
         y: i16,
2362
         y: i16,
2328
         geometries: &[(u32, Rect)],
2363
         geometries: &[(u32, Rect)],
2329
     ) -> Option<(u32, Direction, u16)> {
2364
     ) -> Option<(u32, Direction, u16)> {
2330
-        const TILED_EDGE_THRESHOLD: i16 = 8;
2365
+        const TILED_EDGE_THRESHOLD: i16 = 16;
2331
         let gap_tolerance = self.config.gap_inner as i16 + 4;
2366
         let gap_tolerance = self.config.gap_inner as i16 + 4;
2332
 
2367
 
2333
         for (w1, r1) in geometries {
2368
         for (w1, r1) in geometries {