mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
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.
This commit is contained in:
parent
4da976bfad
commit
5885679e33
9 changed files with 21 additions and 12 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue