[hackers] [dwm][PATCH] Don't increase nmaster to more than current window count

From: Kristaps Civkulis <kristaps.civkulis_AT_gmail.com>
Date: Fri, 2 Jun 2017 00:20:32 +0300

It was annoying to me that whenever I pressed MODKEY+i too more times than current window count (by holding it, for example), I had to undo it by pressing MODKEY+p to decrease nmaster. This patch should prevent this.

---
 dwm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/dwm.c b/dwm.c
index a5ce993..3b8370e 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -968,7 +968,15 @@ grabkeys(void)
 void
 incnmaster(const Arg *arg)
 {
-	selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
+	int n;
+	Client* c;
+
+	if (arg->i > 0) {
+		for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+		selmon->nmaster = MIN(n, selmon->nmaster + arg->i);
+	}
+	else
+		selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
 	arrange(selmon);
 }
 
-- 
2.13.0
Received on Thu Jun 01 2017 - 23:20:32 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 01 2017 - 23:24:16 CEST