Added a method of optionally clipping wlr_scene_tree children

The two primary use-cases that I have in mind:
- Ensuring that layer surfaces don't spill over to adjacent outputs
- Clipping workspace translation animations to a single output
This commit is contained in:
Erik Reider 2026-02-24 20:08:52 +01:00
parent 7ccef7d9eb
commit 1cfad083a4
2 changed files with 86 additions and 8 deletions

View file

@ -92,6 +92,11 @@ struct wlr_scene_tree {
struct wlr_scene_node node;
struct wl_list children; // wlr_scene_node.link
struct {
// The clipping region in the tree nodes-local coordinate space
struct wlr_box clip;
} WLR_PRIVATE;
};
/** The root scene-graph node. */
@ -386,6 +391,17 @@ void wlr_scene_set_color_manager_v1(struct wlr_scene *scene, struct wlr_color_ma
*/
struct wlr_scene_tree *wlr_scene_tree_create(struct wlr_scene_tree *parent);
/**
* Sets a cropping region for any nodes that are children of this scene tree.
* Note that clip boxes cascade down the tree, as in the clip boxes are
* intersected with each other from the root to the leaves.
* The clip coordinate space will be that of the tree node.
*
* A NULL or empty clip will disable clipping.
*/
void wlr_scene_tree_set_clip(struct wlr_scene_tree *tree,
const struct wlr_box *clip);
/**
* Add a node displaying a single surface to the scene-graph.
*