diff --git a/include/output.h b/include/output.h index 78cebcb..81a68ac 100644 --- a/include/output.h +++ b/include/output.h @@ -46,4 +46,5 @@ void output_set_xdg_output(struct output* output, struct zxdg_output_v1* xdg_output); void output_list_destroy(struct wl_list* list); struct output* output_find_by_id(struct wl_list* list, uint32_t id); +struct output* output_find_by_name(struct wl_list* list, const char* name); struct output* output_first(struct wl_list* list); diff --git a/src/output.c b/src/output.c index 7127497..b183d9b 100644 --- a/src/output.c +++ b/src/output.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "output.h" @@ -156,6 +157,17 @@ struct output* output_find_by_id(struct wl_list* list, uint32_t id) return NULL; } +struct output* output_find_by_name(struct wl_list* list, const char* name) +{ + struct output* output; + + wl_list_for_each(output, list, link) + if (strcmp(output->name, name) == 0) + return output; + + return NULL; +} + struct output* output_first(struct wl_list* list) { struct output* output;