Listen to display destroy in output

This commit is contained in:
emersion 2017-12-07 01:12:04 +01:00
parent cbf5763c22
commit 0e066f0d76
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 13 additions and 0 deletions

View File

@ -74,6 +74,8 @@ struct wlr_output {
// the output position in layout space reported to clients
int32_t lx, ly;
struct wl_listener display_destroy;
void *data;
};

View File

@ -112,6 +112,12 @@ static void wl_output_bind(struct wl_client *wl_client, void *data,
wl_output_send_to_resource(wl_resource);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_output *output =
wl_container_of(listener, output, display_destroy);
wlr_output_destroy_global(output);
}
struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output,
struct wl_display *display) {
if (wlr_output->wl_global != NULL) {
@ -120,6 +126,10 @@ struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output,
struct wl_global *wl_global = wl_global_create(display,
&wl_output_interface, 3, wlr_output, wl_output_bind);
wlr_output->wl_global = wl_global;
wlr_output->display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &wlr_output->display_destroy);
return wl_global;
}
@ -127,6 +137,7 @@ void wlr_output_destroy_global(struct wlr_output *wlr_output) {
if (wlr_output->wl_global == NULL) {
return;
}
wl_list_remove(&wlr_output->display_destroy.link);
struct wl_resource *resource, *tmp;
wl_resource_for_each_safe(resource, tmp, &wlr_output->wl_resources) {
struct wl_list *link = wl_resource_get_link(resource);