mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 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 std::time::Duration;
|
||||||
|
|
||||||
use niri_config::{self, CenterFocusedColumn, Config, SizeChange, Struts};
|
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::element::AsRenderElements;
|
||||||
use smithay::backend::renderer::{ImportAll, Renderer};
|
use smithay::backend::renderer::{ImportAll, Renderer};
|
||||||
use smithay::desktop::space::SpaceElement;
|
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::decoration::zv1::server::zxdg_toplevel_decoration_v1;
|
||||||
use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;
|
use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;
|
||||||
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
|
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
|
||||||
|
use smithay::render_elements;
|
||||||
use smithay::utils::{Logical, Point, Rectangle, Scale, Size, Transform};
|
use smithay::utils::{Logical, Point, Rectangle, Scale, Size, Transform};
|
||||||
use smithay::wayland::compositor::{send_surface_state, with_states};
|
use smithay::wayland::compositor::{send_surface_state, with_states};
|
||||||
use smithay::wayland::shell::xdg::SurfaceCachedState;
|
use smithay::wayland::shell::xdg::SurfaceCachedState;
|
||||||
|
|
||||||
pub use self::monitor::MonitorRenderElement;
|
pub use self::monitor::MonitorRenderElement;
|
||||||
use self::monitor::{Monitor, WorkspaceSwitch, WorkspaceSwitchGesture};
|
use self::monitor::{Monitor, WorkspaceSwitch, WorkspaceSwitchGesture};
|
||||||
use self::workspace::{
|
use self::workspace::{compute_working_area, Column, ColumnWidth, OutputId, Workspace};
|
||||||
compute_working_area, Column, ColumnWidth, OutputId, Workspace, WorkspaceRenderElement,
|
|
||||||
};
|
|
||||||
use crate::animation::Animation;
|
use crate::animation::Animation;
|
||||||
use crate::utils::output_size;
|
use crate::utils::output_size;
|
||||||
|
|
||||||
@@ -60,6 +61,13 @@ mod monitor;
|
|||||||
mod tile;
|
mod tile;
|
||||||
mod workspace;
|
mod workspace;
|
||||||
|
|
||||||
|
render_elements! {
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub LayoutElementRenderElement<R> where R: ImportAll;
|
||||||
|
Wayland = WaylandSurfaceRenderElement<R>,
|
||||||
|
SolidColor = SolidColorRenderElement,
|
||||||
|
}
|
||||||
|
|
||||||
pub trait LayoutElement: PartialEq {
|
pub trait LayoutElement: PartialEq {
|
||||||
/// Visual size of the element.
|
/// Visual size of the element.
|
||||||
///
|
///
|
||||||
@@ -86,7 +94,7 @@ pub trait LayoutElement: PartialEq {
|
|||||||
renderer: &mut R,
|
renderer: &mut R,
|
||||||
location: Point<i32, Logical>,
|
location: Point<i32, Logical>,
|
||||||
scale: Scale<f64>,
|
scale: Scale<f64>,
|
||||||
) -> Vec<WorkspaceRenderElement<R>>
|
) -> Vec<LayoutElementRenderElement<R>>
|
||||||
where
|
where
|
||||||
<R as Renderer>::TextureId: 'static;
|
<R as Renderer>::TextureId: 'static;
|
||||||
|
|
||||||
@@ -224,7 +232,7 @@ impl LayoutElement for Window {
|
|||||||
renderer: &mut R,
|
renderer: &mut R,
|
||||||
location: Point<i32, Logical>,
|
location: Point<i32, Logical>,
|
||||||
scale: Scale<f64>,
|
scale: Scale<f64>,
|
||||||
) -> Vec<WorkspaceRenderElement<R>>
|
) -> Vec<LayoutElementRenderElement<R>>
|
||||||
where
|
where
|
||||||
<R as Renderer>::TextureId: 'static,
|
<R as Renderer>::TextureId: 'static,
|
||||||
{
|
{
|
||||||
@@ -1667,7 +1675,7 @@ mod tests {
|
|||||||
_renderer: &mut R,
|
_renderer: &mut R,
|
||||||
_location: Point<i32, Logical>,
|
_location: Point<i32, Logical>,
|
||||||
_scale: Scale<f64>,
|
_scale: Scale<f64>,
|
||||||
) -> Vec<WorkspaceRenderElement<R>> {
|
) -> Vec<LayoutElementRenderElement<R>> {
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -244,7 +244,12 @@ impl<W: LayoutElement> Tile<W> {
|
|||||||
let mut rv = Vec::new();
|
let mut rv = Vec::new();
|
||||||
|
|
||||||
let window_pos = location + self.window_loc();
|
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() {
|
if self.effective_border_width().is_some() {
|
||||||
rv.extend(
|
rv.extend(
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ use std::rc::Rc;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use niri_config::{CenterFocusedColumn, PresetWidth, SizeChange, Struts};
|
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::element::utils::RelocateRenderElement;
|
||||||
use smithay::backend::renderer::{ImportAll, Renderer};
|
use smithay::backend::renderer::{ImportAll, Renderer};
|
||||||
use smithay::desktop::space::SpaceElement;
|
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::focus_ring::{FocusRing, FocusRingRenderElement};
|
||||||
use super::tile::Tile;
|
use super::tile::Tile;
|
||||||
use super::{LayoutElement, Options};
|
use super::{LayoutElement, LayoutElementRenderElement, Options};
|
||||||
use crate::animation::Animation;
|
use crate::animation::Animation;
|
||||||
use crate::utils::output_size;
|
use crate::utils::output_size;
|
||||||
|
|
||||||
@@ -83,7 +82,7 @@ pub struct OutputId(String);
|
|||||||
render_elements! {
|
render_elements! {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub WorkspaceRenderElement<R> where R: ImportAll;
|
pub WorkspaceRenderElement<R> where R: ImportAll;
|
||||||
Wayland = WaylandSurfaceRenderElement<R>,
|
LayoutElement = LayoutElementRenderElement<R>,
|
||||||
FocusRing = FocusRingRenderElement,
|
FocusRing = FocusRingRenderElement,
|
||||||
Border = RelocateRenderElement<FocusRingRenderElement>,
|
Border = RelocateRenderElement<FocusRingRenderElement>,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user