Add display destroy listener to data device

master
emersion 7 years ago
parent e6d2e72401
commit c7900663bc
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

@ -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 {

@ -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);

@ -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;
} }
return manager; manager->display_destroy.notify = handle_display_destroy;
} wl_display_add_destroy_listener(display, &manager->display_destroy);
void wlr_data_device_manager_destroy(struct wlr_data_device_manager *manager) { return manager;
if (!manager) {
return;
}
wl_global_destroy(manager->global);
free(manager);
} }

Loading…
Cancel
Save