diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 00000000..e69de29b diff --git a/src/shell/element/mod.rs b/src/shell/element/mod.rs index 702281d3..8e2d04c9 100644 --- a/src/shell/element/mod.rs +++ b/src/shell/element/mod.rs @@ -132,6 +132,14 @@ impl CosmicMapped { } } + pub fn has_active_window(&self, window: &CosmicSurface) -> bool { + match &self.element { + CosmicMappedInternal::Stack(stack) => stack.has_active(window), + CosmicMappedInternal::Window(win) => win.contains_surface(window), + _ => unreachable!(), + } + } + pub fn active_window_offset(&self) -> Point { match &self.element { CosmicMappedInternal::Stack(stack) => stack.offset(), diff --git a/src/shell/element/stack.rs b/src/shell/element/stack.rs index 724f88ef..1d7ecb5e 100644 --- a/src/shell/element/stack.rs +++ b/src/shell/element/stack.rs @@ -124,6 +124,11 @@ impl CosmicStack { .with_program(|p| p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)].clone()) } + pub fn has_active(&self, window: &CosmicSurface) -> bool { + self.0 + .with_program(|p| &p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)] == window) + } + pub fn set_active(&self, window: &CosmicSurface) { self.0.with_program(|p| { if let Some(val) = p.windows.lock().unwrap().iter().position(|w| w == window) { diff --git a/src/shell/element/window.rs b/src/shell/element/window.rs index 06ff52d5..b85139e4 100644 --- a/src/shell/element/window.rs +++ b/src/shell/element/window.rs @@ -149,6 +149,10 @@ impl CosmicWindow { self.0.with_program(|p| p.window.clone()) } + pub fn contains_surface(&self, window: &CosmicSurface) -> bool { + self.0.with_program(|p| &p.window == window) + } + pub fn offset(&self) -> Point { let has_ssd = self.0.with_program(|p| p.has_ssd()); if has_ssd { diff --git a/src/shell/focus/mod.rs b/src/shell/focus/mod.rs index d4b30a03..cc5a0c1f 100644 --- a/src/shell/focus/mod.rs +++ b/src/shell/focus/mod.rs @@ -216,9 +216,24 @@ impl Common { continue; // Focus is valid, } } - KeyboardFocusTarget::Popup(_) | KeyboardFocusTarget::Fullscreen(_) => { - continue; - } // Focus is valid + KeyboardFocusTarget::Fullscreen(surface) => { + let workspace = state.common.shell.active_space(&output); + let focus_stack = workspace.focus_stack.get(&seat); + + if focus_stack + .last() + .map(|m| m.has_active_window(&surface)) + .unwrap_or(false) + && workspace.get_fullscreen(&output).is_some() + { + continue; // Focus is valid + } else { + trace!("Wrong Window, focus fixup"); + } + } + KeyboardFocusTarget::Popup(_) => { + continue; // Focus is valid + } }; } else { trace!("Surface dead, focus fixup");