diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index cd12a51..ff2ef86 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -175,29 +175,15 @@ void focusmon(const Arg *arg) { void // 17 focusstack(const Arg *arg) { /* Focus the next or previous client (in tiling order) on selmon */ - Client *c, *sel = focustop(selmon); + Client *sel = focustop(selmon); Client *tc = NULL; if (!sel || sel->isfullscreen) return; if (arg->i > 0) { - wl_list_for_each(c, &sel->link, link) { - if (&c->link == &clients || c->isunglobal) - continue; /* wrap past the sentinel node */ - if (VISIBLEON(c, selmon)) { - tc = c; - break; /* found it */ - } - } + tc = get_next_stack_client(sel, false); } else { - wl_list_for_each_reverse(c, &sel->link, link) { - if (&c->link == &clients) - continue; /* wrap past the sentinel node */ - if (VISIBLEON(c, selmon) || c->isunglobal) { - tc = c; - break; /* found it */ - } - } + tc = get_next_stack_client(sel, true); } /* If only one client is visible on selmon, then c == sel */ diff --git a/src/fetch/client.h b/src/fetch/client.h index edcdb7c..79d0bf0 100644 --- a/src/fetch/client.h +++ b/src/fetch/client.h @@ -335,3 +335,19 @@ focustop(Monitor *m) { } return NULL; } + +Client *get_next_stack_client(Client *c, bool reverse) { + Client *next = NULL; + if (reverse) { + wl_list_for_each_reverse(next, &c->link, link) { + if (VISIBLEON(next, c->mon) && next != c) + return next; + } + } else { + wl_list_for_each(next, &c->link, link) { + if (VISIBLEON(next, c->mon) && next != c) + return next; + } + } + return NULL; +} diff --git a/src/mango.c b/src/mango.c index 697e6d6..731c200 100644 --- a/src/mango.c +++ b/src/mango.c @@ -700,6 +700,7 @@ static bool switch_scratchpad_client_state(Client *c); static bool check_trackpad_disabled(struct wlr_pointer *pointer); static unsigned int get_tag_status(unsigned int tag, Monitor *m); static void enable_adaptive_sync(Monitor *m, struct wlr_output_state *state); +static Client *get_next_stack_client(Client *c, bool reverse); #include "data/static_keymap.h" #include "dispatch/bind_declare.h"