aboutsummaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
authorLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-08-13 19:57:20 -0500
committerLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-08-25 00:20:21 -0500
commit406aebcbd2d9526834ad4131ac8b454a9f27c0d9 (patch)
tree57ef4c9a1b7b215cd1f38ac8ade62a8b9be1d252 /dwl.c
parentdfcd142ce4079d36f5a0a73f9104ba87c365ef12 (diff)
prevent an infinite loop if try to use focusmon() with all monitors disabled
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/dwl.c b/dwl.c
index ebb74b8..f76e30f 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1192,9 +1192,11 @@ focusclient(Client *c, int lift)
void
focusmon(const Arg *arg)
{
- do
- selmon = dirtomon(arg->i);
- while (!selmon->wlr_output->enabled);
+ int i = 0, nmons = wl_list_length(&mons);
+ if (nmons)
+ do /* don't switch to disabled mons */
+ selmon = dirtomon(arg->i);
+ while (!selmon->wlr_output->enabled && i++ < nmons);
focusclient(focustop(selmon), 1);
}