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

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

This is resend. Ignore previous patch please.

It was annoying to me that whenever I pressed MODKEY+i more times than current window count (by holding it, for example), I had to undo that by pressing MODKEY+p to decrease nmaster, which could be avoided by limiting nmaster to window count. 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..b55d9c6 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(selmon->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:38:17 CEST

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