mirror of
https://github.com/swaywm/sway.git
synced 2024-11-28 02:41:28 +00:00
scene_descriptor: Add scene_descriptor_find
This commit is contained in:
parent
d3f0929f79
commit
1a9b3ce0d0
|
@ -38,4 +38,14 @@ void *scene_descriptor_try_get(struct wlr_scene_node *node,
|
|||
void scene_descriptor_destroy(struct wlr_scene_node *node,
|
||||
enum sway_scene_descriptor_type type);
|
||||
|
||||
/*
|
||||
* Searches the scene node and all its parents for this scene descriptor.
|
||||
*
|
||||
* Note that while searching, SWAY_SCENE_DESC_POPUP types will start tracking
|
||||
* its relative node. With popups, they are part of a seperate layer in the scene
|
||||
* graph, but that's irrelavent to users of this function.
|
||||
*/
|
||||
void *scene_descriptor_find(struct wlr_scene_node *node,
|
||||
enum sway_scene_descriptor_type type);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,6 +36,31 @@ void *scene_descriptor_try_get(struct wlr_scene_node *node,
|
|||
return desc->data;
|
||||
}
|
||||
|
||||
void *scene_descriptor_find(struct wlr_scene_node *node,
|
||||
enum sway_scene_descriptor_type type) {
|
||||
while (node) {
|
||||
struct scene_descriptor *desc = scene_node_get_descriptor(node, type);
|
||||
if (desc) {
|
||||
return desc->data;
|
||||
}
|
||||
|
||||
struct sway_popup_desc *popup =
|
||||
scene_descriptor_try_get(node, SWAY_SCENE_DESC_POPUP);
|
||||
if (popup) {
|
||||
node = popup->relative;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!node->parent) {
|
||||
break;
|
||||
}
|
||||
|
||||
node = &node->parent->node;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void scene_descriptor_destroy(struct wlr_scene_node *node,
|
||||
enum sway_scene_descriptor_type type) {
|
||||
struct scene_descriptor *desc = scene_node_get_descriptor(node, type);
|
||||
|
|
Loading…
Reference in a new issue