Remove CropRenderElement from window render elements

This commit is contained in:
Ottatop 2024-04-10 14:02:48 -05:00
parent 4a1a01a5a4
commit a4e1a63efd

View file

@ -146,15 +146,16 @@ where
{ {
let mut last_fullscreen_split_at = 0; let mut last_fullscreen_split_at = 0;
let mut elements = windows let mut fullscreen_and_up = windows
.iter() .iter()
.rev() // rev because I treat the focus stack backwards vs how the renderer orders it .rev() // rev because I treat the focus stack backwards vs how the renderer orders it
.filter(|win| win.is_on_active_tag()) .filter(|win| win.is_on_active_tag())
.enumerate() .enumerate()
.map(|(i, win)| { .flat_map(|(i, win)| {
if win.with_state(|state| state.fullscreen_or_maximized.is_fullscreen()) { if win.with_state(|state| state.fullscreen_or_maximized.is_fullscreen()) {
last_fullscreen_split_at = i + 1; last_fullscreen_split_at = i + 1;
} }
// subtract win.geometry().loc to align decorations correctly // subtract win.geometry().loc to align decorations correctly
let loc = ( let loc = (
space.element_location(win) .unwrap_or((0, 0).into()) space.element_location(win) .unwrap_or((0, 0).into())
@ -163,33 +164,14 @@ where
) )
.to_physical_precise_round(scale); .to_physical_precise_round(scale);
let elem_geo = space.element_geometry(win).map(|mut geo| { win.render_elements::<WaylandSurfaceRenderElement<R>>(renderer, loc, scale, 1.0)
geo.loc -= output.current_location(); .into_iter()
geo .map(OutputRenderElement::from)
});
(win.render_elements::<WaylandSurfaceRenderElement<R>>(renderer, loc, scale, 1.0), elem_geo)
}).map(|(elems, rect)| {
// We're cropping everything down to its expected size to stop any sussy windows that
// don't want to cooperate. Unfortunately this also truncates shadows and other
// external decorations.
match rect {
Some(rect) => {
elems.into_iter().filter_map(|elem| {
CropRenderElement::from_element(elem, scale, rect.to_physical_precise_round(scale))
}).map(TransformRenderElement::from).map(OutputRenderElement::from).collect::<Vec<_>>()
},
None => elems.into_iter().map(OutputRenderElement::from).collect(),
}
}).collect::<Vec<_>>(); }).collect::<Vec<_>>();
let rest = elements.split_off(last_fullscreen_split_at); let rest = fullscreen_and_up.split_off(last_fullscreen_split_at);
// PERF: bunch of allocations here (fullscreen_and_up, rest)
(
elements.into_iter().flatten().collect(),
rest.into_iter().flatten().collect(),
)
} }
pub fn pointer_render_elements<R>( pub fn pointer_render_elements<R>(