Re: [dwm] nmaster strikes back

From: Szabolcs Nagy <nszabolcs_AT_gmail.com>
Date: Wed, 11 Feb 2009 09:57:02 +0100

On 2/11/09, Peter Hartlich <sgkkr_AT_hartlich.com> wrote:
> It would however be useless without the setnmaster() function clocking in
> at 13 LOC, same as setmfact(). But the two have most of their code in
> common:
>
> 1. Verify layout != floating
> 2. Verify arg is within bounds
> 3. Set global variable (relatively or absolutely)
> 4. Call arrange()

nice, but tweak() has too much magic (if there were many runtime
tunable int parameters in dwm then it would be ok).

> enum { Abs, Rel };
>
> void
> tweak(int *var, const int *val, int min, int max) {
> int i;
>
> i = val[1] + (val[0] == Abs ? 0 : *var);
> if(!lt[sellt]->arrange || i < min || i > max)
> return;
> *var = i;
> arrange();
> }
>
> Previously setmfact():
> void
> tweakmwp(const Arg *arg) {
> tweak(&mwp, arg->v, 5, 95);
> }
>
> Previously setnmaster():
> void
> tweakmn(const Arg *arg) {
> tweak(&mn, arg->v, 1, wh / (1 + 2 * borderpx));
> }
>
> Configuration example:
> static int mwp = 55; /* master area width percentage [5..95] */
> static int mn = 1; /* number of clients in master area */
> [...]
> { MODKEY, XK_h, tweakmwp, {.v = (int[]){Rel, -10}} },
> { MODKEY|ShiftMask, XK_n, tweakmn, {.v = (int[]){Abs, 2}} },
>

this way master width cannot be set to a fixed value

i'd probably use a macro in the config:
.. {.v = REL(-10)},
.. {.v = ABS{2}},

is nmaster that useful?

> keyboards thread. It also corrects a discrepancy between documentation and
> code: mfact was described as [0.05..0.95], but was actually [0.1..0.9].

nice catch, config.def.h or setmfact() should be fixed
Received on Wed Feb 11 2009 - 08:57:02 UTC

This archive was generated by hypermail 2.2.0 : Wed Feb 11 2009 - 09:12:04 UTC