diff options
| author | Ridan Vandenbergh <RidanVandenbergh@gmail.com> | 2024-11-21 12:48:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-21 14:48:51 +0300 |
| commit | a74a57819896660ed2c587e60ad11e170eda3e4b (patch) | |
| tree | 81850788eb54cb9037d2a312e858a01c734d9695 /src/input | |
| parent | 7de752ec565c5b3e4e25fcba1f051cfd639338a2 (diff) | |
| download | niri-a74a57819896660ed2c587e60ad11e170eda3e4b.tar.gz niri-a74a57819896660ed2c587e60ad11e170eda3e4b.tar.bz2 niri-a74a57819896660ed2c587e60ad11e170eda3e4b.zip | |
Add `focus-window-previous` action (#811)
* Add `FocusWindowPrevious` action
* remove [`
* track previous focus in Niri instead of every window
---------
Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'src/input')
| -rw-r--r-- | src/input/mod.rs | 22 |
1 files changed, 6 insertions, 16 deletions
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) => { |
