summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuleyman Farajli <suleyman@farajli.net>2024-08-31 11:30:43 +0400
committerSuleyman Farajli <suleyman@farajli.net>2024-08-31 11:30:43 +0400
commite2ecb8556ac149e07ce4b6b156b099efb51767a6 (patch)
tree793330b65c67cf369400209715ea9ca30bbb2019
parent196ab4dab889902a4114c67b115f8064cdac0cdc (diff)
focusstack function was made more readable
-rw-r--r--dwm.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/dwm.c b/dwm.c
index 5a62ba8..d16420f 100644
--- a/dwm.c
+++ b/dwm.c
@@ -869,39 +869,41 @@ focusstack(const Arg *arg)
if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen))
return;
+
if (arg->i > 0) {
- if (focusfloat)
- for (c = selmon->sel->next; c && (!ISVISIBLE(c) || !c->isfloating); c = c->next);
- else
- for (c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
- if (focusfloat && !c)
- for (c = selmon->clients; c && (!ISVISIBLE(c) || !c->isfloating); c = c->next);
- if (!focusfloat && !c)
- for (c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
+ c = selmon->sel->next;
+ while (1) {
+ for (;c ; c = c->next) {
+ if (!ISVISIBLE(c))
+ continue;
+ if (focusfloat && c->isfloating)
+ break;
+ if (!focusfloat && !c->isfloating)
+ break;
+ }
+ if (!c && selmon->clients)
+ c = selmon->clients;
+ else
+ break;
+ }
} else {
for (i = selmon->clients; i != selmon->sel; i = i->next) {
- if(!focusfloat) {
- if (ISVISIBLE(i) && !i->isfloating)
+ if(!focusfloat && ISVISIBLE(i) && !i->isfloating)
c = i;
- } else {
- if (ISVISIBLE(i) && i->isfloating)
+ if (focusfloat && ISVISIBLE(i) && i->isfloating)
c = i;
- }
}
if (!c) {
for (; i; i = i->next) {
- if(!focusfloat) {
- if (ISVISIBLE(i) && !i->isfloating)
+ if (!focusfloat && ISVISIBLE(i) && !i->isfloating)
c = i;
- } else {
- if (ISVISIBLE(i) && i->isfloating)
+ if (focusfloat && ISVISIBLE(i) && i->isfloating)
c = i;
-
- }
}
}
}
+
if (c) {
focus(c);
restack(selmon);