shell: Fix output_for_surfaces for layer surfaces

This commit is contained in:
Victoria Brekenfeld 2022-07-11 22:35:48 +02:00
parent 0f18216cfb
commit 4de316cbce

View file

@ -441,17 +441,21 @@ impl Shell {
} }
} }
pub fn outputs_for_surface(&self, surface: &WlSurface) -> impl Iterator<Item = Output> { pub fn outputs_for_surface<'a>(&'a self, surface: &'a WlSurface) -> impl Iterator<Item = Output> + 'a {
self.space_for_surface(surface) match self.outputs.iter().find(|o| {
.and_then(|w| { let map = layer_map_for_output(o);
map.layer_for_surface(surface, WindowSurfaceType::ALL).is_some()
}) {
Some(output) => Box::new(std::iter::once(output.clone())) as Box<dyn Iterator<Item = Output>>,
None => Box::new(self.spaces.iter().filter_map(|w| {
if let Some(window) = w.space.window_for_surface(surface, WindowSurfaceType::ALL) { if let Some(window) = w.space.window_for_surface(surface, WindowSurfaceType::ALL) {
Some(w.space.outputs_for_window(&window).into_iter()) Some(w.space.outputs_for_window(&window).into_iter())
} else { } else {
None None
} }
}) })
.into_iter() .flatten()),
.flatten() }
} }
pub fn space_for_surface(&self, surface: &WlSurface) -> Option<&Workspace> { pub fn space_for_surface(&self, surface: &WlSurface) -> Option<&Workspace> {