From 5a004c3d3125121a1059819bca2dfa0d21a55d7e Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Sat, 19 Jul 2025 21:59:43 +0200 Subject: [PATCH] tree: add Node::node_accepts_focus --- src/ifs/wl_surface/x_surface/xwindow.rs | 4 ++++ src/ifs/wl_surface/zwlr_layer_surface_v1.rs | 4 ++++ src/tree.rs | 5 +++++ src/tree/float.rs | 7 +++++++ 4 files changed, 20 insertions(+) diff --git a/src/ifs/wl_surface/x_surface/xwindow.rs b/src/ifs/wl_surface/x_surface/xwindow.rs index 90b9b1c9..4c29833d 100644 --- a/src/ifs/wl_surface/x_surface/xwindow.rs +++ b/src/ifs/wl_surface/x_surface/xwindow.rs @@ -382,6 +382,10 @@ impl Node for Xwindow { self.toplevel_data.node_layer() } + fn node_accepts_focus(&self) -> bool { + self.tl_accepts_keyboard_focus() + } + fn node_do_focus(self: Rc, seat: &Rc, _direction: Direction) { seat.focus_toplevel(self.clone()); } diff --git a/src/ifs/wl_surface/zwlr_layer_surface_v1.rs b/src/ifs/wl_surface/zwlr_layer_surface_v1.rs index 98e9d890..9f8089a7 100644 --- a/src/ifs/wl_surface/zwlr_layer_surface_v1.rs +++ b/src/ifs/wl_surface/zwlr_layer_surface_v1.rs @@ -679,6 +679,10 @@ impl Node for ZwlrLayerSurfaceV1 { SurfaceExt::node_layer(self) } + fn node_accepts_focus(&self) -> bool { + self.keyboard_interactivity.get() != KI_NONE + } + fn node_find_tree_at( &self, x: i32, diff --git a/src/tree.rs b/src/tree.rs index 14c9d010..63fe4c88 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -216,6 +216,11 @@ pub trait Node: 'static { let _ = title; } + #[expect(dead_code)] + fn node_accepts_focus(&self) -> bool { + true + } + fn node_do_focus(self: Rc, seat: &Rc, direction: Direction) { let _ = seat; let _ = direction; diff --git a/src/tree/float.rs b/src/tree/float.rs index 36722a3d..15b3f6b1 100644 --- a/src/tree/float.rs +++ b/src/tree/float.rs @@ -720,6 +720,13 @@ impl Node for FloatNode { self.update_child_title(title); } + fn node_accepts_focus(&self) -> bool { + if let Some(c) = self.child.get() { + return c.tl_accepts_keyboard_focus(); + } + false + } + fn node_find_tree_at( &self, x: i32,