improve xdg + layer shell support

This commit is contained in:
DanyLE
2024-04-01 15:38:57 +02:00
parent 55719d6dba
commit a54dcb682c
13 changed files with 355 additions and 141 deletions

30
node.c
View File

@ -34,4 +34,34 @@ struct diyac_view *diyac_view_from_node(struct wlr_scene_node *wlr_scene_node)
struct diyac_node_descriptor *node_descriptor = wlr_scene_node->data;
assert(node_descriptor->type == DIYAC_NODE_VIEW || node_descriptor->type == DIYAC_NODE_XDG_POPUP);
return (struct diyac_view *)node_descriptor->data;
}
struct diyac_node_descriptor * diyac_node_at(struct diyac_server* server, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy)
{
/* This returns the topmost node in the scene at the given layout coords.
* We only care about surface nodes as we are specifically looking for a
* surface in the surface tree of a diyac_view. */
struct wlr_scene_node *node = wlr_scene_node_at(
&server->scene->tree.node, lx, ly, sx, sy);
if (node == NULL || node->type != WLR_SCENE_NODE_BUFFER)
{
return NULL;
}
struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node);
struct wlr_scene_surface *scene_surface =
wlr_scene_surface_try_from_buffer(scene_buffer);
if (!scene_surface)
{
return NULL;
}
*surface = scene_surface->surface;
/* Find the node corresponding to the diyac_view at the root of this
* surface tree, it is the only one for which we set the data field. */
struct wlr_scene_tree *tree = node->parent;
while (tree != NULL && tree->node.data == NULL)
{
tree = tree->node.parent;
}
return tree->node.data;
}