rootston seat: implement part of roots_seat_destroy

... and have it listen to seat destroy notifier
This commit is contained in:
Dominique Martinet 2017-12-29 19:00:51 +01:00
parent e0eafa0429
commit 689004ff21
2 changed files with 26 additions and 4 deletions

View File

@ -21,6 +21,8 @@ struct roots_seat {
struct wl_list pointers; struct wl_list pointers;
struct wl_list touch; struct wl_list touch;
struct wl_list tablet_tools; struct wl_list tablet_tools;
struct wl_listener seat_destroy;
}; };
struct roots_seat_view { struct roots_seat_view {

View File

@ -220,6 +220,27 @@ static void roots_seat_init_cursor(struct roots_seat *seat) {
seat->cursor->request_set_cursor.notify = handle_request_set_cursor; seat->cursor->request_set_cursor.notify = handle_request_set_cursor;
} }
static void seat_view_destroy(struct roots_seat_view *seat_view);
void roots_seat_destroy(struct roots_seat *seat) {
struct roots_seat_view *view, *nview;
// TODO: probably more to be freed here
wl_list_for_each_safe(view, nview, &seat->views, link) {
seat_view_destroy(view);
}
// Can be called from seat_destroy handler, so don't destroy seat
}
static void roots_seat_handle_seat_destroy(struct wl_listener *listener,
void *data) {
struct roots_seat *seat =
wl_container_of(listener, seat, seat_destroy);
roots_seat_destroy(seat);
}
struct roots_seat *roots_seat_create(struct roots_input *input, char *name) { struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
struct roots_seat *seat = calloc(1, sizeof(struct roots_seat)); struct roots_seat *seat = calloc(1, sizeof(struct roots_seat));
if (!seat) { if (!seat) {
@ -254,11 +275,10 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
wl_list_insert(&input->seats, &seat->link); wl_list_insert(&input->seats, &seat->link);
return seat; seat->seat_destroy.notify = roots_seat_handle_seat_destroy;
} wl_signal_add(&seat->seat->events.destroy, &seat->seat_destroy);
void roots_seat_destroy(struct roots_seat *seat) { return seat;
// TODO
} }
static void seat_add_keyboard(struct roots_seat *seat, static void seat_add_keyboard(struct roots_seat *seat,