output: Add function to find display by name

vencrypt
Andri Yngvason 2020-01-24 20:18:37 +00:00
parent df936b9dac
commit d0bee5c651
2 changed files with 13 additions and 0 deletions

View File

@ -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);

View File

@ -17,6 +17,7 @@
#include <stdint.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <wayland-client.h>
#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;