space: `output_under` may return multiple outputs

This commit is contained in:
Victor Brekenfeld 2022-01-06 18:29:30 +01:00
parent ccec794af7
commit 14d10e4863
1 changed files with 3 additions and 3 deletions

View File

@ -136,10 +136,10 @@ impl Space {
}) })
} }
/// Get a reference to the output under a given point, if any /// Get a reference to the outputs under a given point
pub fn output_under<P: Into<Point<f64, Logical>>>(&self, point: P) -> Option<&Output> { pub fn output_under<P: Into<Point<f64, Logical>>>(&self, point: P) -> impl Iterator<Item = &Output> {
let point = point.into(); let point = point.into();
self.outputs.iter().rev().find(|o| { self.outputs.iter().rev().filter(move |o| {
let bbox = self.output_geometry(o); let bbox = self.output_geometry(o);
bbox.map(|bbox| bbox.to_f64().contains(point)).unwrap_or(false) bbox.map(|bbox| bbox.to_f64().contains(point)).unwrap_or(false)
}) })