summaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
authorSuleyman Farajli <suleyman@farajli.net>2024-08-31 11:30:43 +0400
committerSuleyman Farajli <suleyman@farajli.net>2025-05-27 23:53:47 +0400
commitc93dc215fbf0bdd53cba02a53e02c2c1104818d8 (patch)
treedcfd5f13d3d9ef7a4184da8345a945418e0aad4c /dwm.c
parent90beaa6a33dc2e2bd55f078cfa833321b194d428 (diff)
focusstack function was made more readable
Diffstat (limited to 'dwm.c')
-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);