several changes, made togglemax extern and separated it from zoom() - moved zoom() and togglemax() into layout.c, changed void (*func)(Arg *) into void (*func)(Arg), changed default keybindings of focusnext/focusprev and incmasterw to h/j/k/l accordingly, made keys in config*h appear alphabetically (special keys first), renamed resizemaster into incmasterw, renamed MASTER into MASTERWIDTH

This commit is contained in:
Anselm R. Garbe 2007-02-22 07:59:13 +01:00
parent b3b58c08e4
commit 352cae4380
10 changed files with 188 additions and 187 deletions

View file

@ -3,14 +3,14 @@
*/
#include "dwm.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) {
@ -21,7 +21,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 +69,7 @@ LAYOUTS
/* extern */
void
focusnext(Arg *arg) {
focusnext(Arg arg) {
Client *c;
if(!sel)
@ -84,7 +84,7 @@ focusnext(Arg *arg) {
}
void
focusprev(Arg *arg) {
focusprev(Arg arg) {
Client *c;
if(!sel)
@ -101,11 +101,26 @@ focusprev(Arg *arg) {
}
void
incnmaster(Arg *arg) {
if((lt->arrange != tile) || (nmaster + arg->i < 1)
|| (wah / (nmaster + arg->i) <= 2 * BORDERPX))
incmasterw(Arg arg) {
if(lt->arrange != tile)
return;
nmaster += arg->i;
if(arg.i == 0)
masterw = MASTERWIDTH;
else {
if(waw * (masterw + arg.i) / 1000 >= waw - 2 * BORDERPX
|| waw * (masterw + arg.i) / 1000 <= 2 * BORDERPX)
return;
masterw += arg.i;
}
lt->arrange();
}
void
incnmaster(Arg arg) {
if((lt->arrange != tile) || (nmaster + arg.i < 1)
|| (wah / (nmaster + arg.i) <= 2 * BORDERPX))
return;
nmaster += arg.i;
if(sel)
lt->arrange();
else
@ -131,21 +146,6 @@ nexttiled(Client *c) {
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;
@ -170,10 +170,10 @@ restack(void) {
}
void
setlayout(Arg *arg) {
setlayout(Arg arg) {
unsigned int i;
if(arg->i == -1) {
if(arg.i == -1) {
for(i = 0; i < nlayouts && lt != &layout[i]; i++);
if(i == nlayouts - 1)
lt = &layout[0];
@ -181,9 +181,9 @@ setlayout(Arg *arg) {
lt = &layout[++i];
}
else {
if(arg->i < 0 || arg->i >= nlayouts)
if(arg.i < 0 || arg.i >= nlayouts)
return;
lt = &layout[arg->i];
lt = &layout[arg.i];
}
if(sel)
lt->arrange();
@ -191,6 +191,24 @@ setlayout(Arg *arg) {
drawstatus();
}
void
togglemax(Arg arg) {
XEvent ev;
if(!sel || !sel->isversatile || sel->isfixed || lt->arrange != versatile)
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);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
void
versatile(void) {
Client *c;
@ -213,3 +231,21 @@ versatile(void) {
}
restack();
}
void
zoom(Arg 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();
}