diff --git a/include/seat.h b/include/seat.h index 97692b2..62cec8b 100644 --- a/include/seat.h +++ b/include/seat.h @@ -26,6 +26,8 @@ struct seat { uint32_t id; uint32_t capabilities; char name[256]; + + uint32_t occupancy; }; struct seat* seat_new(struct wl_seat* wl_seat, uint32_t id); @@ -34,4 +36,5 @@ 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_find_unoccupied(struct wl_list* list); struct seat* seat_first(struct wl_list* list); diff --git a/src/seat.c b/src/seat.c index d43fc86..b666892 100644 --- a/src/seat.c +++ b/src/seat.c @@ -97,6 +97,17 @@ struct seat* seat_find_by_id(struct wl_list* list, uint32_t id) return NULL; } +struct seat* seat_find_unoccupied(struct wl_list* list) +{ + struct seat* seat; + + wl_list_for_each(seat, list, link) + if (seat->occupancy == 0) + return seat; + + return NULL; +} + struct seat* seat_first(struct wl_list* list) { struct seat* seat;