From c034ea7604c9b3713b58d41b6cecd09203201bd9 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Sat, 19 Jul 2025 22:00:32 +0200 Subject: [PATCH] tree: implement Node::node_accepts_focus for more nodes --- src/ifs/wl_surface/xdg_surface/xdg_popup.rs | 8 ++++++-- src/ifs/wl_surface/zwlr_layer_surface_v1.rs | 10 +++++++--- src/tree/float.rs | 6 ++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs index dedf8585..d70f8236 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs @@ -19,8 +19,8 @@ use { rect::Rect, renderer::Renderer, tree::{ - FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeLayerLink, NodeLocation, - NodeVisitor, OutputNode, StackedNode, + Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeLayerLink, + NodeLocation, NodeVisitor, OutputNode, StackedNode, }, utils::clonecell::CloneCell, wire::{XdgPopupId, xdg_popup::*}, @@ -329,6 +329,10 @@ impl Node for XdgPopup { XdgSurfaceExt::node_layer(self) } + fn node_do_focus(self: Rc, seat: &Rc, _direction: Direction) { + seat.focus_node(self.xdg.surface.clone()); + } + fn node_find_tree_at( &self, x: i32, diff --git a/src/ifs/wl_surface/zwlr_layer_surface_v1.rs b/src/ifs/wl_surface/zwlr_layer_surface_v1.rs index 9f8089a7..aa8a9bf2 100644 --- a/src/ifs/wl_surface/zwlr_layer_surface_v1.rs +++ b/src/ifs/wl_surface/zwlr_layer_surface_v1.rs @@ -3,7 +3,7 @@ use { client::{Client, ClientError}, ifs::{ wl_output::OutputGlobalOpt, - wl_seat::NodeSeatState, + wl_seat::{NodeSeatState, WlSeatGlobal}, wl_surface::{ PendingState, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError, xdg_surface::xdg_popup::{XdgPopup, XdgPopupParent}, @@ -15,8 +15,8 @@ use { rect::Rect, renderer::Renderer, tree::{ - FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeLayerLink, NodeLocation, - NodeVisitor, OutputNode, StackedNode, + Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeLayerLink, + NodeLocation, NodeVisitor, OutputNode, StackedNode, }, utils::{ bitflags::BitflagsExt, @@ -683,6 +683,10 @@ impl Node for ZwlrLayerSurfaceV1 { self.keyboard_interactivity.get() != KI_NONE } + fn node_do_focus(self: Rc, seat: &Rc, _direction: Direction) { + seat.focus_node(self.surface.clone()) + } + fn node_find_tree_at( &self, x: i32, diff --git a/src/tree/float.rs b/src/tree/float.rs index 15b3f6b1..63a63e23 100644 --- a/src/tree/float.rs +++ b/src/tree/float.rs @@ -727,6 +727,12 @@ impl Node for FloatNode { false } + fn node_do_focus(self: Rc, seat: &Rc, direction: Direction) { + if let Some(c) = self.child.get() { + c.node_do_focus(seat, direction); + } + } + fn node_find_tree_at( &self, x: i32,