From a56e4ff436cc4f36d7cda89e985d51e37f0b4f78 Mon Sep 17 00:00:00 2001 From: TheAngusMcFire <43189215+TheAngusMcFire@users.noreply.github.com> Date: Fri, 5 Jul 2024 06:55:04 +0200 Subject: Added Commnads to focus windows or Monitors above/below the active window (#497) * Implement focus-window-up/down-or-monitor calls * Fixed wrong naming of focus-window-or-monitor commands * fix copy pase errors for focusing direction * Fixed wrong behaviour when the current workspace is empty * Cleanup navigation code to reduce complexity * Fix wrong comments and add testcases for FocusWindowOrMonitorUp/Down --------- Co-authored-by: Christian Rieger --- src/input/mod.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/input') diff --git a/src/input/mod.rs b/src/input/mod.rs index 5e775b03..2a1073f9 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -596,6 +596,40 @@ impl State { // FIXME: granular self.niri.queue_redraw_all(); } + Action::FocusWindowOrMonitorUp => { + if let Some(output) = self.niri.output_up() { + if self.niri.layout.focus_window_up_or_output(&output) + && !self.maybe_warp_cursor_to_focus_centered() + { + self.move_cursor_to_output(&output); + } else { + self.maybe_warp_cursor_to_focus(); + } + } else { + self.niri.layout.focus_up(); + self.maybe_warp_cursor_to_focus(); + } + + // FIXME: granular + self.niri.queue_redraw_all(); + } + Action::FocusWindowOrMonitorDown => { + if let Some(output) = self.niri.output_down() { + if self.niri.layout.focus_window_down_or_output(&output) + && !self.maybe_warp_cursor_to_focus_centered() + { + self.move_cursor_to_output(&output); + } else { + self.maybe_warp_cursor_to_focus(); + } + } else { + self.niri.layout.focus_down(); + self.maybe_warp_cursor_to_focus(); + } + + // FIXME: granular + self.niri.queue_redraw_all(); + } Action::FocusColumnOrMonitorLeft => { if let Some(output) = self.niri.output_left() { if self.niri.layout.focus_column_left_or_output(&output) -- cgit