~ruther/dwl

4c54bd811347b22038ec4a0285fe8d4e0622e0f0 — Guido Cella 2 months ago 2f3fe06
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.
1 files changed, 2 insertions(+), 12 deletions(-)

M dwl.c
M dwl.c => dwl.c +2 -12
@@ 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