output: introduce wlr_output_finish()

This commit is contained in:
Kirill Primak 2024-11-22 23:21:08 +03:00 committed by Isaac Freund
parent 7963ba6a0d
commit d5d650f9f6
6 changed files with 22 additions and 7 deletions

View file

@ -1215,6 +1215,8 @@ static void dealloc_crtc(struct wlr_drm_connector *conn);
static void drm_connector_destroy_output(struct wlr_output *output) { static void drm_connector_destroy_output(struct wlr_output *output) {
struct wlr_drm_connector *conn = get_drm_connector_from_output(output); struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
wlr_output_finish(output);
dealloc_crtc(conn); dealloc_crtc(conn);
conn->status = DRM_MODE_DISCONNECTED; conn->status = DRM_MODE_DISCONNECTED;

View file

@ -80,8 +80,10 @@ static bool output_commit(struct wlr_output *wlr_output,
} }
static void output_destroy(struct wlr_output *wlr_output) { static void output_destroy(struct wlr_output *wlr_output) {
struct wlr_headless_output *output = struct wlr_headless_output *output = headless_output_from_output(wlr_output);
headless_output_from_output(wlr_output);
wlr_output_finish(wlr_output);
wl_list_remove(&output->link); wl_list_remove(&output->link);
wl_event_source_remove(output->frame_timer); wl_event_source_remove(output->frame_timer);
free(output); free(output);

View file

@ -933,6 +933,8 @@ static void output_destroy(struct wlr_output *wlr_output) {
return; return;
} }
wlr_output_finish(wlr_output);
wl_list_remove(&output->link); wl_list_remove(&output->link);
if (output->cursor.surface) { if (output->cursor.surface) {

View file

@ -94,6 +94,8 @@ static void output_destroy(struct wlr_output *wlr_output) {
struct wlr_x11_output *output = get_x11_output_from_output(wlr_output); struct wlr_x11_output *output = get_x11_output_from_output(wlr_output);
struct wlr_x11_backend *x11 = output->x11; struct wlr_x11_backend *x11 = output->x11;
wlr_output_finish(wlr_output);
pixman_region32_fini(&output->exposed); pixman_region32_fini(&output->exposed);
wlr_pointer_finish(&output->pointer); wlr_pointer_finish(&output->pointer);

View file

@ -108,6 +108,10 @@ struct wlr_output_impl {
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
const struct wlr_output_impl *impl, struct wl_event_loop *event_loop, const struct wlr_output_impl *impl, struct wl_event_loop *event_loop,
const struct wlr_output_state *state); const struct wlr_output_state *state);
/**
* Emit the destroy event and clean up common output state.
*/
void wlr_output_finish(struct wlr_output *output);
/** /**
* Notify compositors that they need to submit a new frame in order to apply * Notify compositors that they need to submit a new frame in order to apply
* output changes. * output changes.

View file

@ -375,11 +375,7 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
} }
} }
void wlr_output_destroy(struct wlr_output *output) { void wlr_output_finish(struct wlr_output *output) {
if (!output) {
return;
}
wl_signal_emit_mutable(&output->events.destroy, output); wl_signal_emit_mutable(&output->events.destroy, output);
wlr_output_destroy_global(output); wlr_output_destroy_global(output);
@ -418,10 +414,17 @@ void wlr_output_destroy(struct wlr_output *output) {
free(output->make); free(output->make);
free(output->model); free(output->model);
free(output->serial); free(output->serial);
}
void wlr_output_destroy(struct wlr_output *output) {
if (!output) {
return;
}
if (output->impl && output->impl->destroy) { if (output->impl && output->impl->destroy) {
output->impl->destroy(output); output->impl->destroy(output);
} else { } else {
wlr_output_finish(output);
free(output); free(output);
} }
} }