From 11b47dda9950c646611c3517207c91fb829f603a Mon Sep 17 00:00:00 2001 From: bakkeby Date: Mon, 20 Apr 2020 18:40:25 +0200 Subject: [PATCH] setmfact: Unify bounds for compile-time and runtime mfact 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. --- README.md | 2 +- dwm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d92bb77..d069415 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -This dwm 6.2 side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. +This dwm 6.2 (c4b475, 2020-04-20) side project has a different take on dwm patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. For example to include the `alpha` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/dwm-flexipatch/blob/master/patches.def.h): ```c diff --git a/dwm.c b/dwm.c index df1104f..56e28af 100644 --- a/dwm.c +++ b/dwm.c @@ -2922,7 +2922,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; #if PERTAG_PATCH selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;