remove Regs struct, use Rules
This commit is contained in:
parent
fa28ccd70a
commit
4a7acf821e
|
@ -197,8 +197,6 @@ setup(awesome_config *awesomeconf)
|
||||||
|
|
||||||
grabkeys(awesomeconf->display, awesomeconf->phys_screen, awesomeconf);
|
grabkeys(awesomeconf->display, awesomeconf->phys_screen, awesomeconf);
|
||||||
|
|
||||||
compileregs(awesomeconf->rules, awesomeconf->nrules);
|
|
||||||
|
|
||||||
/* bar */
|
/* bar */
|
||||||
initstatusbar(awesomeconf->display, awesomeconf->screen, &awesomeconf->statusbar, awesomeconf->cursor[CurNormal], awesomeconf->font, awesomeconf->layouts, awesomeconf->nlayouts);
|
initstatusbar(awesomeconf->display, awesomeconf->screen, &awesomeconf->statusbar, awesomeconf->cursor[CurNormal], awesomeconf->font, awesomeconf->layouts, awesomeconf->nlayouts);
|
||||||
}
|
}
|
||||||
|
|
2
config.c
2
config.c
|
@ -342,6 +342,8 @@ parse_config(Display * disp, int scr,const char *confpatharg, awesome_config *aw
|
||||||
awesomeconf->rules[i].isfloating = cfg_getbool(cfgsectmp, "float");
|
awesomeconf->rules[i].isfloating = cfg_getbool(cfgsectmp, "float");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileregs(awesomeconf->rules, awesomeconf->nrules);
|
||||||
|
|
||||||
/* Tags */
|
/* Tags */
|
||||||
|
|
||||||
awesomeconf->ntags = cfg_size(cfg_tags, "tag");
|
awesomeconf->ntags = cfg_size(cfg_tags, "tag");
|
||||||
|
|
3
config.h
3
config.h
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
|
#include <regex.h>
|
||||||
|
|
||||||
/** Bar possible position */
|
/** Bar possible position */
|
||||||
enum
|
enum
|
||||||
|
@ -40,6 +41,8 @@ typedef struct
|
||||||
char *prop;
|
char *prop;
|
||||||
char *tags;
|
char *tags;
|
||||||
Bool isfloating;
|
Bool isfloating;
|
||||||
|
regex_t *propregex;
|
||||||
|
regex_t *tagregex;
|
||||||
} Rule;
|
} Rule;
|
||||||
|
|
||||||
typedef struct awesome_config awesome_config;
|
typedef struct awesome_config awesome_config;
|
||||||
|
|
21
tag.c
21
tag.c
|
@ -26,14 +26,6 @@
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
regex_t *propregex;
|
|
||||||
regex_t *tagregex;
|
|
||||||
} Regs;
|
|
||||||
|
|
||||||
static Regs *regs = NULL;
|
|
||||||
|
|
||||||
/** This function returns the index of
|
/** This function returns the index of
|
||||||
* the tag given un argument in *tags
|
* the tag given un argument in *tags
|
||||||
* \param tag_to_find tag name
|
* \param tag_to_find tag name
|
||||||
|
@ -75,11 +67,11 @@ applyrules(Client * c, awesome_config *awesomeconf)
|
||||||
snprintf(prop, len + 3, "%s:%s:%s",
|
snprintf(prop, len + 3, "%s:%s:%s",
|
||||||
ch.res_class ? ch.res_class : "", ch.res_name ? ch.res_name : "", c->name);
|
ch.res_class ? ch.res_class : "", ch.res_name ? ch.res_name : "", c->name);
|
||||||
for(i = 0; i < awesomeconf->nrules; i++)
|
for(i = 0; i < awesomeconf->nrules; i++)
|
||||||
if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0))
|
if(awesomeconf->rules[i].propregex && !regexec(awesomeconf->rules[i].propregex, prop, 1, &tmp, 0))
|
||||||
{
|
{
|
||||||
c->isfloating = awesomeconf->rules[i].isfloating;
|
c->isfloating = awesomeconf->rules[i].isfloating;
|
||||||
for(j = 0; regs[i].tagregex && j < awesomeconf->ntags; j++)
|
for(j = 0; awesomeconf->rules[i].tagregex && j < awesomeconf->ntags; j++)
|
||||||
if(!regexec(regs[i].tagregex, awesomeconf->tags[j].name, 1, &tmp, 0))
|
if(!regexec(awesomeconf->rules[i].tagregex, awesomeconf->tags[j].name, 1, &tmp, 0))
|
||||||
{
|
{
|
||||||
matched = True;
|
matched = True;
|
||||||
c->tags[j] = True;
|
c->tags[j] = True;
|
||||||
|
@ -103,9 +95,6 @@ compileregs(Rule * rules, int nrules)
|
||||||
int i;
|
int i;
|
||||||
regex_t *reg;
|
regex_t *reg;
|
||||||
|
|
||||||
if(regs)
|
|
||||||
return;
|
|
||||||
regs = p_new(Regs, nrules);
|
|
||||||
for(i = 0; i < nrules; i++)
|
for(i = 0; i < nrules; i++)
|
||||||
{
|
{
|
||||||
if(rules[i].prop)
|
if(rules[i].prop)
|
||||||
|
@ -114,7 +103,7 @@ compileregs(Rule * rules, int nrules)
|
||||||
if(regcomp(reg, rules[i].prop, REG_EXTENDED))
|
if(regcomp(reg, rules[i].prop, REG_EXTENDED))
|
||||||
p_delete(®);
|
p_delete(®);
|
||||||
else
|
else
|
||||||
regs[i].propregex = reg;
|
rules[i].propregex = reg;
|
||||||
}
|
}
|
||||||
if(rules[i].tags)
|
if(rules[i].tags)
|
||||||
{
|
{
|
||||||
|
@ -122,7 +111,7 @@ compileregs(Rule * rules, int nrules)
|
||||||
if(regcomp(reg, rules[i].tags, REG_EXTENDED))
|
if(regcomp(reg, rules[i].tags, REG_EXTENDED))
|
||||||
p_delete(®);
|
p_delete(®);
|
||||||
else
|
else
|
||||||
regs[i].tagregex = reg;
|
rules[i].tagregex = reg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue