diff --git a/src/api.rs b/src/api.rs index 1bb37e4..13c06cc 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1698,8 +1698,11 @@ impl window_service_server::WindowService for WindowService { }); let focused = window.as_ref().and_then(|win| { - let output = win.output(state)?; - state.focused_window(&output).map(|foc_win| win == &foc_win) + state + .output_focus_stack + .current_focus() + .and_then(|output| state.focused_window(output)) + .map(|foc_win| win == &foc_win) }); let floating = window diff --git a/src/backend/udev.rs b/src/backend/udev.rs index c8841d3..8112493 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -516,6 +516,7 @@ pub fn run_udev() -> anyhow::Result<()> { Some(Duration::from_micros(((1.0 / 144.0) * 1000000.0) as u64)), &mut state, |state| { + state.fixup_focus(); state.space.refresh(); state.popup_manager.cleanup(); state @@ -1252,13 +1253,6 @@ impl State { texture }); - // let windows = self - // .output_focus_stack - // .stack - // .iter() - // .flat_map(|op| op.with_state(|state| state.focus_stack.stack.clone())) - // .collect::>(); - let windows = self.space.elements().cloned().collect::>(); let result = render_surface( diff --git a/src/focus.rs b/src/focus.rs index cf3d81a..fd950b7 100644 --- a/src/focus.rs +++ b/src/focus.rs @@ -21,8 +21,9 @@ use crate::{ impl State { /// Get the currently focused window on `output` /// that isn't an override redirect window, if any. - pub fn focused_window(&mut self, output: &Output) -> Option { - output.with_state(|state| state.focus_stack.stack.retain(|win| win.alive())); + pub fn focused_window(&self, output: &Output) -> Option { + // TODO: see if the below is necessary + // output.with_state(|state| state.focus_stack.stack.retain(|win| win.alive())); let windows = output.with_state(|state| { state