mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
layout: Add LayoutElementRenderElement
Allows for testing layout rendering without Wayland windows.
This commit is contained in:
+14
-6
@@ -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![]
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -244,7 +244,12 @@ impl<W: LayoutElement> Tile<W> {
|
||||
let mut rv = Vec::new();
|
||||
|
||||
let window_pos = location + self.window_loc();
|
||||
rv.extend(self.window.render(renderer, window_pos, scale));
|
||||
rv.extend(
|
||||
self.window
|
||||
.render(renderer, window_pos, scale)
|
||||
.into_iter()
|
||||
.map(Into::into),
|
||||
);
|
||||
|
||||
if self.effective_border_width().is_some() {
|
||||
rv.extend(
|
||||
|
||||
@@ -5,7 +5,6 @@ use std::rc::Rc;
|
||||
use std::time::Duration;
|
||||
|
||||
use niri_config::{CenterFocusedColumn, PresetWidth, SizeChange, Struts};
|
||||
use smithay::backend::renderer::element::surface::WaylandSurfaceRenderElement;
|
||||
use smithay::backend::renderer::element::utils::RelocateRenderElement;
|
||||
use smithay::backend::renderer::{ImportAll, Renderer};
|
||||
use smithay::desktop::space::SpaceElement;
|
||||
@@ -17,7 +16,7 @@ use smithay::utils::{Logical, Point, Rectangle, Scale, Size};
|
||||
|
||||
use super::focus_ring::{FocusRing, FocusRingRenderElement};
|
||||
use super::tile::Tile;
|
||||
use super::{LayoutElement, Options};
|
||||
use super::{LayoutElement, LayoutElementRenderElement, Options};
|
||||
use crate::animation::Animation;
|
||||
use crate::utils::output_size;
|
||||
|
||||
@@ -83,7 +82,7 @@ pub struct OutputId(String);
|
||||
render_elements! {
|
||||
#[derive(Debug)]
|
||||
pub WorkspaceRenderElement<R> where R: ImportAll;
|
||||
Wayland = WaylandSurfaceRenderElement<R>,
|
||||
LayoutElement = LayoutElementRenderElement<R>,
|
||||
FocusRing = FocusRingRenderElement,
|
||||
Border = RelocateRenderElement<FocusRingRenderElement>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user