Handle seat removal
parent
0cc1a70ba7
commit
017edc6ae1
|
@ -23,13 +23,15 @@ struct seat {
|
|||
struct wl_seat* wl_seat;
|
||||
struct wl_list link;
|
||||
|
||||
uint32_t id;
|
||||
uint32_t capabilities;
|
||||
char name[256];
|
||||
};
|
||||
|
||||
struct seat* seat_new(struct wl_seat* wl_seat);
|
||||
struct seat* seat_new(struct wl_seat* wl_seat, uint32_t id);
|
||||
void seat_destroy(struct seat* self);
|
||||
void seat_list_destroy(struct wl_list* list);
|
||||
|
||||
struct seat* seat_find_by_name(struct wl_list* list, const char* name);
|
||||
struct seat* seat_find_by_id(struct wl_list* list, uint32_t id);
|
||||
struct seat* seat_first(struct wl_list* list);
|
||||
|
|
14
src/main.c
14
src/main.c
|
@ -159,7 +159,7 @@ static void registry_add(void* data, struct wl_registry* registry,
|
|||
if (!wl_seat)
|
||||
return;
|
||||
|
||||
struct seat* seat = seat_new(wl_seat);
|
||||
struct seat* seat = seat_new(wl_seat, id);
|
||||
if (!seat) {
|
||||
wl_seat_destroy(wl_seat);
|
||||
return;
|
||||
|
@ -189,6 +189,18 @@ static void registry_remove(void* data, struct wl_registry* registry,
|
|||
output_destroy(out);
|
||||
|
||||
/* TODO: If this is the selected output, exit */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
struct seat* seat = seat_find_by_id(&self->seats, id);
|
||||
if (seat) {
|
||||
wl_list_remove(&seat->link);
|
||||
seat_destroy(seat);
|
||||
|
||||
/* TODO: If this is the selected seat, exit */
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
14
src/seat.c
14
src/seat.c
|
@ -44,13 +44,14 @@ static const struct wl_seat_listener seat_listener = {
|
|||
.name = seat_name,
|
||||
};
|
||||
|
||||
struct seat* seat_new(struct wl_seat* wl_seat)
|
||||
struct seat* seat_new(struct wl_seat* wl_seat, uint32_t id)
|
||||
{
|
||||
struct seat* self = calloc(1, sizeof(*self));
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
self->wl_seat = wl_seat;
|
||||
self->id = id;
|
||||
|
||||
wl_seat_add_listener(wl_seat, &seat_listener, self);
|
||||
|
||||
|
@ -85,6 +86,17 @@ struct seat* seat_find_by_name(struct wl_list* list, const char* name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct seat* seat_find_by_id(struct wl_list* list, uint32_t id)
|
||||
{
|
||||
struct seat* seat;
|
||||
|
||||
wl_list_for_each(seat, list, link)
|
||||
if (seat->id == id)
|
||||
return seat;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct seat* seat_first(struct wl_list* list)
|
||||
{
|
||||
struct seat* seat;
|
||||
|
|
Loading…
Reference in New Issue