Improve code of func "focusstack"

This commit is contained in:
Alex Kotov 2021-11-16 06:29:34 +05:00
parent d794be4c49
commit e2a856dccd
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
1 changed files with 20 additions and 9 deletions

29
dwm.c
View File

@ -1045,23 +1045,34 @@ focusmon(const Arg *arg)
void
focusstack(const Arg *arg)
{
Client *c = NULL, *i;
if (!selmon->sel) return;
Client *c = NULL;
if (!selmon->sel)
return;
if (arg->i > 0) {
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
if (!c)
if (!c) {
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
}
} else {
for (i = selmon->clients; i != selmon->sel; i = i->next)
if (ISVISIBLE(i))
Client *i = selmon->clients;
for (; i != selmon->sel; i = i->next) {
if (ISVISIBLE(i)) {
c = i;
if (!c)
for (; i; i = i->next)
if (ISVISIBLE(i))
}
}
if (!c) {
for (; i; i = i->next) {
if (ISVISIBLE(i)) {
c = i;
}
}
}
}
if (c) {
focus(c);
restack(selmon);