* See LICENSE file for license details.
*/
#include "dwm.h"
+#include <stdlib.h>
-unsigned int master = MASTER;
-unsigned int nmaster = NMASTER;
unsigned int blw = 0;
Layout *lt = NULL;
/* static */
static unsigned int nlayouts = 0;
+static unsigned int masterw = MASTERWIDTH;
+static unsigned int nmaster = NMASTER;
static void
tile(void) {
n++;
/* window geoms */
mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
- mw = (n > nmaster) ? (waw * master) / 1000 : waw;
+ mw = (n > nmaster) ? (waw * masterw) / 1000 : waw;
th = (n > nmaster) ? wah / (n - nmaster) : 0;
tw = waw - mw;
/* extern */
void
-focusnext(Arg *arg) {
+focusnext(const char *arg) {
Client *c;
if(!sel)
}
void
-focusprev(Arg *arg) {
+focusprev(const char *arg) {
Client *c;
if(!sel)
}
void
-incnmaster(Arg *arg) {
- if((lt->arrange != tile) || (nmaster + arg->i < 1)
- || (wah / (nmaster + arg->i) <= 2 * BORDERPX))
+incmasterw(const char *arg) {
+ int i;
+ if(lt->arrange != tile)
return;
- nmaster += arg->i;
+ if(!arg)
+ masterw = MASTERWIDTH;
+ else {
+ i = atoi(arg);
+ if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX
+ || waw * (masterw + i) / 1000 <= 2 * BORDERPX)
+ return;
+ masterw += i;
+ }
+ lt->arrange();
+}
+
+void
+incnmaster(const char *arg) {
+ int i;
+
+ if(!arg)
+ nmaster = NMASTER;
+ else {
+ i = atoi(arg);
+ if((lt->arrange != tile) || (nmaster + i < 1)
+ || (wah / (nmaster + i) <= 2 * BORDERPX))
+ return;
+ nmaster += i;
+ }
if(sel)
lt->arrange();
else
return c;
}
-void
-resizemaster(Arg *arg) {
- if(lt->arrange != tile)
- return;
- if(arg->i == 0)
- master = MASTER;
- else {
- if(waw * (master + arg->i) / 1000 >= waw - 2 * BORDERPX
- || waw * (master + arg->i) / 1000 <= 2 * BORDERPX)
- return;
- master += arg->i;
- }
- lt->arrange();
-}
-
void
restack(void) {
Client *c;
}
void
-setlayout(Arg *arg) {
- unsigned int i;
+setlayout(const char *arg) {
+ int i;
- if(arg->i == -1) {
+ if(!arg) {
for(i = 0; i < nlayouts && lt != &layout[i]; i++);
if(i == nlayouts - 1)
lt = &layout[0];
lt = &layout[++i];
}
else {
- if(arg->i < 0 || arg->i >= nlayouts)
+ i = atoi(arg);
+ if(i < 0 || i >= nlayouts)
return;
- lt = &layout[arg->i];
+ lt = &layout[i];
}
if(sel)
lt->arrange();
drawstatus();
}
+void
+togglemax(const char *arg) {
+ XEvent ev;
+
+ if(!sel || (lt->arrange != versatile && !sel->isversatile) || sel->isfixed)
+ return;
+ if((sel->ismax = !sel->ismax)) {
+ sel->rx = sel->x;
+ sel->ry = sel->y;
+ sel->rw = sel->w;
+ sel->rh = sel->h;
+ resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True);
+ }
+ else
+ resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
+ drawstatus();
+ while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+}
+
void
versatile(void) {
Client *c;
}
restack();
}
+
+void
+zoom(const char *arg) {
+ unsigned int n;
+ Client *c;
+
+ if(!sel || lt->arrange != tile || sel->isversatile)
+ return;
+ for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+ n++;
+ if((c = sel) == nexttiled(clients))
+ if(!(c = nexttiled(c->next)))
+ return;
+ detach(c);
+ attach(c);
+ focus(c);
+ lt->arrange();
+}