diff --git a/src/backend/udev.rs b/src/backend/udev.rs index b8f00d6..99bb8a6 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -1509,11 +1509,10 @@ fn render_surface<'a>( let output_render_elements = crate::render::generate_render_elements( space, - windows, + focus_stack, pointer_location, cursor_status, dnd_icon, - focus_stack, renderer, output, input_method, diff --git a/src/backend/winit.rs b/src/backend/winit.rs index cdd1461..94be3c2 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -281,21 +281,12 @@ pub fn run_winit() -> anyhow::Result<()> { state.focus_state.fix_up_focus(&mut state.space); - let windows = state - .focus_state - .focus_stack - .iter() - .filter(|win| win.alive()) - .cloned() - .collect::>(); - let output_render_elements = crate::render::generate_render_elements( &state.space, - &windows, + &state.focus_state.focus_stack, state.pointer_location, &mut state.cursor_status, state.dnd_icon.as_ref(), - &state.focus_state.focus_stack, backend.backend.renderer(), &output, state.seat.input_method(), diff --git a/src/render.rs b/src/render.rs index 9ec4042..3d4f0e8 100644 --- a/src/render.rs +++ b/src/render.rs @@ -12,7 +12,7 @@ use smithay::{ }, desktop::{ layer_map_for_output, - space::{SpaceRenderElements, SurfaceTree}, + space::{SpaceElement, SpaceRenderElements, SurfaceTree}, Space, }, input::pointer::{CursorImageAttributes, CursorImageStatus}, @@ -26,7 +26,7 @@ use smithay::{ wayland::{compositor, input_method::InputMethodHandle, shell::wlr_layer}, }; -use crate::{state::WithState, tag::Tag, window::WindowElement}; +use crate::{state::WithState, window::WindowElement}; use self::pointer::{PointerElement, PointerRenderElement}; @@ -126,6 +126,33 @@ where } } +/// Get the render_elements for the provided tags. +fn tag_render_elements( + windows: &[WindowElement], + space: &Space, + renderer: &mut R, +) -> Vec +where + R: Renderer + ImportAll + ImportMem, + ::TextureId: 'static, + C: From>, +{ + let elements = windows + .iter() + .rev() // rev because I treat the focus stack backwards vs how the renderer orders it + .filter(|win| win.is_on_active_tag(space.outputs())) + .flat_map(|win| { + // subtract win.geometry().loc to align decorations correctly + let loc = (space.element_location(win).unwrap_or((0, 0).into()) + - win.geometry().loc) + .to_physical(1); + win.render_elements::(renderer, loc, Scale::from(1.0), 1.0) + }) + .collect::>(); + + elements +} + #[allow(clippy::too_many_arguments)] pub fn generate_render_elements( space: &Space, @@ -133,7 +160,6 @@ pub fn generate_render_elements( pointer_location: Point, cursor_status: &mut CursorImageStatus, dnd_icon: Option<&WlSurface>, - focus_stack: &[WindowElement], renderer: &mut R, output: &Output, input_method: &InputMethodHandle, @@ -218,7 +244,7 @@ where } let output_render_elements = { - let top_fullscreen_window = focus_stack.iter().rev().find(|win| { + let top_fullscreen_window = windows.iter().rev().find(|win| { win.with_state(|state| { // TODO: for wayland windows, check if current state has xdg_toplevel fullscreen let is_wayland_actually_fullscreen = { @@ -269,7 +295,7 @@ where } = layer_render_elements(output, renderer); let window_render_elements: Vec> = - Tag::tag_render_elements(windows, space, renderer); + tag_render_elements(windows, space, renderer); let mut output_render_elements = Vec::>>::new(); diff --git a/src/tag.rs b/src/tag.rs index 39c6ab1..1404b0e 100644 --- a/src/tag.rs +++ b/src/tag.rs @@ -7,20 +7,11 @@ use std::{ sync::atomic::{AtomicU32, Ordering}, }; -use smithay::{ - backend::renderer::{ - element::{surface::WaylandSurfaceRenderElement, AsRenderElements}, - ImportAll, ImportMem, Renderer, - }, - desktop::{space::SpaceElement, Space}, - output::Output, - utils::Scale, -}; +use smithay::output::Output; use crate::{ layout::Layout, state::{State, WithState}, - window::WindowElement, }; static TAG_ID_COUNTER: AtomicU32 = AtomicU32::new(0); @@ -117,31 +108,4 @@ impl Tag { .find(|output| output.with_state(|state| state.tags.iter().any(|tg| tg == self))) .cloned() } - - /// Get the render_elements for the provided tags. - pub fn tag_render_elements( - windows: &[WindowElement], - space: &Space, - renderer: &mut R, - ) -> Vec - where - R: Renderer + ImportAll + ImportMem, - ::TextureId: 'static, - C: From>, - { - let elements = windows - .iter() - .rev() // rev because I treat the focus stack backwards vs how the renderer orders it - .filter(|win| win.is_on_active_tag(space.outputs())) - .flat_map(|win| { - // subtract win.geometry().loc to align decorations correctly - let loc = (space.element_location(win).unwrap_or((0, 0).into()) - - win.geometry().loc) - .to_physical(1); - win.render_elements::(renderer, loc, Scale::from(1.0), 1.0) - }) - .collect::>(); - - elements - } }