diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 34f649939..91e53c8c5 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -3994,12 +3994,12 @@ impl Layout { } } - pub fn render_floating_for_output( - &self, + pub fn render_floating_for_output<'a, R: NiriRenderer + 'a>( + &'a self, renderer: &mut R, output: &Output, target: RenderTarget, - ) -> impl Iterator> { + ) -> impl Iterator> + 'a { if self.update_render_elements_time != self.clock.now() { error!("clock moved between updating render elements and rendering"); } diff --git a/src/layout/shadow.rs b/src/layout/shadow.rs index 1600e3338..3e0605c41 100644 --- a/src/layout/shadow.rs +++ b/src/layout/shadow.rs @@ -157,26 +157,19 @@ impl Shadow { &self, renderer: &mut impl NiriRenderer, location: Point, - ) -> impl Iterator { - let mut rv = Vec::new(); - + ) -> impl Iterator + '_ { if !self.config.on { - return rv.into_iter(); + return None.into_iter().flatten(); } let has_shadow_shader = ShadowRenderElement::has_shader(renderer); if !has_shadow_shader { - return rv.into_iter(); + return None.into_iter().flatten(); } - let mut push = |shader: &ShadowRenderElement, location: Point| { - rv.push(shader.clone().with_location(location)); - }; - - for (shader, rect) in zip(&self.shaders, &self.shader_rects) { - push(shader, location + rect.loc); - } + let rv = zip(&self.shaders, &self.shader_rects) + .map(move |(shader, rect)| shader.clone().with_location(location + rect.loc)); - rv.into_iter() + Some(rv).into_iter().flatten() } } diff --git a/src/layout/tile.rs b/src/layout/tile.rs index a9fd8e136..529ffc0fd 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -710,14 +710,14 @@ impl Tile { .unwrap_or_else(|| !self.window.has_ssd()) } - fn render_inner( - &self, + fn render_inner<'a, R: NiriRenderer + 'a>( + &'a self, renderer: &mut R, location: Point, scale: Scale, focus_ring: bool, target: RenderTarget, - ) -> impl Iterator> { + ) -> impl Iterator> + 'a { let _span = tracy_client::span!("Tile::render_inner"); let alpha = if self.is_fullscreen { @@ -926,14 +926,14 @@ impl Tile { rv.chain(self.shadow.render(renderer, location).map(Into::into)) } - pub fn render( - &self, + pub fn render<'a, R: NiriRenderer + 'a>( + &'a self, renderer: &mut R, location: Point, scale: Scale, focus_ring: bool, target: RenderTarget, - ) -> impl Iterator> { + ) -> impl Iterator> + 'a { let _span = tracy_client::span!("Tile::render"); let mut open_anim_elem = None;