From 45bd385d9c136a463543448baeb01127e1a769d5 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Mon, 13 Feb 2023 20:28:07 +0100 Subject: [PATCH] shell: Clear fullscreen on new window --- src/shell/mod.rs | 1 + src/shell/workspace.rs | 33 +++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 4685fc14..17fc79ca 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -1051,6 +1051,7 @@ impl Shell { let (window, seat) = state.common.shell.pending_windows.remove(pos); let workspace = state.common.shell.workspaces.active_mut(output); + workspace.set_fullscreen(None, output); state.common.shell.toplevel_info_state.new_toplevel(&window); state .common diff --git a/src/shell/workspace.rs b/src/shell/workspace.rs index 11ee61c7..3945b3d7 100644 --- a/src/shell/workspace.rs +++ b/src/shell/workspace.rs @@ -236,17 +236,30 @@ impl Workspace { self.set_fullscreen(window, output) } - fn set_fullscreen(&mut self, window: &CosmicSurface, output: &Output) { - if let Some(mapped) = self - .mapped() - .find(|m| m.windows().any(|(w, _)| &w == window)) - { - mapped.set_active(window); - } + pub(super) fn set_fullscreen<'a>( + &mut self, + window: impl Into>, + output: &Output, + ) { + match window.into() { + Some(window) => { + if let Some(mapped) = self + .mapped() + .find(|m| m.windows().any(|(w, _)| &w == window)) + { + mapped.set_active(window); + } - window.set_geometry(output.geometry()); - window.send_configure(); - self.fullscreen.insert(output.clone(), window.clone()); + window.set_geometry(output.geometry()); + window.send_configure(); + self.fullscreen.insert(output.clone(), window.clone()); + } + None => { + if let Some(surface) = self.fullscreen.get(output).cloned() { + self.unfullscreen_request(&surface); + } + } + } } pub fn unfullscreen_request(&mut self, window: &CosmicSurface) {