view: add view_for_each_reverse() macro

This commit is contained in:
Consolatis 2024-11-12 20:34:29 +01:00 committed by Johan Malm
parent da1f28f3dd
commit e274c588c0
2 changed files with 47 additions and 3 deletions

View file

@ -269,6 +269,22 @@ view_next(struct wl_list *head, struct view *view, enum lab_view_criteria criter
return NULL;
}
struct view *
view_prev(struct wl_list *head, struct view *view, enum lab_view_criteria criteria)
{
assert(head);
struct wl_list *elm = view ? &view->link : head;
for (elm = elm->prev; elm != head; elm = elm->prev) {
view = wl_container_of(elm, view, link);
if (matches_criteria(view, criteria)) {
return view;
}
}
return NULL;
}
struct view *
view_next_no_head_stop(struct wl_list *head, struct view *from,
enum lab_view_criteria criteria)