setmfact: Unify bounds for compile-time and runtime mfact a8e95137
There are two places that mfact can be set:

- In the mfact global, which is defined at compile time and passed
  into m->mfact during monitor setup. No bounds checks are performed,
  but the comment alongside it says that valid values are [0.05..0.95]:

      static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */

- By setmfact, which adjusts m->mfact at runtime. It also does some
  minimum and maximum bounds checks, allowing [0.1..0.9]. Values outside
  of that range are ignored, and mfact is not adjusted.

These different thresholds mean that one cannot setmfact 0.95 or 0.05,
despite the comment above that lists the legal range for mfact.

Clarify this by enforcing the same bounds in setmfact at runtime as
those listed for mfact at compile time.
Chris Down · 2020-04-20 16:41 1 file(s) · +1 −1
dwm.c +1 −1
1520 1520
	if (!arg || !selmon->lt[selmon->sellt]->arrange)
1521 1521
		return;
1522 1522
	f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
1523 -
	if (f < 0.1 || f > 0.9)
1523 +
	if (f < 0.05 || f > 0.95)
1524 1524
		return;
1525 1525
	selmon->mfact = f;
1526 1526
	arrange(selmon);