From c01e5c608052138b54ce957835f0f98f33f027d1 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sat, 29 Apr 2023 19:48:30 +0000 Subject: [PATCH] seat: Add occupancy count --- include/seat.h | 3 +++ src/seat.c | 11 +++++++++++ 2 files changed, 14 insertions(+) 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;