X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=layout.c;h=5d43187d6af7e3e879573d50841158f9f504b7ec;hb=5711609203602bd01b4b131572142bb171ffc560;hp=e5f635c7542d4d0963cc7094d78fc51e2364783b;hpb=29c26b88e7333fb8ea022c4bb4277bc0394ab9e3;p=dwm.git diff --git a/layout.c b/layout.c index e5f635c..5d43187 100644 --- a/layout.c +++ b/layout.c @@ -2,15 +2,16 @@ * See LICENSE file for license details. */ #include "dwm.h" +#include -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) { @@ -21,7 +22,7 @@ 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; @@ -69,7 +70,7 @@ LAYOUTS /* extern */ void -focusnext(Arg *arg) { +focusnext(const char *arg) { Client *c; if(!sel) @@ -84,7 +85,7 @@ focusnext(Arg *arg) { } void -focusprev(Arg *arg) { +focusprev(const char *arg) { Client *c; if(!sel) @@ -101,11 +102,35 @@ focusprev(Arg *arg) { } 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 @@ -132,21 +157,6 @@ nexttiled(Client *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; XEvent ev; @@ -170,10 +180,10 @@ restack(void) { } 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]; @@ -181,9 +191,10 @@ setlayout(Arg *arg) { 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(); @@ -192,6 +203,25 @@ setlayout(Arg *arg) { } 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; @@ -213,3 +243,21 @@ versatile(void) { } 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(); +}