use crate::backend::ButtonState;
use crate::backend::KeyState;
use crate::client::Client;
use crate::client::ClientId;
use crate::fixed::Fixed;
use crate::ifs::wl_output::TF_90;
use crate::ifs::wl_output::TF_180;
use crate::ifs::wl_output::TF_270;
use crate::ifs::wl_output::TF_FLIPPED;
use crate::ifs::wl_output::TF_FLIPPED_90;
use crate::ifs::wl_output::TF_FLIPPED_180;
use crate::ifs::wl_output::TF_FLIPPED_270;
use crate::ifs::wl_output::TF_NORMAL;
use crate::ifs::wl_seat::Dnd;
use crate::ifs::wl_seat::NodeSeatState;
use crate::ifs::wl_seat::WlSeatGlobal;
use crate::ifs::wl_seat::tablet::PadButtonState;
use crate::ifs::wl_seat::tablet::TabletPad;
use crate::ifs::wl_seat::tablet::TabletPadDial;
use crate::ifs::wl_seat::tablet::TabletPadGroup;
use crate::ifs::wl_seat::tablet::TabletPadRing;
use crate::ifs::wl_seat::tablet::TabletPadStrip;
use crate::ifs::wl_seat::tablet::TabletRingEventSource;
use crate::ifs::wl_seat::tablet::TabletStripEventSource;
use crate::ifs::wl_seat::tablet::TabletTool;
use crate::ifs::wl_seat::tablet::TabletToolChanges;
use crate::ifs::wl_seat::tablet::ToolButtonState;
use crate::ifs::wl_seat::wl_pointer::PendingScroll;
use crate::ifs::wl_surface::WlSurface;
use crate::ifs::wl_surface::tray::TrayItemId;
use crate::ifs::wl_surface::xdg_surface::xdg_popup::XdgPopup;
use crate::ifs::wl_surface::zwlr_layer_surface_v1::LayerSurfaceLink;
use crate::keyboard::KeyboardState;
use crate::rect::Rect;
use crate::renderer::Renderer;
use crate::tree::TreeTimeline::LiveTL;
use crate::tree::TreeTimeline::RenderTL;
use crate::utils::fuse::fuse_inode::FuseInodeExt;
use crate::utils::fuse::fuse_inode::FuseInodeWithKey;
use crate::utils::linkedlist::LinkedList;
use crate::utils::linkedlist::NodeRef;
use crate::utils::liveness::GetLiveness;
use crate::utils::numcell::NumCell;
use crate::utils::static_text::StaticText;
use crate::utils::type_view::TypeViewExt1;
use crate::wire::ObjectId;
pub use container::*;
pub use containing::*;
pub use display::*;
pub use float::*;
use jay_config::Direction as JayDirection;
use jay_config::video::Transform as ConfigTransform;
use jay_config::window::JcTileState;
use jay_config::workspace::WorkspaceDisplayOrder as ConfigWorkspaceDisplayOrder;
use linearize::Linearize;
use linearize::LinearizeExt;
use linearize::StaticMap;
use linearize::static_map;
pub use output::*;
pub use placeholder::*;
pub use stacked::*;
use std::cell::Cell;
use std::fmt::Debug;
use std::fmt::Display;
use std::ops::Deref;
use std::rc::Rc;
pub use toplevel::*;
pub use tree_dfs_g_fuse::NodeView;
pub use walker::*;
pub use workspace::*;
mod container;
mod containing;
mod display;
mod float;
mod output;
mod placeholder;
mod stacked;
mod toplevel;
mod tree_dfs_g_fuse;
mod walker;
mod workspace;
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Default, Linearize)]
pub enum WorkspaceDisplayOrder {
#[default]
Manual,
Sorted,
}
impl From<ConfigWorkspaceDisplayOrder> for WorkspaceDisplayOrder {
fn from(value: ConfigWorkspaceDisplayOrder) -> Self {
match value {
ConfigWorkspaceDisplayOrder::Manual => WorkspaceDisplayOrder::Manual,
ConfigWorkspaceDisplayOrder::Sorted => WorkspaceDisplayOrder::Sorted,
}
}
}
impl Into<ConfigWorkspaceDisplayOrder> for WorkspaceDisplayOrder {
fn into(self) -> ConfigWorkspaceDisplayOrder {
match self {
WorkspaceDisplayOrder::Manual => ConfigWorkspaceDisplayOrder::Manual,
WorkspaceDisplayOrder::Sorted => ConfigWorkspaceDisplayOrder::Sorted,
}
}
}
impl StaticText for WorkspaceDisplayOrder {
fn text(&self) -> &'static str {
match self {
WorkspaceDisplayOrder::Manual => "Manual",
WorkspaceDisplayOrder::Sorted => "Sorted",
}
}
}
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Default, Linearize)]
pub enum Transform {
#[default]
None,
Rotate90,
Rotate180,
Rotate270,
Flip,
FlipRotate90,
FlipRotate180,
FlipRotate270,
}
impl StaticText for Transform {
fn text(&self) -> &'static str {
match self {
Transform::None => "none",
Transform::Rotate90 => "rotate-90",
Transform::Rotate180 => "rotate-180",
Transform::Rotate270 => "rotate-270",
Transform::Flip => "flip",
Transform::FlipRotate90 => "flip-rotate-90",
Transform::FlipRotate180 => "flip-rotate-180",
Transform::FlipRotate270 => "flip-rotate-270",
}
}
}
impl From<ConfigTransform> for Transform {
fn from(value: ConfigTransform) -> Self {
match value {
ConfigTransform::None => Transform::None,
ConfigTransform::Rotate90 => Transform::Rotate90,
ConfigTransform::Rotate180 => Transform::Rotate180,
ConfigTransform::Rotate270 => Transform::Rotate270,
ConfigTransform::Flip => Transform::Flip,
ConfigTransform::FlipRotate90 => Transform::FlipRotate90,
ConfigTransform::FlipRotate180 => Transform::FlipRotate180,
ConfigTransform::FlipRotate270 => Transform::FlipRotate270,
}
}
}
impl Into<ConfigTransform> for Transform {
fn into(self) -> ConfigTransform {
match self {
Transform::None => ConfigTransform::None,
Transform::Rotate90 => ConfigTransform::Rotate90,
Transform::Rotate180 => ConfigTransform::Rotate180,
Transform::Rotate270 => ConfigTransform::Rotate270,
Transform::Flip => ConfigTransform::Flip,
Transform::FlipRotate90 => ConfigTransform::FlipRotate90,
Transform::FlipRotate180 => ConfigTransform::FlipRotate180,
Transform::FlipRotate270 => ConfigTransform::FlipRotate270,
}
}
}
impl Transform {
pub fn maybe_swap<T>(self, (left, right): (T, T)) -> (T, T) {
match self {
Self::None | Self::Rotate180 | Self::Flip | Self::FlipRotate180 => (left, right),
Self::Rotate90 | Self::Rotate270 | Self::FlipRotate90 | Self::FlipRotate270 => {
(right, left)
}
}
}
pub fn to_wl(self) -> i32 {
match self {
Self::None => TF_NORMAL,
Self::Rotate90 => TF_90,
Self::Rotate180 => TF_180,
Self::Rotate270 => TF_270,
Self::Flip => TF_FLIPPED,
Self::FlipRotate90 => TF_FLIPPED_90,
Self::FlipRotate180 => TF_FLIPPED_180,
Self::FlipRotate270 => TF_FLIPPED_270,
}
}
pub fn from_wl(wl: i32) -> Option<Self> {
let tf = match wl {
TF_NORMAL => Self::None,
TF_90 => Self::Rotate90,
TF_180 => Self::Rotate180,
TF_270 => Self::Rotate270,
TF_FLIPPED => Self::Flip,
TF_FLIPPED_90 => Self::FlipRotate90,
TF_FLIPPED_180 => Self::FlipRotate180,
TF_FLIPPED_270 => Self::FlipRotate270,
_ => return None,
};
Some(tf)
}
pub fn apply_point(self, width: i32, height: i32, (x, y): (i32, i32)) -> (i32, i32) {
match self {
Self::None => (x, y),
Self::Rotate90 => (y, height - x),
Self::Rotate180 => (width - x, height - y),
Self::Rotate270 => (width - y, x),
Self::Flip => (width - x, y),
Self::FlipRotate90 => (y, x),
Self::FlipRotate180 => (x, height - y),
Self::FlipRotate270 => (width - y, height - x),
}
}
fn inverse(self) -> Self {
match self {
Self::Rotate90 => Self::Rotate270,
Self::Rotate270 => Self::Rotate90,
_ => self,
}
}
}
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Linearize)]
pub enum TileState {
Tiled,
Floating,
}
impl From<JcTileState> for TileState {
fn from(value: JcTileState) -> Self {
match value {
JcTileState::Tiled => TileState::Tiled,
JcTileState::Floating => TileState::Floating,
}
}
}
impl Into<JcTileState> for TileState {
fn into(self) -> JcTileState {
match self {
TileState::Tiled => JcTileState::Tiled,
TileState::Floating => JcTileState::Floating,
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Direction {
Unspecified,
Left,
Down,
Up,
Right,
}
impl From<JayDirection> for Direction {
fn from(d: JayDirection) -> Self {
match d {
JayDirection::Left => Self::Left,
JayDirection::Down => Self::Down,
JayDirection::Up => Self::Up,
JayDirection::Right => Self::Right,
}
}
}
pub struct NodeIds {
next: NumCell<u32>,
}
impl Default for NodeIds {
fn default() -> Self {
Self {
next: NumCell::new(1),
}
}
}
impl NodeIds {
pub fn next<T: From<NodeId>>(&self) -> T {
NodeId(self.next.fetch_add(1)).into()
}
pub fn last(&self) -> u32 {
self.next.get() - 1
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub struct NodeId(pub u32);
impl NodeId {
pub fn raw(&self) -> u32 {
self.0
}
}
impl Display for NodeId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Display::fmt(&self.0, f)
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub enum FindTreeResult {
AcceptsInput,
Other,
}
impl FindTreeResult {
fn accepts_input(self) -> bool {
self == Self::AcceptsInput
}
}
#[derive(Copy, Clone)]
pub enum FindTreeUsecase {
None,
SelectToplevel,
SelectToplevelOrPopup,
SelectNormalWorkspace,
}
#[derive(Copy, Clone, PartialEq)]
pub enum NodeLocation {
Workspace(OutputNodeId, WorkspaceNodeId),
Output(OutputNodeId),
}
#[derive(Copy, Clone, Linearize, Eq, PartialEq, Debug)]
pub enum NodeLayer {
Display,
Layer0,
Layer1,
Output,
Workspace,
Tiled,
Fullscreen,
Stacked,
Layer2,
Layer3,
StackedAboveLayers,
Lock,
InputMethod,
Overlay,
OverlayTiled,
OverlayFullscreen,
OverlayStacked,
}
const NODE_LAYER_FIRST: NodeLayer = NodeLayer::Display;
const NODE_LAYER_LAST: NodeLayer = NodeLayer::OverlayStacked;
pub enum NodeLayerLink {
Display,
Layer0(NodeRef<LayerSurfaceLink>),
Layer1(NodeRef<LayerSurfaceLink>),
Output,
Workspace,
Tiled,
Fullscreen,
Stacked(NodeRef<Rc<dyn StackedNode>>),
Layer2(NodeRef<LayerSurfaceLink>),
Layer3(NodeRef<LayerSurfaceLink>),
StackedAboveLayers(NodeRef<Rc<dyn StackedNode>>),
Lock,
InputMethod,
Overlay,
OverlayTiled,
OverlayFullscreen,
OverlayStacked(NodeRef<Rc<dyn StackedNode>>),
}
impl NodeLayerLink {
pub fn layer(&self) -> NodeLayer {
macro_rules! map {
($($id:ident,)*) => {
match self {
$(
Self::$id { .. } => NodeLayer::$id,
)*
}
};
}
map! {
Display,
Layer0,
Layer1,
Output,
Workspace,
Tiled,
Fullscreen,
Stacked,
Layer2,
Layer3,
StackedAboveLayers,
Lock,
InputMethod,
Overlay,
OverlayTiled,
OverlayFullscreen,
OverlayStacked,
}
}
}
impl NodeLayer {
pub fn prev(self) -> Self {
if self == NODE_LAYER_FIRST {
return NODE_LAYER_LAST;
}
Self::from_linear(self.linearize() - 1).unwrap_or(NODE_LAYER_LAST)
}
pub fn next(self) -> Self {
Self::from_linear(self.linearize() + 1).unwrap_or(NODE_LAYER_FIRST)
}
}
impl StaticText for NodeLayer {
fn text(&self) -> &'static str {
match self {
NodeLayer::Display => "Display",
NodeLayer::Layer0 => "Layer0",
NodeLayer::Layer1 => "Layer1",
NodeLayer::Output => "Output",
NodeLayer::Workspace => "Workspace",
NodeLayer::Tiled => "Tiled",
NodeLayer::Fullscreen => "Fullscreen",
NodeLayer::Stacked => "Stacked",
NodeLayer::Layer2 => "Layer2",
NodeLayer::Layer3 => "Layer3",
NodeLayer::StackedAboveLayers => "StackedAboveLayers",
NodeLayer::Lock => "Lock",
NodeLayer::InputMethod => "InputMethod",
NodeLayer::Overlay => "Overlay",
NodeLayer::OverlayTiled => "OverlayTiled",
NodeLayer::OverlayFullscreen => "OverlayFullscreen",
NodeLayer::OverlayStacked => "OverlayStacked",
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum WorkspaceChangeReason {
InitialGrab,
OutputChanged,
}
linear_ids!(TreeSerials, TreeSerial, u64);
impl TreeSerial {
pub const NONE: Self = Self(0);
}
pub trait NodeBase: GetLiveness + 'static {
fn node_id(&self) -> NodeId;
fn node_seat_state(&self) -> &NodeSeatState;
fn node_visit(self: &Rc<Self>, visitor: &mut dyn NodeVisitor)
where
Self: Sized;
fn node_visit_children(&self, visitor: &mut dyn NodeVisitor);
fn node_visible(&self, tl: TreeTimeline) -> bool;
fn node_absolute_position(&self, tl: TreeTimeline) -> Rect;
fn node_output(&self) -> Option<Rc<OutputNode>>;
fn node_workspace(&self) -> Option<Rc<WorkspaceNode>>;
fn node_location(&self) -> Option<NodeLocation>;
fn node_layer(&self) -> NodeLayerLink;
fn node_output_id(&self) -> Option<OutputNodeId> {
self.node_output().map(|o| o.id)
}
fn node_debugfs(self: Rc<Self>) -> FuseInodeWithKey
where
Self: Sized,
{
if let Some(id) = self.node_object_id()
&& let Some(client) = self.node_client()
{
client.object_link(id)
} else {
self.tv_wrap_rc::<NodeView>().without_key()
}
}
fn node_child_title_changed(self: Rc<Self>, child: &dyn Node, title: &str) {
let _ = child;
let _ = title;
}
fn node_accepts_focus(&self) -> bool {
true
}
fn node_do_focus(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction)
where
Self: Sized,
{
let _ = seat;
let _ = direction;
}
fn node_active_changed(&self, active: bool) {
let _ = active;
}
fn node_find_tree_at(
&self,
x: i32,
y: i32,
tree: &mut Vec<FoundNode>,
usecase: FindTreeUsecase,
) -> FindTreeResult {
let _ = x;
let _ = y;
let _ = tree;
let _ = usecase;
FindTreeResult::Other
}
fn node_child_size_changed(self: Rc<Self>, child: &dyn Node, width: i32, height: i32) {
let _ = (child, width, height);
}
fn node_child_active_changed(self: Rc<Self>, child: &dyn Node, active: bool, depth: u32) {
let _ = (child, active, depth);
}
fn node_render(&self, renderer: &mut Renderer<'_>, x: i32, y: i32, bounds: Option<&Rect>) {
let _ = renderer;
let _ = x;
let _ = y;
let _ = bounds;
}
fn node_client(&self) -> Option<Rc<Client>> {
None
}
fn node_client_id(&self) -> Option<ClientId> {
self.node_client().map(|c| c.id)
}
fn node_object_id(&self) -> Option<ObjectId> {
None
}
fn node_toplevel(self: Rc<Self>) -> Option<Rc<dyn ToplevelNode>> {
None
}
fn node_tray_item(&self) -> Option<TrayItemId> {
None
}
fn node_make_visible(self: &Rc<Self>)
where
Self: Sized,
{
}
fn node_grab_workspace_changed(
self: Rc<Self>,
seat: &Rc<WlSeatGlobal>,
on: &Rc<OutputNode>,
ws: Option<&Rc<WorkspaceNode>>,
reason: WorkspaceChangeReason,
) {
let _ = seat;
let _ = on;
let _ = ws;
let _ = reason;
}
fn node_on_key(
&self,
seat: &WlSeatGlobal,
time_usec: u64,
key: u32,
state: KeyState,
kb_state: &KeyboardState,
) {
let _ = seat;
let _ = time_usec;
let _ = key;
let _ = state;
let _ = kb_state;
}
fn node_on_mods(&self, seat: &WlSeatGlobal, kb_state: &KeyboardState) {
let _ = seat;
let _ = kb_state;
}
fn node_on_touch_down(
self: Rc<Self>,
seat: &Rc<WlSeatGlobal>,
time_usec: u64,
id: i32,
x: Fixed,
y: Fixed,
) {
let _ = seat;
let _ = time_usec;
let _ = id;
let _ = x;
let _ = y;
}
fn node_on_touch_up(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, time_usec: u64, id: i32) {
let _ = seat;
let _ = time_usec;
let _ = id;
}
fn node_on_touch_motion(
self: Rc<Self>,
seat: &WlSeatGlobal,
time_usec: u64,
id: i32,
x: Fixed,
y: Fixed,
) {
let _ = seat;
let _ = time_usec;
let _ = id;
let _ = x;
let _ = y;
}
fn node_on_touch_frame(&self, seat: &WlSeatGlobal) {
let _ = seat;
}
fn node_on_touch_cancel(&self, seat: &WlSeatGlobal) {
let _ = seat;
}
fn node_on_button(
self: Rc<Self>,
seat: &Rc<WlSeatGlobal>,
time_usec: u64,
button: u32,
state: ButtonState,
serial: u64,
) {
let _ = seat;
let _ = time_usec;
let _ = button;
let _ = state;
let _ = serial;
}
fn node_on_axis_event(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, event: &PendingScroll) {
let _ = seat;
let _ = event;
}
fn node_on_focus(self: Rc<Self>, seat: &WlSeatGlobal) {
let _ = seat;
}
fn node_on_unfocus(&self, seat: &WlSeatGlobal) {
let _ = seat;
}
fn node_on_leave(&self, seat: &WlSeatGlobal) {
let _ = seat;
}
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
let _ = seat;
let _ = x;
let _ = y;
}
fn node_on_pointer_unfocus(&self, seat: &Rc<WlSeatGlobal>) {
let _ = seat;
}
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
let _ = seat;
}
fn node_on_pointer_motion(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
let _ = seat;
let _ = x;
let _ = y;
}
fn node_on_pointer_relative_motion(
&self,
seat: &Rc<WlSeatGlobal>,
time_usec: u64,
dx: Fixed,
dy: Fixed,
dx_unaccelerated: Fixed,
dy_unaccelerated: Fixed,
) {
let _ = seat;
let _ = time_usec;
let _ = dx;
let _ = dy;
let _ = dx_unaccelerated;
let _ = dy_unaccelerated;
}
fn node_on_dnd_drop(&self, dnd: &Dnd) {
let _ = dnd;
}
fn node_on_dnd_leave(&self, dnd: &Dnd) {
let _ = dnd;
}
fn node_on_dnd_enter(&self, dnd: &Dnd, x: Fixed, y: Fixed, serial: u64) {
let _ = dnd;
let _ = x;
let _ = y;
let _ = serial;
}
fn node_on_dnd_motion(&self, dnd: &Dnd, time_usec: u64, x: Fixed, y: Fixed) {
let _ = dnd;
let _ = time_usec;
let _ = x;
let _ = y;
}
fn node_on_swipe_begin(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, finger_count: u32) {
let _ = seat;
let _ = time_usec;
let _ = finger_count;
}
fn node_on_swipe_update(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, dx: Fixed, dy: Fixed) {
let _ = seat;
let _ = time_usec;
let _ = dx;
let _ = dy;
}
fn node_on_swipe_end(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, cancelled: bool) {
let _ = seat;
let _ = time_usec;
let _ = cancelled;
}
fn node_on_pinch_begin(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, finger_count: u32) {
let _ = seat;
let _ = time_usec;
let _ = finger_count;
}
fn node_on_pinch_update(
&self,
seat: &Rc<WlSeatGlobal>,
time_usec: u64,
dx: Fixed,
dy: Fixed,
scale: Fixed,
rotation: Fixed,
) {
let _ = seat;
let _ = time_usec;
let _ = dx;
let _ = dy;
let _ = scale;
let _ = rotation;
}
fn node_on_pinch_end(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, cancelled: bool) {
let _ = seat;
let _ = time_usec;
let _ = cancelled;
}
fn node_on_hold_begin(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, finger_count: u32) {
let _ = seat;
let _ = time_usec;
let _ = finger_count;
}
fn node_on_hold_end(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, cancelled: bool) {
let _ = seat;
let _ = time_usec;
let _ = cancelled;
}
fn node_on_tablet_pad_enter(&self, pad: &Rc<TabletPad>) {
let _ = pad;
}
fn node_on_tablet_pad_leave(&self, pad: &Rc<TabletPad>) {
let _ = pad;
}
fn node_on_tablet_pad_button(
&self,
pad: &Rc<TabletPad>,
time_usec: u64,
button: u32,
state: PadButtonState,
) {
let _ = pad;
let _ = time_usec;
let _ = button;
let _ = state;
}
fn node_on_tablet_pad_mode_switch(
&self,
pad: &Rc<TabletPad>,
group: &Rc<TabletPadGroup>,
time_usec: u64,
mode: u32,
) {
let _ = pad;
let _ = group;
let _ = time_usec;
let _ = mode;
}
fn node_on_tablet_pad_ring(
&self,
pad: &Rc<TabletPad>,
ring: &Rc<TabletPadRing>,
source: Option<TabletRingEventSource>,
angle: Option<f64>,
time_usec: u64,
) {
let _ = pad;
let _ = time_usec;
let _ = ring;
let _ = source;
let _ = angle;
}
fn node_on_tablet_pad_strip(
&self,
pad: &Rc<TabletPad>,
strip: &Rc<TabletPadStrip>,
source: Option<TabletStripEventSource>,
position: Option<f64>,
time_usec: u64,
) {
let _ = pad;
let _ = time_usec;
let _ = strip;
let _ = source;
let _ = position;
}
fn node_on_tablet_pad_dial(
&self,
pad: &Rc<TabletPad>,
dial: &Rc<TabletPadDial>,
value120: i32,
time_usec: u64,
) {
let _ = pad;
let _ = time_usec;
let _ = dial;
let _ = value120;
}
fn node_on_tablet_tool_leave(&self, tool: &Rc<TabletTool>, time_usec: u64) {
let _ = tool;
let _ = time_usec;
}
fn node_on_tablet_tool_enter(
self: Rc<Self>,
tool: &Rc<TabletTool>,
time_usec: u64,
x: Fixed,
y: Fixed,
) {
let _ = tool;
let _ = time_usec;
let _ = x;
let _ = y;
}
fn node_on_tablet_tool_button(
&self,
tool: &Rc<TabletTool>,
time_usec: u64,
button: u32,
state: ToolButtonState,
) {
let _ = tool;
let _ = time_usec;
let _ = button;
let _ = state;
}
fn node_on_tablet_tool_apply_changes(
self: Rc<Self>,
tool: &Rc<TabletTool>,
time_usec: u64,
changes: Option<&TabletToolChanges>,
x: Fixed,
y: Fixed,
) {
let _ = tool;
let _ = time_usec;
let _ = changes;
let _ = x;
let _ = y;
}
fn node_into_float(self: Rc<Self>) -> Option<Rc<FloatNode>> {
None
}
fn node_into_container(self: Rc<Self>) -> Option<Rc<ContainerNode>> {
None
}
fn node_into_workspace(self: Rc<Self>) -> Option<Rc<WorkspaceNode>> {
None
}
fn node_into_surface(self: Rc<Self>) -> Option<Rc<WlSurface>> {
None
}
fn node_into_containing_node(self: Rc<Self>) -> Option<Rc<dyn ContainingNode>> {
None
}
fn node_into_toplevel(self: Rc<Self>) -> Option<Rc<dyn ToplevelNode>> {
None
}
fn node_into_popup(self: Rc<Self>) -> Option<Rc<XdgPopup>> {
None
}
fn node_is_display(&self) -> bool {
false
}
fn node_is_container(&self) -> bool {
false
}
fn node_is_float(&self) -> bool {
false
}
fn node_is_workspace(&self) -> bool {
false
}
fn node_is_xwayland_surface(&self) -> bool {
false
}
fn node_is_placeholder(&self) -> bool {
false
}
}
pub trait Node: NodeBase {
fn node_visit_dyn(self: Rc<Self>, visitor: &mut dyn NodeVisitor);
fn node_do_focus_dyn(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction);
fn node_make_visible_dyn(self: Rc<Self>);
fn node_debugfs_dyn(self: Rc<Self>) -> FuseInodeWithKey;
}
impl<T> Node for T
where
T: NodeBase + Sized,
{
fn node_visit_dyn(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
self.node_visit(visitor);
}
fn node_do_focus_dyn(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
self.node_do_focus(seat, direction);
}
fn node_make_visible_dyn(self: Rc<Self>) {
self.node_make_visible();
}
fn node_debugfs_dyn(self: Rc<Self>) -> FuseInodeWithKey {
self.node_debugfs()
}
}
pub struct FoundNode {
pub node: Rc<dyn Node>,
pub x: i32,
pub y: i32,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Linearize)]
#[linearize(const)]
pub enum TreeTimeline {
LiveTL,
RenderTL,
}
pub type SplitView<T> = StaticMap<TreeTimeline, T>;
pub struct TreeLink<T> {
pub item: T,
valid: SplitView<Cell<bool>>,
}
impl<T> TreeLink<T> {
pub fn new(t: T) -> Self {
Self {
item: t,
valid: static_map! {
LiveTL => Cell::new(true),
RenderTL => Cell::new(false),
},
}
}
pub fn set_valid(&self) {
self.valid[RenderTL].set(true);
}
pub fn set_invalid(&self) {
self.valid[LiveTL].set(false);
}
}
impl<T> Deref for TreeLink<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.item
}
}
impl<T> NodeRef<TreeLink<T>> {
pub fn prev_valid(&self, tl: TreeTimeline) -> Option<Self> {
self.prev_with(|c| c.valid[tl].get())
}
pub fn next_valid(&self, tl: TreeTimeline) -> Option<Self> {
self.next_with(|c| c.valid[tl].get())
}
}
impl<T> LinkedList<TreeLink<T>> {
pub fn iter_valid(
&self,
tl: TreeTimeline,
) -> impl Iterator<Item = NodeRef<TreeLink<T>>> + use<T> {
self.iter().filter(move |c| c.valid[tl].get())
}
pub fn rev_iter_valid(
&self,
tl: TreeTimeline,
) -> impl Iterator<Item = NodeRef<TreeLink<T>>> + use<T> {
self.rev_iter().filter(move |c| c.valid[tl].get())
}
fn first_valid(&self, tl: TreeTimeline) -> Option<NodeRef<TreeLink<T>>> {
self.iter_valid(tl).next()
}
fn last_valid(&self, tl: TreeTimeline) -> Option<NodeRef<TreeLink<T>>> {
self.rev_iter_valid(tl).next()
}
}
#[derive(Copy, Clone)]
pub enum ContainerTarget {
Parent,
Itself,
Auto,
}
#[derive(Copy, Clone)]
pub enum RelativeAxis {
Major,
Minor,
}