@@ -1373,31 +1373,21 @@ impl WindowManager { |
| 1373 | 1373 | y: i16, |
| 1374 | 1374 | geometries: &[(u32, Rect)], |
| 1375 | 1375 | ) -> Option<(u32, u32, Direction)> { |
| 1376 | | - const EDGE_ZONE: i16 = 32; // Detection zone from window edge (increased for easier grabbing) |
| 1376 | + // Edge zone for resize detection - wide enough to cover gap + some margin |
| 1377 | + // This makes it easy to grab edges: click near the boundary between windows |
| 1377 | 1378 | let gap = self.config.gap_inner as i16; |
| 1379 | + let edge_zone = gap + 8; // Gap width plus comfortable margin |
| 1378 | 1380 | |
| 1379 | 1381 | let left = rect.x; |
| 1380 | 1382 | let right = rect.x + rect.width as i16; |
| 1381 | 1383 | let top = rect.y; |
| 1382 | 1384 | let bottom = rect.y + rect.height as i16; |
| 1383 | 1385 | |
| 1384 | | - // Calculate distances from each edge |
| 1385 | | - let dist_from_left = x - left; |
| 1386 | | - let dist_from_right = right - x; |
| 1387 | | - let dist_from_top = y - top; |
| 1388 | | - let dist_from_bottom = bottom - y; |
| 1389 | | - |
| 1390 | | - debug_log(&format!("EDGE DIST: x={}, y={}, left={}, right={}, top={}, bottom={}", x, y, left, right, top, bottom)); |
| 1391 | | - debug_log(&format!("EDGE DIST: from_left={}, from_right={}, from_top={}, from_bottom={}, zone={}", |
| 1392 | | - dist_from_left, dist_from_right, dist_from_top, dist_from_bottom, EDGE_ZONE)); |
| 1393 | | - |
| 1394 | | - // Check each edge |
| 1395 | | - let near_left = x >= left && x < left + EDGE_ZONE; |
| 1396 | | - let near_right = x > right - EDGE_ZONE && x <= right; |
| 1397 | | - let near_top = y >= top && y < top + EDGE_ZONE; |
| 1398 | | - let near_bottom = y > bottom - EDGE_ZONE && y <= bottom; |
| 1399 | | - |
| 1400 | | - debug_log(&format!("NEAR EDGES: left={}, right={}, top={}, bottom={}", near_left, near_right, near_top, near_bottom)); |
| 1386 | + // Check each edge - trigger if within edge_zone of the window boundary |
| 1387 | + let near_left = x >= left && x < left + edge_zone; |
| 1388 | + let near_right = x > right - edge_zone && x <= right; |
| 1389 | + let near_top = y >= top && y < top + edge_zone; |
| 1390 | + let near_bottom = y > bottom - edge_zone && y <= bottom; |
| 1401 | 1391 | |
| 1402 | 1392 | // For each edge we're near, look for an adjacent window |
| 1403 | 1393 | if near_left { |
@@ -1482,7 +1472,12 @@ impl WindowManager { |
| 1482 | 1472 | geometries: &[(u32, Rect)], |
| 1483 | 1473 | ) -> Option<(u32, u32, Direction)> { |
| 1484 | 1474 | let gap = self.config.gap_inner as i16; |
| 1485 | | - let tolerance = gap + 8; // Gap width plus some tolerance |
| 1475 | + |
| 1476 | + // Log all geometries for debugging |
| 1477 | + for (w, r) in geometries { |
| 1478 | + debug_log(&format!("GAP CHECK GEOM: w={}, x={}, y={}, w={}, h={}, right={}, bottom={}", |
| 1479 | + w, r.x, r.y, r.width, r.height, r.x + r.width as i16, r.y + r.height as i16)); |
| 1480 | + } |
| 1486 | 1481 | |
| 1487 | 1482 | // Check all pairs of windows for horizontal adjacency (vertical split line) |
| 1488 | 1483 | for (w1, r1) in geometries { |
@@ -1491,14 +1486,22 @@ impl WindowManager { |
| 1491 | 1486 | if w1 == w2 { |
| 1492 | 1487 | continue; |
| 1493 | 1488 | } |
| 1494 | | - // Check if w2 is to the right of w1 (within gap distance) |
| 1489 | + // Check if w2 is to the right of w1 |
| 1495 | 1490 | let horizontal_gap = r2.x - r1_right; |
| 1496 | | - if horizontal_gap >= 0 && horizontal_gap <= tolerance { |
| 1497 | | - // Check if click is in the gap horizontally |
| 1498 | | - if x >= r1_right && x <= r2.x { |
| 1491 | + debug_log(&format!("GAP H CHECK: w1={} right={}, w2={} left={}, gap={}, click_x={}", |
| 1492 | + w1, r1_right, w2, r2.x, horizontal_gap, x)); |
| 1493 | + |
| 1494 | + // Allow detection if click is anywhere near the gap area |
| 1495 | + // Gap region is from r1_right to r2.x, but expand by a few pixels for tolerance |
| 1496 | + let gap_left = r1_right - 4; |
| 1497 | + let gap_right = r2.x + 4; |
| 1498 | + |
| 1499 | + if horizontal_gap >= 0 && horizontal_gap <= gap + 16 { |
| 1500 | + if x >= gap_left && x <= gap_right { |
| 1499 | 1501 | // Check vertical overlap at click position |
| 1500 | 1502 | let v_overlap_top = r1.y.max(r2.y); |
| 1501 | 1503 | let v_overlap_bottom = (r1.y + r1.height as i16).min(r2.y + r2.height as i16); |
| 1504 | + debug_log(&format!("GAP H Y CHECK: y={}, v_top={}, v_bottom={}", y, v_overlap_top, v_overlap_bottom)); |
| 1502 | 1505 | if y >= v_overlap_top && y < v_overlap_bottom { |
| 1503 | 1506 | debug_log(&format!("GAP EDGE FOUND H: w1={}, w2={}, gap_x=[{},{}], y_range=[{},{}]", |
| 1504 | 1507 | w1, w2, r1_right, r2.x, v_overlap_top, v_overlap_bottom)); |
@@ -1516,11 +1519,15 @@ impl WindowManager { |
| 1516 | 1519 | if w1 == w2 { |
| 1517 | 1520 | continue; |
| 1518 | 1521 | } |
| 1519 | | - // Check if w2 is below w1 (within gap distance) |
| 1522 | + // Check if w2 is below w1 |
| 1520 | 1523 | let vertical_gap = r2.y - r1_bottom; |
| 1521 | | - if vertical_gap >= 0 && vertical_gap <= tolerance { |
| 1522 | | - // Check if click is in the gap vertically |
| 1523 | | - if y >= r1_bottom && y <= r2.y { |
| 1524 | + |
| 1525 | + // Allow detection if click is anywhere near the gap area |
| 1526 | + let gap_top = r1_bottom - 4; |
| 1527 | + let gap_bottom = r2.y + 4; |
| 1528 | + |
| 1529 | + if vertical_gap >= 0 && vertical_gap <= gap + 16 { |
| 1530 | + if y >= gap_top && y <= gap_bottom { |
| 1524 | 1531 | // Check horizontal overlap at click position |
| 1525 | 1532 | let h_overlap_left = r1.x.max(r2.x); |
| 1526 | 1533 | let h_overlap_right = (r1.x + r1.width as i16).min(r2.x + r2.width as i16); |