scene/output-layout: improve ownership logic

This commit ensures that outputs that weren't created by the output
layout helper aren't destroyed on the output layout change.

Consider the following piece of logic:

// struct wlr_output *o1, *o2;
// struct wlr_scene *scene;
// struct wlr_output_layout *layout;
wlr_scene_attach_output_layout(scene, layout);
wlr_output_layout_add_auto(layout, o1);
struct wlr_scene_output *so2 = wlr_scene_output_create(scene, o2);
wlr_output_layout_move(layout, o1, 100, 200);
// so2 is invalid now
This commit is contained in:
Kirill Primak 2022-05-31 21:40:03 +03:00 committed by Isaac Freund
parent d3bc17d5d1
commit 0c2eed533e
2 changed files with 80 additions and 36 deletions

View file

@ -406,8 +406,10 @@ struct wlr_scene_output *wlr_scene_get_scene_output(struct wlr_scene *scene,
/**
* Attach an output layout to a scene.
*
* Outputs in the output layout are automatically added to the scene. Any
* change to the output layout is mirrored to the scene-graph outputs.
* Adding, removing, or repositioning an output in the output layout
* will respectively add, remove or reposition a corresponding
* scene-graph output. When the output layout is destroyed, scene-graph
* outputs which were created by this helper will be destroyed.
*/
bool wlr_scene_attach_output_layout(struct wlr_scene *scene,
struct wlr_output_layout *output_layout);