@@ -1943,43 +1943,50 @@ impl WindowManager { |
| 1943 | 1943 | // Check if memory was used (preferred matched target) or default algorithm was used |
| 1944 | 1944 | let used_memory = preferred == Some(target); |
| 1945 | 1945 | |
| 1946 | + tracing::info!("NAV: {:?} from {} to {}, preferred={:?}, used_memory={}", |
| 1947 | + direction, focused, target, preferred, used_memory); |
| 1948 | + |
| 1946 | 1949 | // Store the directional focus memory for next time |
| 1947 | 1950 | self.directional_focus_memory.insert((focused, direction), target); |
| 1951 | + tracing::info!("NAV: stored ({}, {:?}) -> {}", focused, direction, target); |
| 1952 | + |
| 1953 | + // Always store reverse direction if windows are aligned (same row/column) |
| 1954 | + // This ensures "go back" always returns to the window we came from |
| 1955 | + if let (Some((_, from_rect)), Some((_, to_rect))) = ( |
| 1956 | + geometries.iter().find(|(w, _)| *w == focused), |
| 1957 | + geometries.iter().find(|(w, _)| *w == target), |
| 1958 | + ) { |
| 1959 | + let overlaps = match direction { |
| 1960 | + // For Left/Right: store reverse if windows share vertical space (same row) |
| 1961 | + Direction::Left | Direction::Right => { |
| 1962 | + let overlap_start = from_rect.y.max(to_rect.y); |
| 1963 | + let overlap_end = (from_rect.y + from_rect.height as i16) |
| 1964 | + .min(to_rect.y + to_rect.height as i16); |
| 1965 | + tracing::info!("NAV: L/R overlap check: from_y={},{} to_y={},{} overlap=[{},{}]", |
| 1966 | + from_rect.y, from_rect.height, to_rect.y, to_rect.height, overlap_start, overlap_end); |
| 1967 | + overlap_start < overlap_end |
| 1968 | + } |
| 1969 | + // For Up/Down: store reverse if windows share horizontal space (same column) |
| 1970 | + Direction::Up | Direction::Down => { |
| 1971 | + let overlap_start = from_rect.x.max(to_rect.x); |
| 1972 | + let overlap_end = (from_rect.x + from_rect.width as i16) |
| 1973 | + .min(to_rect.x + to_rect.width as i16); |
| 1974 | + tracing::info!("NAV: U/D overlap check: from_x={},{} to_x={},{} overlap=[{},{}]", |
| 1975 | + from_rect.x, from_rect.width, to_rect.x, to_rect.width, overlap_start, overlap_end); |
| 1976 | + overlap_start < overlap_end |
| 1977 | + } |
| 1978 | + }; |
| 1948 | 1979 | |
| 1949 | | - // Store reverse direction only if: |
| 1950 | | - // 1. Default algorithm was used (not memory-assisted jump that skipped windows) |
| 1951 | | - // 2. Windows are aligned (same row/column) |
| 1952 | | - if !used_memory { |
| 1953 | | - if let (Some((_, from_rect)), Some((_, to_rect))) = ( |
| 1954 | | - geometries.iter().find(|(w, _)| *w == focused), |
| 1955 | | - geometries.iter().find(|(w, _)| *w == target), |
| 1956 | | - ) { |
| 1957 | | - let dominated = match direction { |
| 1958 | | - // For Left/Right: store reverse if windows share vertical space (same row) |
| 1959 | | - Direction::Left | Direction::Right => { |
| 1960 | | - let overlap_start = from_rect.y.max(to_rect.y); |
| 1961 | | - let overlap_end = (from_rect.y + from_rect.height as i16) |
| 1962 | | - .min(to_rect.y + to_rect.height as i16); |
| 1963 | | - overlap_start < overlap_end |
| 1964 | | - } |
| 1965 | | - // For Up/Down: store reverse if windows share horizontal space (same column) |
| 1966 | | - Direction::Up | Direction::Down => { |
| 1967 | | - let overlap_start = from_rect.x.max(to_rect.x); |
| 1968 | | - let overlap_end = (from_rect.x + from_rect.width as i16) |
| 1969 | | - .min(to_rect.x + to_rect.width as i16); |
| 1970 | | - overlap_start < overlap_end |
| 1971 | | - } |
| 1980 | + tracing::info!("NAV: overlaps={}", overlaps); |
| 1981 | + if overlaps { |
| 1982 | + let opposite = match direction { |
| 1983 | + Direction::Left => Direction::Right, |
| 1984 | + Direction::Right => Direction::Left, |
| 1985 | + Direction::Up => Direction::Down, |
| 1986 | + Direction::Down => Direction::Up, |
| 1972 | 1987 | }; |
| 1973 | | - |
| 1974 | | - if dominated { |
| 1975 | | - let opposite = match direction { |
| 1976 | | - Direction::Left => Direction::Right, |
| 1977 | | - Direction::Right => Direction::Left, |
| 1978 | | - Direction::Up => Direction::Down, |
| 1979 | | - Direction::Down => Direction::Up, |
| 1980 | | - }; |
| 1981 | | - self.directional_focus_memory.insert((target, opposite), focused); |
| 1982 | | - } |
| 1988 | + self.directional_focus_memory.insert((target, opposite), focused); |
| 1989 | + tracing::info!("NAV: stored reverse ({}, {:?}) -> {}", target, opposite, focused); |
| 1983 | 1990 | } |
| 1984 | 1991 | } |
| 1985 | 1992 | |
@@ -2542,6 +2549,11 @@ impl WindowManager { |
| 2542 | 2549 | let _ = self.conn.sync(); |
| 2543 | 2550 | tracing::info!("Windows unmapped and synced"); |
| 2544 | 2551 | |
| 2552 | + // Kill all processes spawned via gar.exec()/gar.exec_once() |
| 2553 | + if let Ok(state) = self.lua_state.lock() { |
| 2554 | + state.kill_spawned_children(); |
| 2555 | + } |
| 2556 | + |
| 2545 | 2557 | // Stop garbar if it was spawned |
| 2546 | 2558 | if let Some(ref mut child) = self.garbar_process { |
| 2547 | 2559 | stop_garbar(child); |