mirror of
https://github.com/0intro/wmii
synced 2025-01-07 11:02:11 +03:00
simplified rule.c
This commit is contained in:
parent
3588e0909d
commit
2b3eb084f7
@ -336,11 +336,9 @@ manage_client(Client *c)
|
|||||||
{
|
{
|
||||||
View *v;
|
View *v;
|
||||||
Client *trans;
|
Client *trans;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
if(c->trans && (trans = win2client(c->trans))) {
|
if(c->trans && (trans = win2client(c->trans))) {
|
||||||
for(i = 0; i < trans->ntag; i++)
|
cext_strlcpy(c->tags, trans->tags, sizeof(c->tags));
|
||||||
cext_strlcpy(c->tags, trans->tags, sizeof(c->tags));
|
|
||||||
str2tagvector(&c->tag, c->tags);
|
str2tagvector(&c->tag, c->tags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -349,7 +347,7 @@ manage_client(Client *c)
|
|||||||
reparent_client(c, c->framewin, c->rect.x, c->rect.y);
|
reparent_client(c, c->framewin, c->rect.x, c->rect.y);
|
||||||
|
|
||||||
v = view.size ? view.data[sel] : alloc_view(def.tag);
|
v = view.size ? view.data[sel] : alloc_view(def.tag);
|
||||||
if(!c->ntag) {
|
if(!strlen(c->tags)) {
|
||||||
cext_strlcpy(c->tags, v->name, sizeof(c->tags));
|
cext_strlcpy(c->tags, v->name, sizeof(c->tags));
|
||||||
str2tagvector(&c->tag, c->tags);
|
str2tagvector(&c->tag, c->tags);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ rule2vector(RuleVector *rv)
|
|||||||
void
|
void
|
||||||
update_rules()
|
update_rules()
|
||||||
{
|
{
|
||||||
unsigned int i;
|
|
||||||
int mode = IGNORE;
|
int mode = IGNORE;
|
||||||
char *p, *r = nil, *t = nil, regex[256], tags[256];
|
char *p, *r = nil, *t = nil, regex[256], tags[256];
|
||||||
|
|
||||||
@ -49,14 +48,13 @@ update_rules()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
while(rule.size) {
|
while(rule.size) {
|
||||||
Rule *r = rule.data[i];
|
Rule *r = rule.data[0];
|
||||||
if(r->is_valid)
|
if(r->is_valid)
|
||||||
regfree(&r->regex);
|
regfree(&r->regex);
|
||||||
cext_vdetach(rule2vector(&rule), r);
|
cext_vdetach(rule2vector(&rule), r);
|
||||||
free(r);
|
free(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
|
||||||
for(p = def.rules; *p; p++)
|
for(p = def.rules; *p; p++)
|
||||||
switch(mode) {
|
switch(mode) {
|
||||||
case IGNORE:
|
case IGNORE:
|
||||||
@ -106,14 +104,15 @@ match(Client *c, const char *prop)
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
regmatch_t tmpregm;
|
regmatch_t tmpregm;
|
||||||
|
|
||||||
c->tags[0] = 0;
|
|
||||||
for(i = 0; i < rule.size; i++) {
|
for(i = 0; i < rule.size; i++) {
|
||||||
Rule *r = rule.data[i];
|
Rule *r = rule.data[i];
|
||||||
if(r->is_valid && !regexec(&r->regex, prop, 1, &tmpregm, 0)) {
|
if(r->is_valid && !regexec(&r->regex, prop, 1, &tmpregm, 0)) {
|
||||||
if(!strncmp(r->tags, "~", 2))
|
if(!strncmp(r->tags, "~", 2))
|
||||||
c->floating = True;
|
c->floating = True;
|
||||||
else
|
else {
|
||||||
cext_strlcat(c->tags, r->tags, sizeof(c->tags) - strlen(c->tags));
|
cext_strlcpy(c->tags, r->tags, sizeof(c->tags));
|
||||||
|
str2tagvector(&c->tag, c->tags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,11 @@ void
|
|||||||
update_tags()
|
update_tags()
|
||||||
{
|
{
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
for(i = 0; i < tag.size; i++) {
|
while(tag.size) {
|
||||||
free(tag.data[i]);
|
char *p = tag.data[0];
|
||||||
tag.data[i] = nil;
|
cext_vdetach(tag2vector(&tag), p);
|
||||||
|
free(p);
|
||||||
}
|
}
|
||||||
tag.size = 0;
|
|
||||||
|
|
||||||
for(i = 0; i < client.size; i++) {
|
for(i = 0; i < client.size; i++) {
|
||||||
for(j = 0; j < client.data[i]->tag.size; j++)
|
for(j = 0; j < client.data[i]->tag.size; j++)
|
||||||
|
@ -103,7 +103,6 @@ struct Client {
|
|||||||
char name[256];
|
char name[256];
|
||||||
char tags[256];
|
char tags[256];
|
||||||
TagVector tag;
|
TagVector tag;
|
||||||
unsigned int ntag;
|
|
||||||
char classinst[256];
|
char classinst[256];
|
||||||
int proto;
|
int proto;
|
||||||
unsigned int border;
|
unsigned int border;
|
||||||
|
Loading…
Reference in New Issue
Block a user