gardesk/gar / d5bc31a

Browse files

fix: simplify edge zone detection, remove debug logging

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
d5bc31a23e012036b4f00fad8f4a3d3503c77af3
Parents
b19cd1f
Tree
63c3360

1 changed file

StatusFile+-
M gar/src/x11/events.rs 34 27
gar/src/x11/events.rsmodified
@@ -1373,31 +1373,21 @@ impl WindowManager {
13731373
         y: i16,
13741374
         geometries: &[(u32, Rect)],
13751375
     ) -> 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
13771378
         let gap = self.config.gap_inner as i16;
1379
+        let edge_zone = gap + 8; // Gap width plus comfortable margin
13781380
 
13791381
         let left = rect.x;
13801382
         let right = rect.x + rect.width as i16;
13811383
         let top = rect.y;
13821384
         let bottom = rect.y + rect.height as i16;
13831385
 
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;
14011391
 
14021392
         // For each edge we're near, look for an adjacent window
14031393
         if near_left {
@@ -1482,7 +1472,12 @@ impl WindowManager {
14821472
         geometries: &[(u32, Rect)],
14831473
     ) -> Option<(u32, u32, Direction)> {
14841474
         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
+        }
14861481
 
14871482
         // Check all pairs of windows for horizontal adjacency (vertical split line)
14881483
         for (w1, r1) in geometries {
@@ -1491,14 +1486,22 @@ impl WindowManager {
14911486
                 if w1 == w2 {
14921487
                     continue;
14931488
                 }
1494
-                // Check if w2 is to the right of w1 (within gap distance)
1489
+                // Check if w2 is to the right of w1
14951490
                 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 {
14991501
                         // Check vertical overlap at click position
15001502
                         let v_overlap_top = r1.y.max(r2.y);
15011503
                         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));
15021505
                         if y >= v_overlap_top && y < v_overlap_bottom {
15031506
                             debug_log(&format!("GAP EDGE FOUND H: w1={}, w2={}, gap_x=[{},{}], y_range=[{},{}]",
15041507
                                 w1, w2, r1_right, r2.x, v_overlap_top, v_overlap_bottom));
@@ -1516,11 +1519,15 @@ impl WindowManager {
15161519
                 if w1 == w2 {
15171520
                     continue;
15181521
                 }
1519
-                // Check if w2 is below w1 (within gap distance)
1522
+                // Check if w2 is below w1
15201523
                 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 {
15241531
                         // Check horizontal overlap at click position
15251532
                         let h_overlap_left = r1.x.max(r2.x);
15261533
                         let h_overlap_right = (r1.x + r1.width as i16).min(r2.x + r2.width as i16);