From a74a57819896660ed2c587e60ad11e170eda3e4b Mon Sep 17 00:00:00 2001 From: Ridan Vandenbergh Date: Thu, 21 Nov 2024 12:48:51 +0100 Subject: Add `focus-window-previous` action (#811) * Add `FocusWindowPrevious` action * remove [` * track previous focus in Niri instead of every window --------- Co-authored-by: Ivan Molodetskikh --- src/input/mod.rs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/input') diff --git a/src/input/mod.rs b/src/input/mod.rs index 6a242890..864bfe7f 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -636,22 +636,12 @@ impl State { let window = self.niri.layout.windows().find(|(_, m)| m.id().get() == id); let window = window.map(|(_, m)| m.window.clone()); if let Some(window) = window { - let active_output = self.niri.layout.active_output().cloned(); - - self.niri.layout.activate_window(&window); - - let new_active = self.niri.layout.active_output().cloned(); - #[allow(clippy::collapsible_if)] - if new_active != active_output { - if !self.maybe_warp_cursor_to_focus_centered() { - self.move_cursor_to_output(&new_active.unwrap()); - } - } else { - self.maybe_warp_cursor_to_focus(); - } - - // FIXME: granular - self.niri.queue_redraw_all(); + self.focus_window(&window); + } + } + Action::FocusWindowPrevious => { + if let Some(window) = self.niri.previously_focused_window.clone() { + self.focus_window(&window); } } Action::SwitchLayout(action) => { -- cgit