aboutsummaryrefslogtreecommitdiff
path: root/src/layout/mod.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-02-04 22:29:09 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-02-04 22:31:44 +0400
commitda826e42aaaa6dc559db67f4708db8bc23754f46 (patch)
treed4f91d3ac79e922d29b3cf917364649dd42378d7 /src/layout/mod.rs
parentb824cf90ab10f4ba5e1e0b23e0b2cf840814c02a (diff)
downloadniri-da826e42aaaa6dc559db67f4708db8bc23754f46.tar.gz
niri-da826e42aaaa6dc559db67f4708db8bc23754f46.tar.bz2
niri-da826e42aaaa6dc559db67f4708db8bc23754f46.zip
layout: Add LayoutElementRenderElement
Allows for testing layout rendering without Wayland windows.
Diffstat (limited to 'src/layout/mod.rs')
-rw-r--r--src/layout/mod.rs20
1 files changed, 14 insertions, 6 deletions
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<R> where R: ImportAll;
+ Wayland = WaylandSurfaceRenderElement<R>,
+ SolidColor = SolidColorRenderElement,
+}
+
pub trait LayoutElement: PartialEq {
/// Visual size of the element.
///
@@ -86,7 +94,7 @@ pub trait LayoutElement: PartialEq {
renderer: &mut R,
location: Point<i32, Logical>,
scale: Scale<f64>,
- ) -> Vec<WorkspaceRenderElement<R>>
+ ) -> Vec<LayoutElementRenderElement<R>>
where
<R as Renderer>::TextureId: 'static;
@@ -224,7 +232,7 @@ impl LayoutElement for Window {
renderer: &mut R,
location: Point<i32, Logical>,
scale: Scale<f64>,
- ) -> Vec<WorkspaceRenderElement<R>>
+ ) -> Vec<LayoutElementRenderElement<R>>
where
<R as Renderer>::TextureId: 'static,
{
@@ -1667,7 +1675,7 @@ mod tests {
_renderer: &mut R,
_location: Point<i32, Logical>,
_scale: Scale<f64>,
- ) -> Vec<WorkspaceRenderElement<R>> {
+ ) -> Vec<LayoutElementRenderElement<R>> {
vec![]
}