From 4c54bd811347b22038ec4a0285fe8d4e0622e0f0 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Fri, 11 Sep 2026 23:08:32 +0200 Subject: [PATCH] implement xytonode() with toplevel_from_wlr_surface() xytonode() does not return the layer surface under the cursor because pnode->data is always NULL. It was not noticed because it is not passed the LayerSurface argument anywhere. But it is noticeable after implementing layer shell on-demand keyboard interactivity because layer shell surfaces are never focused by sloppyfocus. Rather than figuring out how to fix it, just replace its implementation with toplevel_from_wlr_surface() which works and also reduces the SLOC. --- dwl.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/dwl.c b/dwl.c index 1e7b9e9..7b8e55a 100644 --- a/dwl.c +++ b/dwl.c @@ -3049,10 +3049,8 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc, LayerSurface **pl, double *nx, double *ny) { - struct wlr_scene_node *node, *pnode; + struct wlr_scene_node *node; struct wlr_surface *surface = NULL; - Client *c = NULL; - LayerSurface *l = NULL; int layer; for (layer = NUM_LAYERS - 1; !surface && layer >= 0; layer--) { @@ -3063,18 +3061,10 @@ xytonode(double x, double y, struct wlr_surface **psurface, if (node->type == WLR_SCENE_NODE_BUFFER) surface = wlr_scene_surface_try_from_buffer( wlr_scene_buffer_from_node(node))->surface; - /* Walk the tree to find a node that knows the client */ - for (pnode = node; pnode && !c; pnode = &pnode->parent->node) - c = pnode->data; - if (c && c->type == LayerShell) { - c = NULL; - l = pnode->data; - } } if (psurface) *psurface = surface; - if (pc) *pc = c; - if (pl) *pl = l; + toplevel_from_wlr_surface(surface, pc, pl); } void