From d02c138414665df1569cec47ee79f11e62aab77c Mon Sep 17 00:00:00 2001 From: Ottatop Date: Mon, 4 Mar 2024 19:34:00 -0600 Subject: [PATCH] Fix `focused_window` not returning `None` if no window is focused --- src/focus.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/focus.rs b/src/focus.rs index 087a54d..0913383 100644 --- a/src/focus.rs +++ b/src/focus.rs @@ -18,16 +18,20 @@ impl State { // TODO: see if the below is necessary // output.with_state(|state| state.focus_stack.stack.retain(|win| win.alive())); - output.with_state(|state| { - state - .focus_stack - .stack - .iter() - .rev() - .filter(|win| win.is_on_active_tag()) - .find(|win| !win.is_x11_override_redirect()) - .cloned() - }) + output + .with_state(|state| { + state.focus_stack.focused.then(|| { + state + .focus_stack + .stack + .iter() + .rev() + .filter(|win| win.is_on_active_tag()) + .find(|win| !win.is_x11_override_redirect()) + .cloned() + }) + }) + .flatten() } /// Update the keyboard focus.