opt: optimzie code struct

This commit is contained in:
DreamMaoMao 2025-09-28 15:00:09 +08:00
parent b273ea5811
commit 53b8fa4597

View file

@ -176,27 +176,37 @@ void // 17
focusstack(const Arg *arg) { focusstack(const Arg *arg) {
/* Focus the next or previous client (in tiling order) on selmon */ /* Focus the next or previous client (in tiling order) on selmon */
Client *c, *sel = focustop(selmon); Client *c, *sel = focustop(selmon);
Client *tc = NULL;
if (!sel || sel->isfullscreen) if (!sel || sel->isfullscreen)
return; return;
if (arg->i > 0) { if (arg->i > 0) {
wl_list_for_each(c, &sel->link, link) { wl_list_for_each(c, &sel->link, link) {
if (&c->link == &clients || c->isunglobal) if (&c->link == &clients || c->isunglobal)
continue; /* wrap past the sentinel node */ continue; /* wrap past the sentinel node */
if (VISIBLEON(c, selmon)) if (VISIBLEON(c, selmon)) {
tc = c;
break; /* found it */ break; /* found it */
}
} }
} else { } else {
wl_list_for_each_reverse(c, &sel->link, link) { wl_list_for_each_reverse(c, &sel->link, link) {
if (&c->link == &clients) if (&c->link == &clients)
continue; /* wrap past the sentinel node */ continue; /* wrap past the sentinel node */
if (VISIBLEON(c, selmon) || c->isunglobal) if (VISIBLEON(c, selmon) || c->isunglobal) {
tc = c;
break; /* found it */ break; /* found it */
}
} }
} }
/* If only one client is visible on selmon, then c == sel */ /* If only one client is visible on selmon, then c == sel */
focusclient(c, 1);
if (!tc)
return;
focusclient(tc, 1);
if (warpcursor) if (warpcursor)
warp_cursor(c); warp_cursor(tc);
} }
void incnmaster(const Arg *arg) { void incnmaster(const Arg *arg) {