shell: Each surface has only one workspace

This commit is contained in:
Victoria Brekenfeld 2023-11-07 18:40:29 +01:00
parent 32efedc7e1
commit 9ced8c346d
2 changed files with 2 additions and 6 deletions

View file

@ -1006,10 +1006,7 @@ impl Shell {
} }
} }
pub fn workspaces_for_surface( pub fn workspace_for_surface(&self, surface: &WlSurface) -> Option<(WorkspaceHandle, Output)> {
&self,
surface: &WlSurface,
) -> impl Iterator<Item = (WorkspaceHandle, Output)> {
match self.outputs().find(|o| { match self.outputs().find(|o| {
let map = layer_map_for_output(o); let map = layer_map_for_output(o);
map.layer_for_surface(surface, WindowSurfaceType::ALL) map.layer_for_surface(surface, WindowSurfaceType::ALL)
@ -1029,7 +1026,6 @@ impl Shell {
}) })
.map(|w| (w.handle.clone(), w.output().clone())), .map(|w| (w.handle.clone(), w.output().clone())),
} }
.into_iter()
} }
pub fn element_for_surface(&self, surface: &CosmicSurface) -> Option<&CosmicMapped> { pub fn element_for_surface(&self, surface: &CosmicSurface) -> Option<&CosmicMapped> {

View file

@ -1246,7 +1246,7 @@ impl State {
.outputs() .outputs()
.map(|o| (o.clone(), self.common.shell.active_space(o).handle.clone())) .map(|o| (o.clone(), self.common.shell.active_space(o).handle.clone()))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
for (handle, output) in self.common.shell.workspaces_for_surface(surface) { if let Some((handle, output)) = self.common.shell.workspace_for_surface(surface) {
let workspace = self.common.shell.space_for_handle_mut(&handle).unwrap(); let workspace = self.common.shell.space_for_handle_mut(&handle).unwrap();
if !workspace.pending_buffers.is_empty() { if !workspace.pending_buffers.is_empty() {
// TODO: replace with drain_filter.... // TODO: replace with drain_filter....