1
0
Fork 0
forked from wry/wry

tree: add Node::node_location

This commit is contained in:
Julian Orth 2025-07-19 11:21:45 +02:00
parent f75051281b
commit 289c201a69
20 changed files with 152 additions and 45 deletions

View file

@ -21,8 +21,8 @@ use {
text::TextTexture,
tree::{
ContainingNode, Direction, FindTreeResult, FindTreeUsecase, FloatNode, FoundNode, Node,
NodeId, NodeVisitorBase, OutputNode, PlaceholderNode, StackedNode, ToplevelNode,
container::ContainerNode, walker::NodeVisitor,
NodeId, NodeLocation, NodeVisitorBase, OutputNode, OutputNodeId, PlaceholderNode,
StackedNode, ToplevelNode, container::ContainerNode, walker::NodeVisitor,
},
utils::{
clonecell::CloneCell,
@ -49,6 +49,7 @@ pub struct WorkspaceNode {
pub state: Rc<State>,
pub is_dummy: bool,
pub output: CloneCell<Rc<OutputNode>>,
pub output_id: Cell<OutputNodeId>,
pub position: Cell<Rect>,
pub container: CloneCell<Option<Rc<ContainerNode>>>,
pub stacked: LinkedList<Rc<dyn StackedNode>>,
@ -104,6 +105,7 @@ impl WorkspaceNode {
}
pub fn set_output(&self, output: &Rc<OutputNode>) {
self.output_id.set(output.id);
let old = self.output.set(output.clone());
for wh in self.ext_workspaces.lock().values() {
wh.handle_new_output(output);
@ -113,12 +115,13 @@ impl WorkspaceNode {
}
self.update_has_captures();
struct OutputSetter<'a> {
ws: &'a WorkspaceNode,
old: &'a Rc<OutputNode>,
new: &'a Rc<OutputNode>,
}
impl NodeVisitorBase for OutputSetter<'_> {
fn visit_surface(&mut self, node: &Rc<WlSurface>) {
node.set_output(self.new);
node.set_output(self.new, self.ws.location());
}
fn visit_container(&mut self, node: &Rc<ContainerNode>) {
@ -147,6 +150,7 @@ impl WorkspaceNode {
}
}
let mut visitor = OutputSetter {
ws: self,
old: &old,
new: output,
};
@ -273,6 +277,10 @@ impl WorkspaceNode {
self.output.get().schedule_update_render_data();
}
}
pub fn location(&self) -> NodeLocation {
NodeLocation::Workspace(self.output_id.get(), self.id)
}
}
impl Node for WorkspaceNode {
@ -309,6 +317,10 @@ impl Node for WorkspaceNode {
Some(self.output.get())
}
fn node_location(&self) -> Option<NodeLocation> {
Some(self.location())
}
fn node_do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
if let Some(fs) = self.fullscreen.get() {
fs.node_do_focus(seat, direction);