Set window focused only if it's on the focused output

This commit is contained in:
Ottatop 2024-02-24 14:58:58 -06:00
parent 1f909ac81b
commit e734a716c0
3 changed files with 9 additions and 11 deletions

View file

@ -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

View file

@ -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::<Vec<_>>();
let windows = self.space.elements().cloned().collect::<Vec<_>>();
let result = render_surface(

View file

@ -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<WindowElement> {
output.with_state(|state| state.focus_stack.stack.retain(|win| win.alive()));
pub fn focused_window(&self, output: &Output) -> Option<WindowElement> {
// 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