gardesk/gar / 3ab345f

Browse files

detect cross-monitor mouse movement on empty desktops via root MotionNotify

Authored by espadonne
SHA
3ab345f1d045827dc745b7934f617cb444cc124f
Parents
ae7eded
Tree
38d8769

2 changed files

StatusFile+-
M gar/src/x11/connection.rs 2 1
M gar/src/x11/events.rs 24 7
gar/src/x11/connection.rsmodified
@@ -245,7 +245,8 @@ impl Connection {
245
                     | EventMask::SUBSTRUCTURE_NOTIFY
245
                     | EventMask::SUBSTRUCTURE_NOTIFY
246
                     | EventMask::STRUCTURE_NOTIFY
246
                     | EventMask::STRUCTURE_NOTIFY
247
                     | EventMask::PROPERTY_CHANGE
247
                     | EventMask::PROPERTY_CHANGE
248
-                    | EventMask::ENTER_WINDOW,
248
+                    | EventMask::ENTER_WINDOW
249
+                    | EventMask::POINTER_MOTION,
249
             )
250
             )
250
             .background_pixel(self.screen().black_pixel)
251
             .background_pixel(self.screen().black_pixel)
251
             .cursor(self.cursor_normal);
252
             .cursor(self.cursor_normal);
gar/src/x11/events.rsmodified
@@ -1212,13 +1212,30 @@ impl WindowManager {
1212
                     // Check for tiled edge hover (for cursor feedback)
1212
                     // Check for tiled edge hover (for cursor feedback)
1213
                     self.update_tiled_edge_cursor(window, event.root_x, event.root_y)?;
1213
                     self.update_tiled_edge_cursor(window, event.root_x, event.root_y)?;
1214
                 }
1214
                 }
1215
-            } else if self.tiled_edge_cursor.is_some() {
1215
+            } else {
1216
-                // Moving to unmanaged window or root - clear tiled edge cursor
1216
+                if self.tiled_edge_cursor.is_some() {
1217
-                let (old_w1, old_w2, _) = self.tiled_edge_cursor.unwrap();
1217
+                    // Moving to unmanaged window or root - clear tiled edge cursor
1218
-                self.conn.clear_window_cursor(old_w1)?;
1218
+                    let (old_w1, old_w2, _) = self.tiled_edge_cursor.unwrap();
1219
-                self.conn.clear_window_cursor(old_w2)?;
1219
+                    self.conn.clear_window_cursor(old_w1)?;
1220
-                self.conn.flush()?;
1220
+                    self.conn.clear_window_cursor(old_w2)?;
1221
-                self.tiled_edge_cursor = None;
1221
+                    self.conn.flush()?;
1222
+                    self.tiled_edge_cursor = None;
1223
+                }
1224
+                // Pointer is on root/empty desktop — check for cross-monitor movement
1225
+                let monitor_idx = self.monitor_idx_at_point(event.root_x, event.root_y);
1226
+                if monitor_idx != self.focused_monitor {
1227
+                    let old_workspace_idx = self.focused_workspace;
1228
+                    self.focused_monitor = monitor_idx;
1229
+                    let workspace_idx = self.monitors[monitor_idx].active_workspace;
1230
+                    self.focused_workspace = workspace_idx;
1231
+                    self.focused_window = None;
1232
+                    self.conn.set_active_window(None)?;
1233
+                    self.conn.set_current_desktop(workspace_idx as u32)?;
1234
+                    if workspace_idx != old_workspace_idx {
1235
+                        self.broadcast_i3_workspace_event("focus", workspace_idx, Some(old_workspace_idx));
1236
+                    }
1237
+                    self.conn.flush()?;
1238
+                }
1222
             }
1239
             }
1223
             return Ok(());
1240
             return Ok(());
1224
         }
1241
         }