From 9ced8c346d99ab6846ff89aa2973c5bc4bb7c619 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Tue, 7 Nov 2023 18:40:29 +0100 Subject: [PATCH] shell: Each surface has only one workspace --- src/shell/mod.rs | 6 +----- src/wayland/handlers/screencopy.rs | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 5fdd1119..6a5ba211 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -1006,10 +1006,7 @@ impl Shell { } } - pub fn workspaces_for_surface( - &self, - surface: &WlSurface, - ) -> impl Iterator { + pub fn workspace_for_surface(&self, surface: &WlSurface) -> Option<(WorkspaceHandle, Output)> { match self.outputs().find(|o| { let map = layer_map_for_output(o); map.layer_for_surface(surface, WindowSurfaceType::ALL) @@ -1029,7 +1026,6 @@ impl Shell { }) .map(|w| (w.handle.clone(), w.output().clone())), } - .into_iter() } pub fn element_for_surface(&self, surface: &CosmicSurface) -> Option<&CosmicMapped> { diff --git a/src/wayland/handlers/screencopy.rs b/src/wayland/handlers/screencopy.rs index 16a37b19..e2dd4443 100644 --- a/src/wayland/handlers/screencopy.rs +++ b/src/wayland/handlers/screencopy.rs @@ -1246,7 +1246,7 @@ impl State { .outputs() .map(|o| (o.clone(), self.common.shell.active_space(o).handle.clone())) .collect::>(); - 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(); if !workspace.pending_buffers.is_empty() { // TODO: replace with drain_filter....