shell: Fix moving fullscreen windows

This commit is contained in:
Victoria Brekenfeld 2023-10-24 15:58:53 +02:00
parent 3901e637b0
commit 724a4170df
2 changed files with 44 additions and 4 deletions

View file

@ -1526,7 +1526,7 @@ impl Shell {
None None
}; };
let to_workspace = state let mut to_workspace = state
.common .common
.shell .shell
.workspaces .workspaces
@ -1541,8 +1541,39 @@ impl Shell {
.map(mapped.clone(), Some(focus_stack.iter()), direction); .map(mapped.clone(), Some(focus_stack.iter()), direction);
} }
let focus_target = if let Some(f) = window_state.was_fullscreen { 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); 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 { } else {
KeyboardFocusTarget::from(mapped.clone()) KeyboardFocusTarget::from(mapped.clone())
}; };

View file

@ -479,7 +479,12 @@ impl Workspace {
window: &CosmicSurface, window: &CosmicSurface,
previously: Option<(ManagedLayer, WorkspaceHandle)>, previously: Option<(ManagedLayer, WorkspaceHandle)>,
) { ) {
if self.fullscreen.is_some() { if self
.fullscreen
.as_ref()
.filter(|f| f.ended_at.is_none())
.is_some()
{
return; return;
} }
@ -516,7 +521,11 @@ impl Workspace {
&mut self, &mut self,
window: &CosmicSurface, window: &CosmicSurface,
) -> Option<(ManagedLayer, WorkspaceHandle)> { ) -> 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_fullscreen(false);
window.set_geometry(f.original_geometry); window.set_geometry(f.original_geometry);