From 724a4170dfe5d66cc67eeac2810595bad96fc176 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Tue, 24 Oct 2023 15:58:53 +0200 Subject: [PATCH] shell: Fix moving fullscreen windows --- src/shell/mod.rs | 35 +++++++++++++++++++++++++++++++++-- src/shell/workspace.rs | 13 +++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/shell/mod.rs b/src/shell/mod.rs index a2907e5e..db386c1b 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -1526,7 +1526,7 @@ impl Shell { None }; - let to_workspace = state + let mut to_workspace = state .common .shell .workspaces @@ -1541,8 +1541,39 @@ impl Shell { .map(mapped.clone(), Some(focus_stack.iter()), direction); } let focus_target = if let Some(f) = window_state.was_fullscreen { + if to_workspace.fullscreen.is_some() { + if let Some((mapped, layer, previous_workspace)) = to_workspace.remove_fullscreen() + { + let old_handle = to_workspace.handle.clone(); + let new_workspace_handle = state + .common + .shell + .space_for_handle(&previous_workspace) + .is_some() + .then_some(previous_workspace) + .unwrap_or(old_handle); + + state.common.shell.remap_unfullscreened_window( + mapped, + &old_handle, + &new_workspace_handle, + layer, + ); + to_workspace = state + .common + .shell + .workspaces + .get_mut(to_idx, to_output) + .unwrap(); // checked above + } + } + to_workspace.fullscreen_request(&mapped.active_window(), f.previously); - KeyboardFocusTarget::from(to_workspace.get_fullscreen().unwrap().clone()) + to_workspace + .fullscreen + .as_ref() + .map(|f| KeyboardFocusTarget::from(f.surface.clone())) + .unwrap_or_else(|| KeyboardFocusTarget::from(mapped.clone())) } else { KeyboardFocusTarget::from(mapped.clone()) }; diff --git a/src/shell/workspace.rs b/src/shell/workspace.rs index 97ce3eb9..bdf0e3fb 100644 --- a/src/shell/workspace.rs +++ b/src/shell/workspace.rs @@ -479,7 +479,12 @@ impl Workspace { window: &CosmicSurface, previously: Option<(ManagedLayer, WorkspaceHandle)>, ) { - if self.fullscreen.is_some() { + if self + .fullscreen + .as_ref() + .filter(|f| f.ended_at.is_none()) + .is_some() + { return; } @@ -516,7 +521,11 @@ impl Workspace { &mut self, window: &CosmicSurface, ) -> Option<(ManagedLayer, WorkspaceHandle)> { - if let Some(f) = self.fullscreen.as_mut().filter(|f| &f.surface == window) { + if let Some(f) = self + .fullscreen + .as_mut() + .filter(|f| &f.surface == window && f.ended_at.is_none()) + { window.set_fullscreen(false); window.set_geometry(f.original_geometry);