Hi,
Attached are two small patches to setmfact. The first one removes some
redundancy, saving 5 LOC; the second one reintroduces the MFACT define
that was present (as MWFACT) before, so that you can do setmfact(NULL)
to restore your initial master factor.
Taken together, they add 1 LOC.
Regards,
Peter
diff -r 3ac7eb240b52 dwm.c
--- a/dwm.c Tue Apr 01 15:45:37 2008 +0100
+++ b/dwm.c Wed Apr 02 15:25:44 2008 +0200
@@ -1467,21 +1467,16 @@
void
setmfact(const char *arg) {
- double delta;
+ double d;
if(!arg || lt->isfloating)
return;
- delta = strtod(arg, NULL);
- if(arg[0] == '-' || arg[0] == '+') {
- if(mfact + delta < 0.1 || mfact + delta > 0.9)
- return;
- mfact += delta;
- }
- else {
- if(delta < 0.1 || delta > 0.9)
- return;
- mfact = delta;
- }
+ d = strtod(arg, NULL);
+ if(arg[0] == '-' || arg[0] == '+')
+ d += mfact;
+ if(d < 0.1 || d > 0.9)
+ return;
+ mfact = d;
setgeom(geom->symbol);
}
diff -r 3c8ba4a4092d config.def.h
--- a/config.def.h Wed Apr 02 15:55:43 2008 +0200
+++ b/config.def.h Wed Apr 02 15:59:51 2008 +0200
@@ -20,7 +20,7 @@
/* geometries, s{x,y,w,h} and bh are already initualized here */
/* func name bx by bw wx wy ww wh mx my mw mh tx ty
tw th mox moy mow moh */
-double mfact = 0.55;
+#define MFACT 0.55 /* master width factor [0.1 .. 0.9] */
DEFGEOM(single, 0, 0, sw, 0, bh, sw, sh-bh, wx, wy, mfact*sw, wh, mx+mw,
wy, ww-mw, wh, wx, wy, ww, wh)
DEFGEOM(dual, 0, 0,1280, 0, bh, ww, wh-bh, wx, wy, 1280,800-bh, 1280, 0,
ww-mw, sh, mx, my, mw, mh)
diff -r 3c8ba4a4092d dwm.c
--- a/dwm.c Wed Apr 02 15:55:43 2008 +0200
+++ b/dwm.c Wed Apr 02 15:59:51 2008 +0200
@@ -212,6 +212,7 @@
int screen, sx, sy, sw, sh;
int (*xerrorxlib)(Display *, XErrorEvent *);
int bx, by, bw, bh, blw, bgw, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw,
th, wx, wy, ww, wh;
+double mfact;
unsigned int numlockmask = 0;
void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress,
@@ -1469,14 +1470,18 @@
setmfact(const char *arg) {
double d;
- if(!arg || lt->isfloating)
+ if(lt->isfloating)
return;
- d = strtod(arg, NULL);
- if(arg[0] == '-' || arg[0] == '+')
- d += mfact;
- if(d < 0.1 || d > 0.9)
- return;
- mfact = d;
+ if(!arg)
+ mfact = MFACT;
+ else {
+ d = strtod(arg, NULL);
+ if(arg[0] == '-' || arg[0] == '+')
+ d += mfact;
+ if(d < 0.1 || d > 0.9)
+ return;
+ mfact = d;
+ }
setgeom(geom->symbol);
}
@@ -1496,6 +1501,7 @@
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
bh = dc.font.height + 2;
+ mfact = MFACT;
geom = &geoms[0];
geom->apply();