From 9b3a42d450593734b7dbfca584c0f3e6166c64ea Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Mon, 27 Jan 2025 18:12:50 -0800 Subject: [PATCH] toplevel-management: Make `move_to_workspace` work with minimized window Iterating over `.windows()` for each workspace does not iterate over `minimized_windows`, so `from_workspace` was not found. Simply changing this to use `element_for_surface` and `space_for` (like `fullscreen` and `unfullscreen`) fixes this. Addresses https://github.com/pop-os/cosmic-workspaces-epoch/issues/89. Though it does unminimize the window, which we may also want to change. --- src/wayland/handlers/toplevel_management.rs | 43 ++++++++------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/src/wayland/handlers/toplevel_management.rs b/src/wayland/handlers/toplevel_management.rs index e4c8cc71..28654837 100644 --- a/src/wayland/handlers/toplevel_management.rs +++ b/src/wayland/handlers/toplevel_management.rs @@ -109,33 +109,24 @@ impl ToplevelManagementHandler for State { }; let mut shell = self.common.shell.write().unwrap(); - let from_workspace = shell.workspaces.spaces().find(|w| { - w.mapped() - .flat_map(|m| m.windows().map(|(s, _)| s)) - .any(|w| &w == window) - }); - if let Some(from_workspace) = from_workspace { - let mapped = from_workspace - .mapped() - .find(|m| m.windows().any(|(w, _)| &w == window)) - .unwrap() - .clone(); - let from_handle = from_workspace.handle; - let seat = shell.seats.last_active().clone(); - let res = shell.move_window( - Some(&seat), - &mapped, - &from_handle, - &to_handle, - false, - None, - &mut self.common.workspace_state.update(), - ); - if let Some((target, _)) = res { - std::mem::drop(shell); - Shell::set_focus(self, Some(&target), &seat, None, true); + if let Some(mapped) = shell.element_for_surface(window).cloned() { + if let Some(from_workspace) = shell.space_for(&mapped) { + let from_handle = from_workspace.handle; + let seat = shell.seats.last_active().clone(); + let res = shell.move_window( + Some(&seat), + &mapped, + &from_handle, + &to_handle, + false, + None, + &mut self.common.workspace_state.update(), + ); + if let Some((target, _)) = res { + std::mem::drop(shell); + Shell::set_focus(self, Some(&target), &seat, None, true); + } } - return; } }