|
|
@ -9,9 +9,10 @@
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
|
|
|
|
|
|
|
void (*arrange)(void) = DEFMODE;
|
|
|
|
|
|
|
|
unsigned int master = MASTER;
|
|
|
|
unsigned int master = MASTER;
|
|
|
|
unsigned int nmaster = NMASTER;
|
|
|
|
unsigned int nmaster = NMASTER;
|
|
|
|
|
|
|
|
unsigned int blw = 0;
|
|
|
|
|
|
|
|
Layout *lt = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
/* static */
|
|
|
|
|
|
|
|
|
|
|
@ -24,39 +25,41 @@ typedef struct {
|
|
|
|
typedef struct {
|
|
|
|
typedef struct {
|
|
|
|
regex_t *propregex;
|
|
|
|
regex_t *propregex;
|
|
|
|
regex_t *tagregex;
|
|
|
|
regex_t *tagregex;
|
|
|
|
} Regexps;
|
|
|
|
} Regs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LAYOUTS
|
|
|
|
TAGS
|
|
|
|
TAGS
|
|
|
|
RULES
|
|
|
|
RULES
|
|
|
|
|
|
|
|
|
|
|
|
static Regexps *regexps = NULL;
|
|
|
|
static Regs *regs = NULL;
|
|
|
|
static unsigned int len = 0;
|
|
|
|
static unsigned int nrules = 0;
|
|
|
|
|
|
|
|
static unsigned int nlayouts = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/* extern */
|
|
|
|
/* extern */
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
compileregexps(void) {
|
|
|
|
compileregs(void) {
|
|
|
|
unsigned int i;
|
|
|
|
unsigned int i;
|
|
|
|
regex_t *reg;
|
|
|
|
regex_t *reg;
|
|
|
|
|
|
|
|
|
|
|
|
if(regexps)
|
|
|
|
if(regs)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
len = sizeof rule / sizeof rule[0];
|
|
|
|
nrules = sizeof rule / sizeof rule[0];
|
|
|
|
regexps = emallocz(len * sizeof(Regexps));
|
|
|
|
regs = emallocz(nrules * sizeof(Regs));
|
|
|
|
for(i = 0; i < len; i++) {
|
|
|
|
for(i = 0; i < nrules; i++) {
|
|
|
|
if(rule[i].prop) {
|
|
|
|
if(rule[i].prop) {
|
|
|
|
reg = emallocz(sizeof(regex_t));
|
|
|
|
reg = emallocz(sizeof(regex_t));
|
|
|
|
if(regcomp(reg, rule[i].prop, REG_EXTENDED))
|
|
|
|
if(regcomp(reg, rule[i].prop, REG_EXTENDED))
|
|
|
|
free(reg);
|
|
|
|
free(reg);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
regexps[i].propregex = reg;
|
|
|
|
regs[i].propregex = reg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(rule[i].tags) {
|
|
|
|
if(rule[i].tags) {
|
|
|
|
reg = emallocz(sizeof(regex_t));
|
|
|
|
reg = emallocz(sizeof(regex_t));
|
|
|
|
if(regcomp(reg, rule[i].tags, REG_EXTENDED))
|
|
|
|
if(regcomp(reg, rule[i].tags, REG_EXTENDED))
|
|
|
|
free(reg);
|
|
|
|
free(reg);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
regexps[i].tagregex = reg;
|
|
|
|
regs[i].tagregex = reg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -138,16 +141,29 @@ dotile(void) {
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
incnmaster(Arg *arg) {
|
|
|
|
incnmaster(Arg *arg) {
|
|
|
|
if((arrange == dofloat) || (nmaster + arg->i < 1)
|
|
|
|
if((lt->arrange == dofloat) || (nmaster + arg->i < 1)
|
|
|
|
|| (wah / (nmaster + arg->i) <= 2 * BORDERPX))
|
|
|
|
|| (wah / (nmaster + arg->i) <= 2 * BORDERPX))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
nmaster += arg->i;
|
|
|
|
nmaster += arg->i;
|
|
|
|
if(sel)
|
|
|
|
if(sel)
|
|
|
|
arrange();
|
|
|
|
lt->arrange();
|
|
|
|
else
|
|
|
|
else
|
|
|
|
drawstatus();
|
|
|
|
drawstatus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
initlayouts(void) {
|
|
|
|
|
|
|
|
unsigned int i, w;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lt = &layout[0];
|
|
|
|
|
|
|
|
nlayouts = sizeof layout / sizeof layout[0];
|
|
|
|
|
|
|
|
for(blw = i = 0; i < nlayouts; i++) {
|
|
|
|
|
|
|
|
w = textw(layout[i].symbol);
|
|
|
|
|
|
|
|
if(w > blw)
|
|
|
|
|
|
|
|
blw = w;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
Bool
|
|
|
|
isvisible(Client *c) {
|
|
|
|
isvisible(Client *c) {
|
|
|
|
unsigned int i;
|
|
|
|
unsigned int i;
|
|
|
@ -160,7 +176,7 @@ isvisible(Client *c) {
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
resizemaster(Arg *arg) {
|
|
|
|
resizemaster(Arg *arg) {
|
|
|
|
if(arrange != dotile)
|
|
|
|
if(lt->arrange != dotile)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
if(arg->i == 0)
|
|
|
|
if(arg->i == 0)
|
|
|
|
master = MASTER;
|
|
|
|
master = MASTER;
|
|
|
@ -170,7 +186,7 @@ resizemaster(Arg *arg) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
master += arg->i;
|
|
|
|
master += arg->i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
arrange();
|
|
|
|
lt->arrange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
@ -181,9 +197,9 @@ restack(void) {
|
|
|
|
drawstatus();
|
|
|
|
drawstatus();
|
|
|
|
if(!sel)
|
|
|
|
if(!sel)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
if(sel->isfloat || arrange == dofloat)
|
|
|
|
if(sel->isfloat || lt->arrange == dofloat)
|
|
|
|
XRaiseWindow(dpy, sel->win);
|
|
|
|
XRaiseWindow(dpy, sel->win);
|
|
|
|
if(arrange != dofloat) {
|
|
|
|
if(lt->arrange != dofloat) {
|
|
|
|
if(!sel->isfloat)
|
|
|
|
if(!sel->isfloat)
|
|
|
|
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)) {
|
|
|
@ -212,11 +228,11 @@ settags(Client *c, Client *trans) {
|
|
|
|
snprintf(prop, sizeof prop, "%s:%s:%s",
|
|
|
|
snprintf(prop, sizeof prop, "%s:%s:%s",
|
|
|
|
ch.res_class ? ch.res_class : "",
|
|
|
|
ch.res_class ? ch.res_class : "",
|
|
|
|
ch.res_name ? ch.res_name : "", c->name);
|
|
|
|
ch.res_name ? ch.res_name : "", c->name);
|
|
|
|
for(i = 0; i < len; i++)
|
|
|
|
for(i = 0; i < nrules; i++)
|
|
|
|
if(regexps[i].propregex && !regexec(regexps[i].propregex, prop, 1, &tmp, 0)) {
|
|
|
|
if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0)) {
|
|
|
|
c->isfloat = rule[i].isfloat;
|
|
|
|
c->isfloat = rule[i].isfloat;
|
|
|
|
for(j = 0; regexps[i].tagregex && j < ntags; j++) {
|
|
|
|
for(j = 0; regs[i].tagregex && j < ntags; j++) {
|
|
|
|
if(!regexec(regexps[i].tagregex, tags[j], 1, &tmp, 0)) {
|
|
|
|
if(!regexec(regs[i].tagregex, tags[j], 1, &tmp, 0)) {
|
|
|
|
matched = True;
|
|
|
|
matched = True;
|
|
|
|
c->tags[j] = True;
|
|
|
|
c->tags[j] = True;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -242,15 +258,15 @@ tag(Arg *arg) {
|
|
|
|
sel->tags[i] = (arg->i == -1) ? True : False;
|
|
|
|
sel->tags[i] = (arg->i == -1) ? True : False;
|
|
|
|
if(arg->i >= 0 && arg->i < ntags)
|
|
|
|
if(arg->i >= 0 && arg->i < ntags)
|
|
|
|
sel->tags[arg->i] = True;
|
|
|
|
sel->tags[arg->i] = True;
|
|
|
|
arrange();
|
|
|
|
lt->arrange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
togglefloat(Arg *arg) {
|
|
|
|
togglefloat(Arg *arg) {
|
|
|
|
if(!sel || arrange == dofloat)
|
|
|
|
if(!sel || lt->arrange == dofloat)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
sel->isfloat = !sel->isfloat;
|
|
|
|
sel->isfloat = !sel->isfloat;
|
|
|
|
arrange();
|
|
|
|
lt->arrange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
@ -263,14 +279,20 @@ toggletag(Arg *arg) {
|
|
|
|
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
|
|
|
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
|
|
|
if(i == ntags)
|
|
|
|
if(i == ntags)
|
|
|
|
sel->tags[arg->i] = True;
|
|
|
|
sel->tags[arg->i] = True;
|
|
|
|
arrange();
|
|
|
|
lt->arrange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
togglemode(Arg *arg) {
|
|
|
|
togglelayout(Arg *arg) {
|
|
|
|
arrange = (arrange == dofloat) ? dotile : dofloat;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < nlayouts && lt != &layout[i]; i++);
|
|
|
|
|
|
|
|
if(i == nlayouts - 1)
|
|
|
|
|
|
|
|
lt = &layout[0];
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
lt = &layout[++i];
|
|
|
|
if(sel)
|
|
|
|
if(sel)
|
|
|
|
arrange();
|
|
|
|
lt->arrange();
|
|
|
|
else
|
|
|
|
else
|
|
|
|
drawstatus();
|
|
|
|
drawstatus();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -283,7 +305,7 @@ toggleview(Arg *arg) {
|
|
|
|
for(i = 0; i < ntags && !seltag[i]; i++);
|
|
|
|
for(i = 0; i < ntags && !seltag[i]; i++);
|
|
|
|
if(i == ntags)
|
|
|
|
if(i == ntags)
|
|
|
|
seltag[arg->i] = True; /* cannot toggle last view */
|
|
|
|
seltag[arg->i] = True; /* cannot toggle last view */
|
|
|
|
arrange();
|
|
|
|
lt->arrange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
@ -294,5 +316,5 @@ view(Arg *arg) {
|
|
|
|
seltag[i] = (arg->i == -1) ? True : False;
|
|
|
|
seltag[i] = (arg->i == -1) ? True : False;
|
|
|
|
if(arg->i >= 0 && arg->i < ntags)
|
|
|
|
if(arg->i >= 0 && arg->i < ntags)
|
|
|
|
seltag[arg->i] = True;
|
|
|
|
seltag[arg->i] = True;
|
|
|
|
arrange();
|
|
|
|
lt->arrange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|