From 53b8fa459775121f475c028d9867186e1693e398 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sun, 28 Sep 2025 15:00:09 +0800 Subject: [PATCH] opt: optimzie code struct --- src/dispatch/bind_define.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index 991984f..cd12a51 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -176,27 +176,37 @@ void // 17 focusstack(const Arg *arg) { /* Focus the next or previous client (in tiling order) on selmon */ Client *c, *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)) + if (VISIBLEON(c, selmon)) { + tc = c; break; /* found it */ + } } } 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) + if (VISIBLEON(c, selmon) || c->isunglobal) { + tc = c; break; /* found it */ + } } } /* If only one client is visible on selmon, then c == sel */ - focusclient(c, 1); + + if (!tc) + return; + + focusclient(tc, 1); if (warpcursor) - warp_cursor(c); + warp_cursor(tc); } void incnmaster(const Arg *arg) {