diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2017-08-19 09:26:25 +0200 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2017-08-19 09:31:06 +0200 |
commit | 5885679e33b4082e727fb55e1700b67159ec9d06 (patch) | |
tree | 2c1324c1ba15f46975c51ed6b473345e215e749d | |
parent | 4da976bfad9fb97a83fd67c52ce547fba880c9b1 (diff) |
examples: separate compositor_fini from run
compositor_fini destroys the display, but it is an error to destroy it
before e.g. wlr_seat that references it.
This lets us order destroy calls properly, following first-in-last-out
logic.
-rw-r--r-- | examples/compositor/main.c | 10 | ||||
-rw-r--r-- | examples/output-layout.c | 3 | ||||
-rw-r--r-- | examples/pointer.c | 3 | ||||
-rw-r--r-- | examples/rotation.c | 3 | ||||
-rw-r--r-- | examples/shared.c | 3 | ||||
-rw-r--r-- | examples/shared.h | 2 | ||||
-rw-r--r-- | examples/simple.c | 3 | ||||
-rw-r--r-- | examples/tablet.c | 3 | ||||
-rw-r--r-- | examples/touch.c | 3 |
9 files changed, 21 insertions, 12 deletions
diff --git a/examples/compositor/main.c b/examples/compositor/main.c index fdc4ed67..4c6e213d 100644 --- a/examples/compositor/main.c +++ b/examples/compositor/main.c @@ -178,9 +178,13 @@ int main() { break; } - compositor_run(&compositor); + wl_display_run(compositor.display); - wlr_wl_shell_destroy(state.wl_shell); - wlr_xdg_shell_v6_destroy(state.xdg_shell); close(state.keymap_fd); + wlr_seat_destroy(state.wl_seat); + wlr_data_device_manager_destroy(state.data_device_manager); + wlr_xdg_shell_v6_destroy(state.xdg_shell); + wlr_wl_shell_destroy(state.wl_shell); + wlr_renderer_destroy(state.renderer); + compositor_fini(&compositor); } diff --git a/examples/output-layout.c b/examples/output-layout.c index 565b21a6..0dcbc1f8 100644 --- a/examples/output-layout.c +++ b/examples/output-layout.c @@ -198,10 +198,11 @@ int main(int argc, char *argv[]) { wlr_texture_upload_pixels(state.cat_texture, WL_SHM_FORMAT_ABGR8888, cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data); - compositor_run(&compositor); + wl_display_run(compositor.display); wlr_texture_destroy(state.cat_texture); wlr_renderer_destroy(state.renderer); + compositor_fini(&compositor); wlr_output_layout_destroy(state.layout); diff --git a/examples/pointer.c b/examples/pointer.c index 1325a579..12253b62 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -146,7 +146,8 @@ int main(int argc, char *argv[]) { } compositor_init(&compositor); - compositor_run(&compositor); + wl_display_run(compositor.display); + compositor_fini(&compositor); wlr_xcursor_theme_destroy(theme); } diff --git a/examples/rotation.c b/examples/rotation.c index 28f82382..1dcbc80f 100644 --- a/examples/rotation.c +++ b/examples/rotation.c @@ -145,10 +145,11 @@ int main(int argc, char *argv[]) { wlr_texture_upload_pixels(state.cat_texture, WL_SHM_FORMAT_ABGR8888, cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data); - compositor_run(&compositor); + wl_display_run(compositor.display); wlr_texture_destroy(state.cat_texture); wlr_renderer_destroy(state.renderer); + compositor_fini(&compositor); example_config_destroy(state.config); } diff --git a/examples/shared.c b/examples/shared.c index 255652c7..f37140cf 100644 --- a/examples/shared.c +++ b/examples/shared.c @@ -674,8 +674,7 @@ void compositor_init(struct compositor_state *state) { } } -void compositor_run(struct compositor_state *state) { - wl_display_run(state->display); +void compositor_fini(struct compositor_state *state) { wlr_backend_destroy(state->backend); wl_display_destroy(state->display); } diff --git a/examples/shared.h b/examples/shared.h index 23b2d83d..d8007753 100644 --- a/examples/shared.h +++ b/examples/shared.h @@ -151,6 +151,6 @@ struct compositor_state { }; void compositor_init(struct compositor_state *state); -void compositor_run(struct compositor_state *state); +void compositor_fini(struct compositor_state *state); #endif diff --git a/examples/simple.c b/examples/simple.c index 8e098e18..7c3cc496 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -52,5 +52,6 @@ int main() { .output_frame_cb = handle_output_frame, }; compositor_init(&compositor); - compositor_run(&compositor); + wl_display_run(compositor.display); + compositor_fini(&compositor); } diff --git a/examples/tablet.c b/examples/tablet.c index f43fbc52..4aec5a72 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -158,7 +158,8 @@ int main(int argc, char *argv[]) { wlr_log(L_ERROR, "Could not start compositor, OOM"); exit(EXIT_FAILURE); } - compositor_run(&compositor); + wl_display_run(compositor.display); wlr_renderer_destroy(state.renderer); + compositor_fini(&compositor); } diff --git a/examples/touch.c b/examples/touch.c index 8df95e5b..7e8d9827 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -120,8 +120,9 @@ int main(int argc, char *argv[]) { wlr_texture_upload_pixels(state.cat_texture, WL_SHM_FORMAT_ARGB8888, cat_tex.width, cat_tex.width, cat_tex.height, cat_tex.pixel_data); - compositor_run(&compositor); + wl_display_run(compositor.display); wlr_texture_destroy(state.cat_texture); wlr_renderer_destroy(state.renderer); + compositor_fini(&compositor); } |