diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index df3d00e8..7187359b 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -28,6 +28,7 @@ struct wlr_output_layout; enum wlr_scene_node_type { WLR_SCENE_NODE_ROOT, + WLR_SCENE_NODE_TREE, WLR_SCENE_NODE_SURFACE, WLR_SCENE_NODE_RECT, }; @@ -61,6 +62,11 @@ struct wlr_scene { struct wl_list outputs; // wlr_scene_output.link }; +/** A sub-tree in the scene-graph. */ +struct wlr_scene_tree { + struct wlr_scene_node node; +}; + /** A scene-graph node displaying a single surface. */ struct wlr_scene_surface { struct wlr_scene_node node; @@ -157,6 +163,11 @@ struct wlr_scene *wlr_scene_create(void); void wlr_scene_render_output(struct wlr_scene *scene, struct wlr_output *output, int lx, int ly, pixman_region32_t *damage); +/** + * Add a node displaying nothing but its children. + */ +struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_node *parent); + /** * Add a node displaying a single surface to the scene-graph. * diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 6a988e53..5d57504a 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -15,6 +15,11 @@ static struct wlr_scene *scene_root_from_node(struct wlr_scene_node *node) { return (struct wlr_scene *)node; } +static struct wlr_scene_tree *scene_tree_from_node(struct wlr_scene_node *node) { + assert(node->type == WLR_SCENE_NODE_TREE); + return (struct wlr_scene_tree *)node; +} + struct wlr_scene_surface *wlr_scene_surface_from_node( struct wlr_scene_node *node) { assert(node->type == WLR_SCENE_NODE_SURFACE); @@ -84,6 +89,10 @@ void wlr_scene_node_destroy(struct wlr_scene_node *node) { free(scene); break; + case WLR_SCENE_NODE_TREE:; + struct wlr_scene_tree *tree = scene_tree_from_node(node); + free(tree); + break; case WLR_SCENE_NODE_SURFACE:; struct wlr_scene_surface *scene_surface = wlr_scene_surface_from_node(node); wl_list_remove(&scene_surface->surface_destroy.link); @@ -106,6 +115,16 @@ struct wlr_scene *wlr_scene_create(void) { return scene; } +struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_node *parent) { + struct wlr_scene_tree *tree = calloc(1, sizeof(struct wlr_scene_tree)); + if (tree == NULL) { + return NULL; + } + scene_node_init(&tree->node, WLR_SCENE_NODE_TREE, parent); + + return tree; +} + static void scene_surface_handle_surface_destroy(struct wl_listener *listener, void *data) { struct wlr_scene_surface *scene_surface = @@ -246,6 +265,7 @@ static void _scene_node_damage_whole(struct wlr_scene_node *node, int width = 0, height = 0; switch (node->type) { case WLR_SCENE_NODE_ROOT: + case WLR_SCENE_NODE_TREE: return; case WLR_SCENE_NODE_SURFACE:; struct wlr_scene_surface *scene_surface = @@ -536,8 +556,9 @@ static void render_node_iterator(struct wlr_scene_node *node, }; switch (node->type) { - case WLR_SCENE_NODE_ROOT:; - /* Root node has nothing to render itself */ + case WLR_SCENE_NODE_ROOT: + case WLR_SCENE_NODE_TREE: + /* Root or tree node has nothing to render itself */ break; case WLR_SCENE_NODE_SURFACE:; struct wlr_scene_surface *scene_surface = wlr_scene_surface_from_node(node);