Add output_cycle to get next/prev outputs
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>pull/175/head
parent
a1aa69625c
commit
4018c698c2
|
@ -60,6 +60,14 @@ 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);
|
||||
|
||||
enum output_cycle_direction {
|
||||
OUTPUT_CYCLE_FORWARD,
|
||||
OUTPUT_CYCLE_REVERSE,
|
||||
};
|
||||
struct output* output_cycle(const struct wl_list* list,
|
||||
const struct output* current,
|
||||
enum output_cycle_direction);
|
||||
|
||||
uint32_t output_get_transformed_width(const struct output* self);
|
||||
uint32_t output_get_transformed_height(const struct output* self);
|
||||
|
||||
|
|
17
src/output.c
17
src/output.c
|
@ -285,3 +285,20 @@ struct output* output_first(struct wl_list* list)
|
|||
|
||||
return output;
|
||||
}
|
||||
|
||||
struct output* output_cycle(const struct wl_list* list,
|
||||
const struct output* current,
|
||||
enum output_cycle_direction direction)
|
||||
{
|
||||
const struct wl_list* iter = current ? ¤t->link : list;
|
||||
iter = (direction == OUTPUT_CYCLE_FORWARD) ?
|
||||
iter->next : iter->prev;
|
||||
if (iter == list) {
|
||||
if (wl_list_empty(list))
|
||||
return NULL;
|
||||
iter = (direction == OUTPUT_CYCLE_FORWARD) ?
|
||||
iter->next : iter->prev;
|
||||
}
|
||||
struct output* output;
|
||||
return wl_container_of(iter, output, link);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue