Add display destroy listener to data device

This commit is contained in:
emersion 2017-12-07 00:50:55 +01:00
parent e6d2e72401
commit c7900663bc
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 23 additions and 8 deletions

View file

@ -15,6 +15,8 @@ wlr_touch_grab_interface wlr_data_device_touch_drag_interface;
struct wlr_data_device_manager { struct wlr_data_device_manager {
struct wl_global *global; struct wl_global *global;
struct wl_listener display_destroy;
}; };
struct wlr_data_offer { struct wlr_data_offer {

View file

@ -78,6 +78,9 @@ 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) {
if (compositor == NULL) {
return;
}
wl_list_remove(&compositor->display_destroy.link); wl_list_remove(&compositor->display_destroy.link);
wl_global_destroy(compositor->wl_global); wl_global_destroy(compositor->wl_global);
free(compositor); free(compositor);

View file

@ -949,6 +949,21 @@ static void data_device_manager_bind(struct wl_client *client,
NULL, NULL); NULL, NULL);
} }
void wlr_data_device_manager_destroy(struct wlr_data_device_manager *manager) {
if (!manager) {
return;
}
wl_list_remove(&manager->display_destroy.link);
wl_global_destroy(manager->global);
free(manager);
}
static void handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_data_device_manager *manager =
wl_container_of(listener, manager, display_destroy);
wlr_data_device_manager_destroy(manager);
}
struct wlr_data_device_manager *wlr_data_device_manager_create( struct wlr_data_device_manager *wlr_data_device_manager_create(
struct wl_display *display) { struct wl_display *display) {
struct wlr_data_device_manager *manager = struct wlr_data_device_manager *manager =
@ -967,13 +982,8 @@ struct wlr_data_device_manager *wlr_data_device_manager_create(
return NULL; return NULL;
} }
manager->display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &manager->display_destroy);
return manager; return manager;
} }
void wlr_data_device_manager_destroy(struct wlr_data_device_manager *manager) {
if (!manager) {
return;
}
wl_global_destroy(manager->global);
free(manager);
}