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,33 +109,24 @@ 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)) let from_handle = from_workspace.handle;
.any(|w| &w == window) let seat = shell.seats.last_active().clone();
}); let res = shell.move_window(
if let Some(from_workspace) = from_workspace { Some(&seat),
let mapped = from_workspace &mapped,
.mapped() &from_handle,
.find(|m| m.windows().any(|(w, _)| &w == window)) &to_handle,
.unwrap() false,
.clone(); None,
let from_handle = from_workspace.handle; &mut self.common.workspace_state.update(),
let seat = shell.seats.last_active().clone(); );
let res = shell.move_window( if let Some((target, _)) = res {
Some(&seat), std::mem::drop(shell);
&mapped, Shell::set_focus(self, Some(&target), &seat, None, true);
&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;
} }
} }