From 406aebcbd2d9526834ad4131ac8b454a9f27c0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Sat, 13 Aug 2022 19:57:20 -0500 Subject: prevent an infinite loop if try to use focusmon() with all monitors disabled --- dwl.c | 8 +++++--- 1 file 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); } -- cgit v1.2.3