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.
This commit is contained in:
Ian Douglas Scott 2025-01-27 18:12:50 -08:00 committed by Ian Douglas Scott
parent 7822030e0b
commit 9b3a42d450

View file

@ -109,17 +109,8 @@ impl ToplevelManagementHandler for State {
}; };
let mut shell = self.common.shell.write().unwrap(); let mut shell = self.common.shell.write().unwrap();
let from_workspace = shell.workspaces.spaces().find(|w| { if let Some(mapped) = shell.element_for_surface(window).cloned() {
w.mapped() if let Some(from_workspace) = shell.space_for(&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 from_handle = from_workspace.handle;
let seat = shell.seats.last_active().clone(); let seat = shell.seats.last_active().clone();
let res = shell.move_window( let res = shell.move_window(
@ -135,7 +126,7 @@ impl ToplevelManagementHandler for State {
std::mem::drop(shell); std::mem::drop(shell);
Shell::set_focus(self, Some(&target), &seat, None, true); Shell::set_focus(self, Some(&target), &seat, None, true);
} }
return; }
} }
} }