From da826e42aaaa6dc559db67f4708db8bc23754f46 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 4 Feb 2024 22:29:09 +0400 Subject: layout: Add LayoutElementRenderElement Allows for testing layout rendering without Wayland windows. --- src/layout/mod.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/layout/mod.rs') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 6b648816..2a551b82 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -35,6 +35,8 @@ use std::rc::Rc; use std::time::Duration; use niri_config::{self, CenterFocusedColumn, Config, SizeChange, Struts}; +use smithay::backend::renderer::element::solid::SolidColorRenderElement; +use smithay::backend::renderer::element::surface::WaylandSurfaceRenderElement; use smithay::backend::renderer::element::AsRenderElements; use smithay::backend::renderer::{ImportAll, Renderer}; use smithay::desktop::space::SpaceElement; @@ -43,15 +45,14 @@ use smithay::output::Output; use smithay::reexports::wayland_protocols::xdg::decoration::zv1::server::zxdg_toplevel_decoration_v1; use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; +use smithay::render_elements; use smithay::utils::{Logical, Point, Rectangle, Scale, Size, Transform}; use smithay::wayland::compositor::{send_surface_state, with_states}; use smithay::wayland::shell::xdg::SurfaceCachedState; pub use self::monitor::MonitorRenderElement; use self::monitor::{Monitor, WorkspaceSwitch, WorkspaceSwitchGesture}; -use self::workspace::{ - compute_working_area, Column, ColumnWidth, OutputId, Workspace, WorkspaceRenderElement, -}; +use self::workspace::{compute_working_area, Column, ColumnWidth, OutputId, Workspace}; use crate::animation::Animation; use crate::utils::output_size; @@ -60,6 +61,13 @@ mod monitor; mod tile; mod workspace; +render_elements! { + #[derive(Debug)] + pub LayoutElementRenderElement where R: ImportAll; + Wayland = WaylandSurfaceRenderElement, + SolidColor = SolidColorRenderElement, +} + pub trait LayoutElement: PartialEq { /// Visual size of the element. /// @@ -86,7 +94,7 @@ pub trait LayoutElement: PartialEq { renderer: &mut R, location: Point, scale: Scale, - ) -> Vec> + ) -> Vec> where ::TextureId: 'static; @@ -224,7 +232,7 @@ impl LayoutElement for Window { renderer: &mut R, location: Point, scale: Scale, - ) -> Vec> + ) -> Vec> where ::TextureId: 'static, { @@ -1667,7 +1675,7 @@ mod tests { _renderer: &mut R, _location: Point, _scale: Scale, - ) -> Vec> { + ) -> Vec> { vec![] } -- cgit