Remove display destroy listeners, add compositor listener

This commit is contained in:
emersion 2017-12-07 00:44:45 +01:00
parent 32591d66d6
commit e6d2e72401
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
4 changed files with 19 additions and 6 deletions

View File

@ -9,7 +9,8 @@ struct wlr_compositor {
struct wl_list wl_resources; struct wl_list wl_resources;
struct wlr_renderer *renderer; struct wlr_renderer *renderer;
struct wl_list surfaces; struct wl_list surfaces;
struct wl_listener destroy_surface_listener;
struct wl_listener display_destroy;
struct { struct {
struct wl_signal create_surface; struct wl_signal create_surface;
@ -20,8 +21,4 @@ void wlr_compositor_destroy(struct wlr_compositor *wlr_compositor);
struct wlr_compositor *wlr_compositor_create(struct wl_display *display, struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
struct wlr_renderer *renderer); struct wlr_renderer *renderer);
struct wlr_surface;
void wl_compositor_surface_destroyed(struct wlr_compositor *wlr_compositor,
struct wlr_surface *surface);
#endif #endif

View File

@ -78,6 +78,7 @@ static void wl_compositor_bind(struct wl_client *wl_client, void *data,
} }
void wlr_compositor_destroy(struct wlr_compositor *compositor) { void wlr_compositor_destroy(struct wlr_compositor *compositor) {
wl_list_remove(&compositor->display_destroy.link);
wl_global_destroy(compositor->wl_global); wl_global_destroy(compositor->wl_global);
free(compositor); free(compositor);
} }
@ -151,6 +152,12 @@ static void subcompositor_bind(struct wl_client *client, void *data,
compositor, NULL); compositor, NULL);
} }
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_compositor *compositor =
wl_container_of(listener, compositor, display_destroy);
wlr_compositor_destroy(compositor);
}
struct wlr_compositor *wlr_compositor_create(struct wl_display *display, struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
struct wlr_renderer *renderer) { struct wlr_renderer *renderer) {
struct wlr_compositor *compositor = struct wlr_compositor *compositor =
@ -162,7 +169,11 @@ struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
struct wl_global *compositor_global = wl_global_create(display, struct wl_global *compositor_global = wl_global_create(display,
&wl_compositor_interface, 4, compositor, wl_compositor_bind); &wl_compositor_interface, 4, compositor, wl_compositor_bind);
if (!compositor_global) {
wlr_log_errno(L_ERROR, "Could not allocate compositor global");
free(compositor);
return NULL;
}
compositor->wl_global = compositor_global; compositor->wl_global = compositor_global;
compositor->renderer = renderer; compositor->renderer = renderer;
@ -173,5 +184,8 @@ struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
wl_list_init(&compositor->surfaces); wl_list_init(&compositor->surfaces);
wl_signal_init(&compositor->events.create_surface); wl_signal_init(&compositor->events.create_surface);
compositor->display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &compositor->display_destroy);
return compositor; return compositor;
} }

View File

@ -165,6 +165,7 @@ void wlr_screenshooter_destroy(struct wlr_screenshooter *screenshooter) {
return; return;
} }
wl_signal_emit(&screenshooter->events.destroy, screenshooter); wl_signal_emit(&screenshooter->events.destroy, screenshooter);
wl_list_remove(&screenshooter->display_destroy.link);
struct wlr_screenshot *screenshot, *tmp; struct wlr_screenshot *screenshot, *tmp;
wl_list_for_each_safe(screenshot, tmp, &screenshooter->screenshots, link) { wl_list_for_each_safe(screenshot, tmp, &screenshooter->screenshots, link) {
screenshot_destroy(screenshot); screenshot_destroy(screenshot);

View File

@ -145,6 +145,7 @@ void wlr_server_decoration_manager_destroy(
if (manager == NULL) { if (manager == NULL) {
return; return;
} }
wl_list_remove(&manager->display_destroy.link);
struct wlr_server_decoration *decoration, *tmp_decoration; struct wlr_server_decoration *decoration, *tmp_decoration;
wl_list_for_each_safe(decoration, tmp_decoration, &manager->decorations, wl_list_for_each_safe(decoration, tmp_decoration, &manager->decorations,
link) { link) {