@@ -275,6 +275,15 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> { |
| 275 | 275 | height: m.height, |
| 276 | 276 | scale: m.scale, |
| 277 | 277 | }).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 | + |
| 278 | 287 | let edge_capture = input::EdgeCapture::new(input::EdgeCaptureConfig { |
| 279 | 288 | barrier_size: 1, |
| 280 | 289 | enabled_edges: enabled_edges.clone(), |
@@ -1081,16 +1090,31 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> { |
| 1081 | 1090 | let (cx, cy) = (cursor.x, cursor.y); |
| 1082 | 1091 | |
| 1083 | 1092 | // 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) |
| 1084 | 1095 | let at_edge: Option<Direction> = if cx <= EDGE_THRESHOLD { |
| 1085 | 1096 | Some(Direction::Left) |
| 1086 | 1097 | } else if cx >= screen_width as i32 - EDGE_THRESHOLD { |
| 1087 | 1098 | 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) |
| 1092 | 1099 | } 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 |
| 1094 | 1118 | }; |
| 1095 | 1119 | |
| 1096 | 1120 | // Debug: Log when cursor is at Up/Down edge |