gardesk/gar / 783dd5d

Browse files

directional focus memory tweak

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
783dd5d725f44bebe0a6dee2b16df20cfcca8d63
Parents
88f32a7
Tree
1a0e284

1 changed file

StatusFile+-
M gar/src/x11/events.rs 36 30
gar/src/x11/events.rsmodified
@@ -1223,40 +1223,46 @@ impl WindowManager {
12231223
         let preferred = self.directional_focus_memory.get(&(focused, direction)).copied();
12241224
 
12251225
         if let Some(target) = Node::find_adjacent(&geometries, focused, direction, preferred) {
1226
+            // Check if memory was used (preferred matched target) or default algorithm was used
1227
+            let used_memory = preferred == Some(target);
1228
+
12261229
             // Store the directional focus memory for next time
12271230
             self.directional_focus_memory.insert((focused, direction), target);
12281231
 
1229
-            // Store reverse direction only if windows are aligned (same row/column)
1230
-            // This enables "back" navigation without breaking natural movement
1231
-            if let (Some((_, from_rect)), Some((_, to_rect))) = (
1232
-                geometries.iter().find(|(w, _)| *w == focused),
1233
-                geometries.iter().find(|(w, _)| *w == target),
1234
-            ) {
1235
-                let dominated = match direction {
1236
-                    // For Left/Right: store reverse if windows share vertical space (same row)
1237
-                    Direction::Left | Direction::Right => {
1238
-                        let overlap_start = from_rect.y.max(to_rect.y);
1239
-                        let overlap_end = (from_rect.y + from_rect.height as i16)
1240
-                            .min(to_rect.y + to_rect.height as i16);
1241
-                        overlap_start < overlap_end
1242
-                    }
1243
-                    // For Up/Down: store reverse if windows share horizontal space (same column)
1244
-                    Direction::Up | Direction::Down => {
1245
-                        let overlap_start = from_rect.x.max(to_rect.x);
1246
-                        let overlap_end = (from_rect.x + from_rect.width as i16)
1247
-                            .min(to_rect.x + to_rect.width as i16);
1248
-                        overlap_start < overlap_end
1249
-                    }
1250
-                };
1251
-
1252
-                if dominated {
1253
-                    let opposite = match direction {
1254
-                        Direction::Left => Direction::Right,
1255
-                        Direction::Right => Direction::Left,
1256
-                        Direction::Up => Direction::Down,
1257
-                        Direction::Down => Direction::Up,
1232
+            // Store reverse direction only if:
1233
+            // 1. Default algorithm was used (not memory-assisted jump that skipped windows)
1234
+            // 2. Windows are aligned (same row/column)
1235
+            if !used_memory {
1236
+                if let (Some((_, from_rect)), Some((_, to_rect))) = (
1237
+                    geometries.iter().find(|(w, _)| *w == focused),
1238
+                    geometries.iter().find(|(w, _)| *w == target),
1239
+                ) {
1240
+                    let dominated = match direction {
1241
+                        // For Left/Right: store reverse if windows share vertical space (same row)
1242
+                        Direction::Left | Direction::Right => {
1243
+                            let overlap_start = from_rect.y.max(to_rect.y);
1244
+                            let overlap_end = (from_rect.y + from_rect.height as i16)
1245
+                                .min(to_rect.y + to_rect.height as i16);
1246
+                            overlap_start < overlap_end
1247
+                        }
1248
+                        // For Up/Down: store reverse if windows share horizontal space (same column)
1249
+                        Direction::Up | Direction::Down => {
1250
+                            let overlap_start = from_rect.x.max(to_rect.x);
1251
+                            let overlap_end = (from_rect.x + from_rect.width as i16)
1252
+                                .min(to_rect.x + to_rect.width as i16);
1253
+                            overlap_start < overlap_end
1254
+                        }
12581255
                     };
1259
-                    self.directional_focus_memory.insert((target, opposite), focused);
1256
+
1257
+                    if dominated {
1258
+                        let opposite = match direction {
1259
+                            Direction::Left => Direction::Right,
1260
+                            Direction::Right => Direction::Left,
1261
+                            Direction::Up => Direction::Down,
1262
+                            Direction::Down => Direction::Up,
1263
+                        };
1264
+                        self.directional_focus_memory.insert((target, opposite), focused);
1265
+                    }
12601266
                 }
12611267
             }
12621268