@@ -1700,18 +1700,30 @@ impl WindowManager { |
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | 1702 | fn focus_direction(&mut self, direction: Direction) -> Result<()> { |
| 1703 | + tracing::debug!( |
| 1704 | + "focus_direction({:?}): focused_monitor={}, monitors={:?}", |
| 1705 | + direction, |
| 1706 | + self.focused_monitor, |
| 1707 | + self.monitors.iter().map(|m| (&m.name, m.geometry.x)).collect::<Vec<_>>() |
| 1708 | + ); |
| 1709 | + |
| 1703 | 1710 | let Some(focused) = self.focused_window else { |
| 1704 | 1711 | // No focused window - try to focus adjacent monitor |
| 1712 | + tracing::debug!("No focused window, trying adjacent monitor"); |
| 1705 | 1713 | return self.focus_adjacent_monitor(direction); |
| 1706 | 1714 | }; |
| 1707 | 1715 | |
| 1708 | 1716 | let screen = self.screen_rect(); |
| 1709 | 1717 | let geometries = self.current_workspace().tree.calculate_geometries(screen); |
| 1718 | + tracing::debug!("Window geometries on workspace: {:?}", geometries); |
| 1710 | 1719 | |
| 1711 | 1720 | // Look up remembered window for this direction (window memory) |
| 1712 | 1721 | let preferred = self.directional_focus_memory.get(&(focused, direction)).copied(); |
| 1713 | 1722 | |
| 1714 | | - if let Some(target) = Node::find_adjacent(&geometries, focused, direction, preferred) { |
| 1723 | + let adjacent = Node::find_adjacent(&geometries, focused, direction, preferred); |
| 1724 | + tracing::debug!("find_adjacent result: {:?}", adjacent); |
| 1725 | + |
| 1726 | + if let Some(target) = adjacent { |
| 1715 | 1727 | // Check if memory was used (preferred matched target) or default algorithm was used |
| 1716 | 1728 | let used_memory = preferred == Some(target); |
| 1717 | 1729 | |
@@ -1763,6 +1775,7 @@ impl WindowManager { |
| 1763 | 1775 | tracing::debug!("Focused {:?} to window {} (preferred: {:?})", direction, target, preferred); |
| 1764 | 1776 | } else { |
| 1765 | 1777 | // No adjacent window on this workspace - try adjacent monitor |
| 1778 | + tracing::debug!("No adjacent window found, trying adjacent monitor"); |
| 1766 | 1779 | self.focus_adjacent_monitor(direction)?; |
| 1767 | 1780 | } |
| 1768 | 1781 | |
@@ -1771,7 +1784,13 @@ impl WindowManager { |
| 1771 | 1784 | |
| 1772 | 1785 | /// Focus the adjacent monitor in the given direction (does NOT wrap at edges) |
| 1773 | 1786 | fn focus_adjacent_monitor(&mut self, direction: Direction) -> Result<()> { |
| 1787 | + tracing::debug!( |
| 1788 | + "focus_adjacent_monitor({:?}): focused_monitor={}, num_monitors={}", |
| 1789 | + direction, self.focused_monitor, self.monitors.len() |
| 1790 | + ); |
| 1791 | + |
| 1774 | 1792 | if self.monitors.len() <= 1 { |
| 1793 | + tracing::debug!("Only one monitor, nothing to do"); |
| 1775 | 1794 | return Ok(()); |
| 1776 | 1795 | } |
| 1777 | 1796 | |
@@ -1780,6 +1799,7 @@ impl WindowManager { |
| 1780 | 1799 | Direction::Left => { |
| 1781 | 1800 | if self.focused_monitor == 0 { |
| 1782 | 1801 | // At leftmost monitor - do nothing |
| 1802 | + tracing::debug!("Already at leftmost monitor (index 0), not navigating left"); |
| 1783 | 1803 | return Ok(()); |
| 1784 | 1804 | } |
| 1785 | 1805 | self.focused_monitor - 1 |
@@ -1787,12 +1807,16 @@ impl WindowManager { |
| 1787 | 1807 | Direction::Right => { |
| 1788 | 1808 | if self.focused_monitor >= self.monitors.len() - 1 { |
| 1789 | 1809 | // At rightmost monitor - do nothing |
| 1810 | + tracing::debug!("Already at rightmost monitor, not navigating right"); |
| 1790 | 1811 | return Ok(()); |
| 1791 | 1812 | } |
| 1792 | 1813 | self.focused_monitor + 1 |
| 1793 | 1814 | } |
| 1794 | 1815 | // Up/Down could navigate if monitors are stacked vertically |
| 1795 | | - Direction::Up | Direction::Down => return Ok(()), |
| 1816 | + Direction::Up | Direction::Down => { |
| 1817 | + tracing::debug!("Up/Down navigation not supported for horizontal monitor layout"); |
| 1818 | + return Ok(()); |
| 1819 | + } |
| 1796 | 1820 | }; |
| 1797 | 1821 | |
| 1798 | 1822 | tracing::info!("Moving focus from monitor {} to {}", self.focused_monitor, target_idx); |