add layer definition to RenderElement
This commit is contained in:
parent
92d04ba8fe
commit
b9ecc3c2d4
|
@ -10,6 +10,23 @@ use std::{
|
|||
};
|
||||
use wayland_server::protocol::wl_surface::WlSurface;
|
||||
|
||||
/// Enum for indicating on with layer a render element schould be draw
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum RenderLayer {
|
||||
/// Bellow every other elements
|
||||
Bottom,
|
||||
/// Above WlrLayer::Background but bellow WlrLayer::Bottom
|
||||
AboveBackground,
|
||||
/// Right before programs windows are draw
|
||||
BeforeWindows,
|
||||
/// Right after programs windows are draw
|
||||
AfterWindows,
|
||||
/// Above WlrLayer::Top but bellow WlrLayer::Overlay
|
||||
BeforeOverlay,
|
||||
/// Above anything else
|
||||
Top,
|
||||
}
|
||||
|
||||
/// Trait for custom elements to be rendered during [`Space::render_output`].
|
||||
pub trait RenderElement<R, F, E, T>
|
||||
where
|
||||
|
@ -55,6 +72,11 @@ where
|
|||
damage: &[Rectangle<i32, Logical>],
|
||||
log: &slog::Logger,
|
||||
) -> Result<(), R::Error>;
|
||||
|
||||
/// Returns they layer the elements schould be draw on, defaults to Top
|
||||
fn layer(&self) -> RenderLayer {
|
||||
RenderLayer::Top
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) trait SpaceElement<R, F, E, T>
|
||||
|
|
|
@ -501,6 +501,7 @@ impl Space {
|
|||
// This will hold all the damage we need for this rendering step
|
||||
let mut damage = Vec::<Rectangle<i32, Logical>>::new();
|
||||
// First add damage for windows gone
|
||||
|
||||
for old_toplevel in state
|
||||
.last_state
|
||||
.iter()
|
||||
|
@ -613,18 +614,53 @@ impl Space {
|
|||
|
||||
// Then re-draw all windows & layers overlapping with a damage rect.
|
||||
|
||||
for element in layer_map
|
||||
for element in custom_elements
|
||||
.iter()
|
||||
.filter(|c| c.layer() == RenderLayer::Bottom)
|
||||
.map(|p| p as &SpaceElem<R>)
|
||||
.chain(
|
||||
layer_map
|
||||
.layers_on(WlrLayer::Background)
|
||||
.chain(layer_map.layers_on(WlrLayer::Bottom))
|
||||
.map(|l| l as &SpaceElem<R>)
|
||||
.chain(
|
||||
custom_elements
|
||||
.iter()
|
||||
.filter(|c| c.layer() == RenderLayer::AboveBackground)
|
||||
.map(|c| c as &SpaceElem<R>),
|
||||
)
|
||||
.chain(layer_map.layers_on(WlrLayer::Bottom).map(|l| l as &SpaceElem<R>)),
|
||||
)
|
||||
.chain(
|
||||
custom_elements
|
||||
.iter()
|
||||
.filter(|c| c.layer() == RenderLayer::BeforeWindows)
|
||||
.map(|c| c as &SpaceElem<R>),
|
||||
)
|
||||
.chain(self.windows.iter().map(|w| w as &SpaceElem<R>))
|
||||
.chain(
|
||||
custom_elements
|
||||
.iter()
|
||||
.filter(|c| c.layer() == RenderLayer::AfterWindows)
|
||||
.map(|c| c as &SpaceElem<R>),
|
||||
)
|
||||
.chain(
|
||||
layer_map
|
||||
.layers_on(WlrLayer::Top)
|
||||
.chain(layer_map.layers_on(WlrLayer::Overlay))
|
||||
.map(|l| l as &SpaceElem<R>),
|
||||
.map(|l| l as &SpaceElem<R>)
|
||||
.chain(
|
||||
custom_elements
|
||||
.iter()
|
||||
.filter(|c| c.layer() == RenderLayer::BeforeOverlay)
|
||||
.map(|c| c as &SpaceElem<R>),
|
||||
)
|
||||
.chain(layer_map.layers_on(WlrLayer::Overlay).map(|l| l as &SpaceElem<R>)),
|
||||
)
|
||||
.chain(
|
||||
custom_elements
|
||||
.iter()
|
||||
.filter(|c| c.layer() == RenderLayer::Top)
|
||||
.map(|c| c as &SpaceElem<R>),
|
||||
)
|
||||
.chain(custom_elements.iter().map(|c| c as &SpaceElem<R>))
|
||||
{
|
||||
let geo = element.geometry(self.id);
|
||||
if damage.iter().any(|d| d.overlaps(geo)) {
|
||||
|
|
Loading…
Reference in New Issue