Re: [hackers] [dwm][PATCH] setmfact: Unify bounds for compile-time and runtime mfact

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Mon, 20 Apr 2020 17:57:19 +0200

On Mon, Apr 20, 2020 at 04:41:52PM +0100, Chris Down wrote:
> 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.
> ---
> dwm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/dwm.c b/dwm.c
> index 4465af1..41c6767 100644
> --- a/dwm.c
> +++ b/dwm.c
> _AT_@ -1520,7 +1520,7 @@ setmfact(const Arg *arg)
> if (!arg || !selmon->lt[selmon->sellt]->arrange)
> return;
> f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
> - if (f < 0.1 || f > 0.9)
> + if (f < 0.05 || f > 0.95)
> return;
> selmon->mfact = f;
> arrange(selmon);
> --
> 2.26.1
>
>

Thanks

-- 
Kind regards,
Hiltjo
Received on Mon Apr 20 2020 - 17:57:19 CEST

This archive was generated by hypermail 2.3.0 : Mon Apr 20 2020 - 18:00:39 CEST