1
0
Fork 0
forked from wry/wry

autocommit 2022-04-07 17:31:31 CEST

This commit is contained in:
Julian Orth 2022-04-07 17:31:31 +02:00
parent 1d33088dba
commit be32036824
200 changed files with 3267 additions and 2479 deletions

View file

@ -1,31 +1,31 @@
use crate::backend::{ConnectorId, KeyState, ScrollAxis};
use crate::client::{Client, ClientId};
use crate::cursor::KnownCursor;
use crate::fixed::Fixed;
use crate::ifs::wl_seat::{Dnd, NodeSeatState, WlSeatGlobal};
use crate::ifs::wl_surface::xwindow::Xwindow;
use crate::ifs::wl_surface::WlSurface;
use crate::rect::Rect;
use crate::render::Renderer;
use crate::tree::walker::NodeVisitor;
use crate::utils::copyhashmap::CopyHashMap;
use crate::utils::linkedlist::LinkedList;
use crate::utils::numcell::NumCell;
use crate::xkbcommon::ModifierState;
pub use container::*;
pub use float::*;
use jay_config::Direction;
pub use output::*;
use std::fmt::{Debug, Display};
use std::ops::Deref;
use std::rc::Rc;
pub use workspace::*;
use {
crate::{
backend::{KeyState, ScrollAxis},
client::{Client, ClientId},
fixed::Fixed,
ifs::{
wl_seat::{Dnd, NodeSeatState, WlSeatGlobal},
wl_surface::WlSurface,
},
rect::Rect,
render::Renderer,
utils::numcell::NumCell,
xkbcommon::ModifierState,
},
jay_config::Direction,
std::{
fmt::{Debug, Display},
rc::Rc,
},
};
pub use {container::*, display::*, float::*, output::*, toplevel::*, walker::*, workspace::*};
mod container;
mod display;
mod float;
mod output;
pub mod toplevel;
pub mod walker;
mod toplevel;
mod walker;
mod workspace;
pub struct NodeIds {
@ -62,6 +62,7 @@ impl Display for NodeId {
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub enum FindTreeResult {
AcceptsInput,
Other,
@ -351,105 +352,3 @@ pub struct FoundNode {
pub x: i32,
pub y: i32,
}
tree_id!(ToplevelNodeId);
pub struct DisplayNode {
pub id: NodeId,
pub outputs: CopyHashMap<ConnectorId, Rc<OutputNode>>,
pub stacked: LinkedList<Rc<dyn Node>>,
pub xstacked: LinkedList<Rc<Xwindow>>,
pub seat_state: NodeSeatState,
}
impl DisplayNode {
pub fn new(id: NodeId) -> Self {
Self {
id,
outputs: Default::default(),
stacked: Default::default(),
xstacked: Default::default(),
seat_state: Default::default(),
}
}
}
impl Node for DisplayNode {
fn id(&self) -> NodeId {
self.id
}
fn seat_state(&self) -> &NodeSeatState {
&self.seat_state
}
fn destroy_node(&self, _detach: bool) {
let mut outputs = self.outputs.lock();
for output in outputs.values() {
output.destroy_node(false);
}
outputs.clear();
for stacked in self.stacked.iter() {
stacked.destroy_node(false);
}
self.seat_state.destroy_node(self);
}
fn visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor) {
visitor.visit_display(&self);
}
fn visit_children(&self, visitor: &mut dyn NodeVisitor) {
let outputs = self.outputs.lock();
for (_, output) in outputs.deref() {
visitor.visit_output(output);
}
for stacked in self.stacked.iter() {
stacked.deref().clone().visit(visitor);
}
}
fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
for stacked in self.stacked.rev_iter() {
let ext = stacked.absolute_position();
if stacked.absolute_position_constrains_input() && !ext.contains(x, y) {
// TODO: make constrain always true
continue;
}
let (x, y) = ext.translate(x, y);
let idx = tree.len();
tree.push(FoundNode {
node: stacked.deref().clone(),
x,
y,
});
match stacked.find_tree_at(x, y, tree) {
FindTreeResult::AcceptsInput => {
return FindTreeResult::AcceptsInput;
}
FindTreeResult::Other => {
tree.drain(idx..);
}
}
}
let outputs = self.outputs.lock();
for output in outputs.values() {
let pos = output.global.pos.get();
if pos.contains(x, y) {
let (x, y) = pos.translate(x, y);
tree.push(FoundNode {
node: output.clone(),
x,
y,
});
output.find_tree_at(x, y, tree);
break;
}
}
FindTreeResult::AcceptsInput
}
fn pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
seat.set_known_cursor(KnownCursor::Default);
}
}