diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-11-15 10:52:04 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-11-16 22:36:01 +0300 |
| commit | aecbd679e39a321495964995fa1e37d84bd91ddf (patch) | |
| tree | 2a949fe60e381a86778fe18f6598c322aa4e1f59 /src/input | |
| parent | 3769e5da46064b1bd85d7791fc767bcfc36d5a1c (diff) | |
| download | niri-aecbd679e39a321495964995fa1e37d84bd91ddf.tar.gz niri-aecbd679e39a321495964995fa1e37d84bd91ddf.tar.bz2 niri-aecbd679e39a321495964995fa1e37d84bd91ddf.zip | |
Reimplement focus-previous-window with MRU focus timestamps
Makes it consistent with the MRU and improves the behavior:
- considers MRU's debounce
- fixes problematic cases where focus changes to non-Layout and back
Diffstat (limited to 'src/input')
| -rw-r--r-- | src/input/mod.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/input/mod.rs b/src/input/mod.rs index a6fc549f..a952a23a 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -779,7 +779,19 @@ impl State { self.niri.queue_redraw_all(); } Action::FocusWindowPrevious => { - if let Some(window) = self.niri.previously_focused_window.clone() { + let current = self.niri.layout.focus().map(|win| win.id()); + if let Some(window) = self + .niri + .layout + .windows() + .map(|(_, win)| win) + .filter(|win| Some(win.id()) != current) + .max_by_key(|win| win.get_focus_timestamp()) + .map(|win| win.window.clone()) + { + // Commit current focus so repeated focus-window-previous works as expected. + self.niri.mru_apply_keyboard_commit(); + self.focus_window(&window); } } |
