@@ -317,14 +317,18 @@ impl WmState { |
| 317 | 317 | for (mi, monitor) in self.monitors.iter().enumerate() { |
| 318 | 318 | let ws = self.workspaces.get(monitor.active_workspace); |
| 319 | 319 | let sr = self.monitor_rect(mi); |
| 320 | | - let geoms = ws.tree.calculate_geometries_with_gaps(sr, self.gap_inner, self.gap_outer, true); |
| 320 | + let geoms = |
| 321 | + ws.tree |
| 322 | + .calculate_geometries_with_gaps(sr, self.gap_inner, self.gap_outer, true); |
| 321 | 323 | let focused = ws.focused; |
| 322 | 324 | |
| 323 | 325 | for (wid, rect) in &geoms { |
| 324 | | - self.borders.update_border(*wid, *rect, focused == Some(*wid)); |
| 326 | + self.borders |
| 327 | + .update_border(*wid, *rect, focused == Some(*wid)); |
| 325 | 328 | } |
| 326 | 329 | for fw in &ws.floating { |
| 327 | | - self.borders.update_border(fw.id, fw.geometry, focused == Some(fw.id)); |
| 330 | + self.borders |
| 331 | + .update_border(fw.id, fw.geometry, focused == Some(fw.id)); |
| 328 | 332 | } |
| 329 | 333 | } |
| 330 | 334 | } |
@@ -711,33 +715,26 @@ impl WmState { |
| 711 | 715 | let at_edge = if let Some((_, rect)) = geoms.iter().find(|(w, _)| *w == from) { |
| 712 | 716 | let tolerance = self.gap_outer + 2.0; |
| 713 | 717 | match direction { |
| 714 | | - Direction::Right => { |
| 715 | | - (rect.x + rect.width) >= (sr.x + sr.width - tolerance) |
| 716 | | - } |
| 718 | + Direction::Right => (rect.x + rect.width) >= (sr.x + sr.width - tolerance), |
| 717 | 719 | Direction::Left => rect.x <= (sr.x + tolerance), |
| 718 | | - Direction::Down => { |
| 719 | | - (rect.y + rect.height) >= (sr.y + sr.height - tolerance) |
| 720 | | - } |
| 720 | + Direction::Down => (rect.y + rect.height) >= (sr.y + sr.height - tolerance), |
| 721 | 721 | Direction::Up => rect.y <= (sr.y + tolerance), |
| 722 | 722 | } |
| 723 | 723 | } else { |
| 724 | 724 | false |
| 725 | 725 | }; |
| 726 | 726 | |
| 727 | | - if !at_edge { |
| 728 | | - if let Some(target) = Node::find_adjacent(&geoms, from, direction) { |
| 729 | | - self.focus_window(target); |
| 730 | | - if self.mouse_follows_focus |
| 731 | | - && let Some((_, rect)) = geoms.iter().find(|(id, _)| *id == target) |
| 732 | | - { |
| 733 | | - warp_mouse_to_center(rect); |
| 734 | | - self.ffm_cooldown_until = Some( |
| 735 | | - std::time::Instant::now() + std::time::Duration::from_millis(200), |
| 736 | | - ); |
| 737 | | - self.ffm_last_window = Some(target); |
| 738 | | - } |
| 739 | | - return; |
| 727 | + if !at_edge && let Some(target) = Node::find_adjacent(&geoms, from, direction) { |
| 728 | + self.focus_window(target); |
| 729 | + if self.mouse_follows_focus |
| 730 | + && let Some((_, rect)) = geoms.iter().find(|(id, _)| *id == target) |
| 731 | + { |
| 732 | + warp_mouse_to_center(rect); |
| 733 | + self.ffm_cooldown_until = |
| 734 | + Some(std::time::Instant::now() + std::time::Duration::from_millis(200)); |
| 735 | + self.ffm_last_window = Some(target); |
| 740 | 736 | } |
| 737 | + return; |
| 741 | 738 | } |
| 742 | 739 | } |
| 743 | 740 | |
@@ -801,12 +798,9 @@ impl WmState { |
| 801 | 798 | None => return, |
| 802 | 799 | }; |
| 803 | 800 | let sr = self.focused_rect(); |
| 804 | | - let geoms = ws.tree.calculate_geometries_with_gaps( |
| 805 | | - sr, |
| 806 | | - self.gap_inner, |
| 807 | | - self.gap_outer, |
| 808 | | - true, |
| 809 | | - ); |
| 801 | + let geoms = |
| 802 | + ws.tree |
| 803 | + .calculate_geometries_with_gaps(sr, self.gap_inner, self.gap_outer, true); |
| 810 | 804 | |
| 811 | 805 | // Check if the focused window touches the monitor edge in the |
| 812 | 806 | // requested direction. If so, skip intra-workspace swap and move |
@@ -824,15 +818,13 @@ impl WmState { |
| 824 | 818 | false |
| 825 | 819 | }; |
| 826 | 820 | |
| 827 | | - if !at_edge { |
| 828 | | - if let Some(target) = Node::find_adjacent(&geoms, focused, direction) { |
| 829 | | - tracing::debug!(focused, target, ?direction, "swap_direction"); |
| 830 | | - if self.active_workspace_mut().tree.swap(focused, target) { |
| 831 | | - self.apply_layout(); |
| 832 | | - self.fix_oversized_windows(); |
| 833 | | - } |
| 834 | | - return; |
| 821 | + if !at_edge && let Some(target) = Node::find_adjacent(&geoms, focused, direction) { |
| 822 | + tracing::debug!(focused, target, ?direction, "swap_direction"); |
| 823 | + if self.active_workspace_mut().tree.swap(focused, target) { |
| 824 | + self.apply_layout(); |
| 825 | + self.fix_oversized_windows(); |
| 835 | 826 | } |
| 827 | + return; |
| 836 | 828 | } |
| 837 | 829 | |
| 838 | 830 | // At monitor edge or no adjacent window — move to adjacent monitor |
@@ -849,7 +841,12 @@ impl WmState { |
| 849 | 841 | _ => None, |
| 850 | 842 | }; |
| 851 | 843 | if let Some(target_mi) = new_mi { |
| 852 | | - tracing::debug!(focused, monitor = target_mi, ?direction, "swap: moving to adjacent monitor"); |
| 844 | + tracing::debug!( |
| 845 | + focused, |
| 846 | + monitor = target_mi, |
| 847 | + ?direction, |
| 848 | + "swap: moving to adjacent monitor" |
| 849 | + ); |
| 853 | 850 | self.move_window_to_monitor(target_mi); |
| 854 | 851 | } |
| 855 | 852 | } |