mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-22 13:34:18 +02:00
Fix view_get_prev_view
* Fix view_get_prev_view function * Reduce code duplication
This commit is contained in:
parent
2c499e20c3
commit
98eb1a4be8
3 changed files with 13 additions and 17 deletions
15
keybinding.c
15
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;
|
||||
|
|
|
|||
13
view.c
13
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
2
view.h
2
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue