diff options
author | Alexander Orzechowski <alex@ozal.ski> | 2024-01-18 10:00:45 -0500 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2024-01-18 18:36:54 +0300 |
commit | 1eb16d136774c8fb3c9085df45156264f0db8814 (patch) | |
tree | 9c348ab37edae50b76a388d7e8d8dcd011cea33b /sway/tree/output.c | |
parent | view: init function should return a success bool (diff) | |
download | sway-1eb16d136774c8fb3c9085df45156264f0db8814.tar.gz sway-1eb16d136774c8fb3c9085df45156264f0db8814.tar.zst sway-1eb16d136774c8fb3c9085df45156264f0db8814.zip |
scene_graph: Maintain `wlr_scene_node`s for the sway tree.
Diffstat (limited to 'sway/tree/output.c')
-rw-r--r-- | sway/tree/output.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c index 2186ad0c..12a2f969 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c | |||
@@ -87,9 +87,41 @@ static void restore_workspaces(struct sway_output *output) { | |||
87 | output_sort_workspaces(output); | 87 | output_sort_workspaces(output); |
88 | } | 88 | } |
89 | 89 | ||
90 | static void destroy_scene_layers(struct sway_output *output) { | ||
91 | wlr_scene_node_destroy(&output->fullscreen_background->node); | ||
92 | |||
93 | scene_node_disown_children(output->layers.tiling); | ||
94 | scene_node_disown_children(output->layers.fullscreen); | ||
95 | |||
96 | wlr_scene_node_destroy(&output->layers.tiling->node); | ||
97 | wlr_scene_node_destroy(&output->layers.fullscreen->node); | ||
98 | } | ||
99 | |||
90 | struct sway_output *output_create(struct wlr_output *wlr_output) { | 100 | struct sway_output *output_create(struct wlr_output *wlr_output) { |
91 | struct sway_output *output = calloc(1, sizeof(struct sway_output)); | 101 | struct sway_output *output = calloc(1, sizeof(struct sway_output)); |
92 | node_init(&output->node, N_OUTPUT, output); | 102 | node_init(&output->node, N_OUTPUT, output); |
103 | |||
104 | bool failed = false; | ||
105 | output->layers.tiling = alloc_scene_tree(root->staging, &failed); | ||
106 | output->layers.fullscreen = alloc_scene_tree(root->staging, &failed); | ||
107 | |||
108 | if (!failed) { | ||
109 | output->fullscreen_background = wlr_scene_rect_create( | ||
110 | output->layers.fullscreen, 0, 0, (float[4]){0.f, 0.f, 0.f, 1.f}); | ||
111 | |||
112 | if (!output->fullscreen_background) { | ||
113 | sway_log(SWAY_ERROR, "Unable to allocate a background rect"); | ||
114 | failed = true; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | if (failed) { | ||
119 | destroy_scene_layers(output); | ||
120 | wlr_scene_output_destroy(output->scene_output); | ||
121 | free(output); | ||
122 | return NULL; | ||
123 | } | ||
124 | |||
93 | output->wlr_output = wlr_output; | 125 | output->wlr_output = wlr_output; |
94 | wlr_output->data = output; | 126 | wlr_output->data = output; |
95 | output->detected_subpixel = wlr_output->subpixel; | 127 | output->detected_subpixel = wlr_output->subpixel; |
@@ -238,6 +270,8 @@ void output_destroy(struct sway_output *output) { | |||
238 | "which is still referenced by transactions")) { | 270 | "which is still referenced by transactions")) { |
239 | return; | 271 | return; |
240 | } | 272 | } |
273 | |||
274 | destroy_scene_layers(output); | ||
241 | list_free(output->workspaces); | 275 | list_free(output->workspaces); |
242 | list_free(output->current.workspaces); | 276 | list_free(output->current.workspaces); |
243 | wl_event_source_remove(output->repaint_timer); | 277 | wl_event_source_remove(output->repaint_timer); |