|
|
@ -19,7 +19,7 @@ Layout *lt = NULL; |
|
|
|
typedef struct { |
|
|
|
typedef struct { |
|
|
|
const char *prop; |
|
|
|
const char *prop; |
|
|
|
const char *tags; |
|
|
|
const char *tags; |
|
|
|
Bool isfloat; |
|
|
|
Bool swimming; |
|
|
|
} Rule; |
|
|
|
} Rule; |
|
|
|
|
|
|
|
|
|
|
|
typedef struct { |
|
|
|
typedef struct { |
|
|
@ -27,7 +27,6 @@ typedef struct { |
|
|
|
regex_t *tagregex; |
|
|
|
regex_t *tagregex; |
|
|
|
} Regs; |
|
|
|
} Regs; |
|
|
|
|
|
|
|
|
|
|
|
LAYOUTS |
|
|
|
|
|
|
|
TAGS |
|
|
|
TAGS |
|
|
|
RULES |
|
|
|
RULES |
|
|
|
|
|
|
|
|
|
|
@ -35,60 +34,8 @@ static Regs *regs = NULL; |
|
|
|
static unsigned int nrules = 0; |
|
|
|
static unsigned int nrules = 0; |
|
|
|
static unsigned int nlayouts = 0; |
|
|
|
static unsigned int nlayouts = 0; |
|
|
|
|
|
|
|
|
|
|
|
/* extern */ |
|
|
|
static void |
|
|
|
|
|
|
|
tile(void) { |
|
|
|
void |
|
|
|
|
|
|
|
compileregs(void) { |
|
|
|
|
|
|
|
unsigned int i; |
|
|
|
|
|
|
|
regex_t *reg; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(regs) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
nrules = sizeof rule / sizeof rule[0]; |
|
|
|
|
|
|
|
regs = emallocz(nrules * sizeof(Regs)); |
|
|
|
|
|
|
|
for(i = 0; i < nrules; i++) { |
|
|
|
|
|
|
|
if(rule[i].prop) { |
|
|
|
|
|
|
|
reg = emallocz(sizeof(regex_t)); |
|
|
|
|
|
|
|
if(regcomp(reg, rule[i].prop, REG_EXTENDED)) |
|
|
|
|
|
|
|
free(reg); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
regs[i].propregex = reg; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(rule[i].tags) { |
|
|
|
|
|
|
|
reg = emallocz(sizeof(regex_t)); |
|
|
|
|
|
|
|
if(regcomp(reg, rule[i].tags, REG_EXTENDED)) |
|
|
|
|
|
|
|
free(reg); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
regs[i].tagregex = reg; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
dofloat(void) { |
|
|
|
|
|
|
|
Client *c; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(c = clients; c; c = c->next) { |
|
|
|
|
|
|
|
if(isvisible(c)) { |
|
|
|
|
|
|
|
if(c->isbanned) |
|
|
|
|
|
|
|
XMoveWindow(dpy, c->win, c->x, c->y); |
|
|
|
|
|
|
|
c->isbanned = False; |
|
|
|
|
|
|
|
resize(c, c->x, c->y, c->w, c->h, True); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
c->isbanned = True; |
|
|
|
|
|
|
|
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!sel || !isvisible(sel)) { |
|
|
|
|
|
|
|
for(c = stack; c && !isvisible(c); c = c->snext); |
|
|
|
|
|
|
|
focus(c); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
restack(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
dotile(void) { |
|
|
|
|
|
|
|
unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th; |
|
|
|
unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th; |
|
|
|
Client *c; |
|
|
|
Client *c; |
|
|
|
|
|
|
|
|
|
|
@ -105,7 +52,7 @@ dotile(void) { |
|
|
|
if(c->isbanned) |
|
|
|
if(c->isbanned) |
|
|
|
XMoveWindow(dpy, c->win, c->x, c->y); |
|
|
|
XMoveWindow(dpy, c->win, c->x, c->y); |
|
|
|
c->isbanned = False; |
|
|
|
c->isbanned = False; |
|
|
|
if(c->isfloat) |
|
|
|
if(c->swimming) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
c->ismax = False; |
|
|
|
c->ismax = False; |
|
|
|
nx = wax; |
|
|
|
nx = wax; |
|
|
@ -139,9 +86,40 @@ dotile(void) { |
|
|
|
restack(); |
|
|
|
restack(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LAYOUTS |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* extern */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
compileregs(void) { |
|
|
|
|
|
|
|
unsigned int i; |
|
|
|
|
|
|
|
regex_t *reg; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(regs) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
nrules = sizeof rule / sizeof rule[0]; |
|
|
|
|
|
|
|
regs = emallocz(nrules * sizeof(Regs)); |
|
|
|
|
|
|
|
for(i = 0; i < nrules; i++) { |
|
|
|
|
|
|
|
if(rule[i].prop) { |
|
|
|
|
|
|
|
reg = emallocz(sizeof(regex_t)); |
|
|
|
|
|
|
|
if(regcomp(reg, rule[i].prop, REG_EXTENDED)) |
|
|
|
|
|
|
|
free(reg); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
regs[i].propregex = reg; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(rule[i].tags) { |
|
|
|
|
|
|
|
reg = emallocz(sizeof(regex_t)); |
|
|
|
|
|
|
|
if(regcomp(reg, rule[i].tags, REG_EXTENDED)) |
|
|
|
|
|
|
|
free(reg); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
regs[i].tagregex = reg; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
incnmaster(Arg *arg) { |
|
|
|
incnmaster(Arg *arg) { |
|
|
|
if((lt->arrange == dofloat) || (nmaster + arg->i < 1) |
|
|
|
if((lt->arrange != tile) || (nmaster + arg->i < 1) |
|
|
|
|| (wah / (nmaster + arg->i) <= 2 * BORDERPX)) |
|
|
|
|| (wah / (nmaster + arg->i) <= 2 * BORDERPX)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
nmaster += arg->i; |
|
|
|
nmaster += arg->i; |
|
|
@ -176,7 +154,7 @@ isvisible(Client *c) { |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
resizemaster(Arg *arg) { |
|
|
|
resizemaster(Arg *arg) { |
|
|
|
if(lt->arrange != dotile) |
|
|
|
if(lt->arrange != tile) |
|
|
|
return; |
|
|
|
return; |
|
|
|
if(arg->i == 0) |
|
|
|
if(arg->i == 0) |
|
|
|
master = MASTER; |
|
|
|
master = MASTER; |
|
|
@ -197,10 +175,10 @@ restack(void) { |
|
|
|
drawstatus(); |
|
|
|
drawstatus(); |
|
|
|
if(!sel) |
|
|
|
if(!sel) |
|
|
|
return; |
|
|
|
return; |
|
|
|
if(sel->isfloat || lt->arrange == dofloat) |
|
|
|
if(sel->swimming || lt->arrange == swim) |
|
|
|
XRaiseWindow(dpy, sel->win); |
|
|
|
XRaiseWindow(dpy, sel->win); |
|
|
|
if(lt->arrange != dofloat) { |
|
|
|
if(lt->arrange != swim) { |
|
|
|
if(!sel->isfloat) |
|
|
|
if(!sel->swimming) |
|
|
|
XLowerWindow(dpy, sel->win); |
|
|
|
XLowerWindow(dpy, sel->win); |
|
|
|
for(c = nexttiled(clients); c; c = nexttiled(c->next)) { |
|
|
|
for(c = nexttiled(clients); c; c = nexttiled(c->next)) { |
|
|
|
if(c == sel) |
|
|
|
if(c == sel) |
|
|
@ -230,7 +208,7 @@ settags(Client *c, Client *trans) { |
|
|
|
ch.res_name ? ch.res_name : "", c->name); |
|
|
|
ch.res_name ? ch.res_name : "", c->name); |
|
|
|
for(i = 0; i < nrules; i++) |
|
|
|
for(i = 0; i < nrules; i++) |
|
|
|
if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) { |
|
|
|
if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) { |
|
|
|
c->isfloat = rule[i].isfloat; |
|
|
|
c->swimming = rule[i].swimming; |
|
|
|
for(j = 0; regs[i].tagregex && j < ntags; j++) { |
|
|
|
for(j = 0; regs[i].tagregex && j < ntags; j++) { |
|
|
|
if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) { |
|
|
|
if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) { |
|
|
|
matched = True; |
|
|
|
matched = True; |
|
|
@ -248,6 +226,29 @@ settags(Client *c, Client *trans) { |
|
|
|
c->tags[i] = seltag[i]; |
|
|
|
c->tags[i] = seltag[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
swim(void) { |
|
|
|
|
|
|
|
Client *c; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(c = clients; c; c = c->next) { |
|
|
|
|
|
|
|
if(isvisible(c)) { |
|
|
|
|
|
|
|
if(c->isbanned) |
|
|
|
|
|
|
|
XMoveWindow(dpy, c->win, c->x, c->y); |
|
|
|
|
|
|
|
c->isbanned = False; |
|
|
|
|
|
|
|
resize(c, c->x, c->y, c->w, c->h, True); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
c->isbanned = True; |
|
|
|
|
|
|
|
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!sel || !isvisible(sel)) { |
|
|
|
|
|
|
|
for(c = stack; c && !isvisible(c); c = c->snext); |
|
|
|
|
|
|
|
focus(c); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
restack(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
tag(Arg *arg) { |
|
|
|
tag(Arg *arg) { |
|
|
|
unsigned int i; |
|
|
|
unsigned int i; |
|
|
@ -262,10 +263,10 @@ tag(Arg *arg) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
togglefloat(Arg *arg) { |
|
|
|
toggleswimming(Arg *arg) { |
|
|
|
if(!sel || lt->arrange == dofloat) |
|
|
|
if(!sel || lt->arrange == swim) |
|
|
|
return; |
|
|
|
return; |
|
|
|
sel->isfloat = !sel->isfloat; |
|
|
|
sel->swimming = !sel->swimming; |
|
|
|
lt->arrange(); |
|
|
|
lt->arrange(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|