tenseleyflow/hyprkvm / 1ea754f

Browse files

fix: use per-monitor bounds for Up/Down cursor edge detection

In multi-monitor setups with different height monitors, cursor edge
detection for Up/Down now checks if cursor is at the edge of the
specific monitor it's on, rather than using global screen bounds.

This fixes mouse-based edge detection on monitors that aren't the
tallest (e.g., cursor at y=1440 on a 1440p monitor now correctly
triggers Down edge, even if another monitor extends to y=1728).
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
1ea754f6f446ac7ee2c06b79b4aba09533b62af9
Parents
05bd991
Tree
b2e65b5

1 changed file

StatusFile+-
M hyprkvm-daemon/src/main.rs 29 5
hyprkvm-daemon/src/main.rsmodified
@@ -275,6 +275,15 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
275275
         height: m.height,
276276
         scale: m.scale,
277277
     }).collect();
278
+
279
+    // Store per-monitor logical bounds for cursor edge detection
280
+    // Each tuple: (x, y, logical_width, logical_height)
281
+    let monitor_logical_bounds: Vec<(i32, i32, i32, i32)> = monitors.iter().map(|m| {
282
+        let logical_width = (m.width as f32 / m.scale).round() as i32;
283
+        let logical_height = (m.height as f32 / m.scale).round() as i32;
284
+        (m.x, m.y, logical_width, logical_height)
285
+    }).collect();
286
+
278287
     let edge_capture = input::EdgeCapture::new(input::EdgeCaptureConfig {
279288
         barrier_size: 1,
280289
         enabled_edges: enabled_edges.clone(),
@@ -1081,16 +1090,31 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
10811090
                         let (cx, cy) = (cursor.x, cursor.y);
10821091
 
10831092
                         // Determine if cursor is at a screen edge
1093
+                        // For Left/Right: use global screen bounds
1094
+                        // For Up/Down: check per-monitor bounds (different monitors have different heights)
10841095
                         let at_edge: Option<Direction> = if cx <= EDGE_THRESHOLD {
10851096
                             Some(Direction::Left)
10861097
                         } else if cx >= screen_width as i32 - EDGE_THRESHOLD {
10871098
                             Some(Direction::Right)
1088
-                        } else if cy <= EDGE_THRESHOLD {
1089
-                            Some(Direction::Up)
1090
-                        } else if cy >= screen_height as i32 - EDGE_THRESHOLD {
1091
-                            Some(Direction::Down)
10921099
                         } else {
1093
-                            None
1100
+                            // Check per-monitor Up/Down edges
1101
+                            let mut edge_found = None;
1102
+                            for &(mon_x, mon_y, mon_w, mon_h) in &monitor_logical_bounds {
1103
+                                // Check if cursor is within this monitor's x range
1104
+                                if cx >= mon_x && cx < mon_x + mon_w {
1105
+                                    // Check Up edge (top of this monitor)
1106
+                                    if cy <= mon_y + EDGE_THRESHOLD && cy >= mon_y {
1107
+                                        edge_found = Some(Direction::Up);
1108
+                                        break;
1109
+                                    }
1110
+                                    // Check Down edge (bottom of this monitor)
1111
+                                    if cy >= mon_y + mon_h - EDGE_THRESHOLD && cy <= mon_y + mon_h {
1112
+                                        edge_found = Some(Direction::Down);
1113
+                                        break;
1114
+                                    }
1115
+                                }
1116
+                            }
1117
+                            edge_found
10941118
                         };
10951119
 
10961120
                         // Debug: Log when cursor is at Up/Down edge