diff --git a/keybinding.c b/keybinding.c index f4c5a5b..723437a 100644 --- a/keybinding.c +++ b/keybinding.c @@ -614,20 +614,7 @@ keybinding_cycle_views(struct cg_server *server, bool reverse) { } struct cg_view *it_view, *next_view = NULL; if(reverse) { - struct wl_list *it; - it = current_view->link.prev; - while(it != ¤t_view->link) { - if(it == &curr_workspace->views) { - it = it->prev; - continue; - } - it_view = wl_container_of(it, it_view, link); - if(!view_is_visible(it_view)) { - next_view = it_view; - break; - } - it = it->prev; - } + next_view=view_get_prev_view(current_view); } else { struct wl_list *it; it = current_view->link.next; diff --git a/view.c b/view.c index 352f404..b1c870b 100644 --- a/view.c +++ b/view.c @@ -32,13 +32,20 @@ view_get_prev_view(struct cg_view *view) { struct cg_view *prev = NULL; struct cg_view *it_view; - wl_list_for_each(it_view, &view->workspace->views, link) { - if(!view_is_visible(it_view) && view != it_view) { + struct wl_list *it; + it = view->link.prev; + while(it != &view->link) { + if(it == &view->workspace->views) { + it = it->prev; + continue; + } + it_view = wl_container_of(it, it_view, link); + if(!view_is_visible(it_view)) { prev = it_view; break; } + it = it->prev; } - return prev; } diff --git a/view.h b/view.h index 5a7ecd4..249ce1c 100644 --- a/view.h +++ b/view.h @@ -118,5 +118,7 @@ view_child_finish(struct cg_view_child *child); void view_child_init(struct cg_view_child *child, struct cg_view_child *parent, struct cg_view *view, struct wlr_surface *wlr_surface); +struct cg_view * +view_get_prev_view(struct cg_view *view); #endif