clean code

This commit is contained in:
Jérémy Anger 2012-04-12 14:52:47 +02:00
parent 4a186874aa
commit 3540bb1cad
3 changed files with 39 additions and 65 deletions

View File

@ -846,6 +846,36 @@ client_frame_new(struct client *c)
XReparentWindow(W->dpy, c->win, c->frame, c->border, c->tbarw);
}
static void
_apply_rule(struct client *c, struct rule *r)
{
if(r->screen != -1)
c->screen = screen_gb_id(r->screen);
c->tag = c->screen->seltag;
if(r->tag != -1)
c->tag = tag_gb_id(c->screen, r->tag);
c->theme = r->theme;
/* free = false for originally free client */
if(r->flags & RULE_FREE)
c->flags |= CLIENT_FREE;
else
c->flags &= ~CLIENT_FREE;
/* Free rule is not compatible with tab rule */
if(r->flags & RULE_TAB)
W->flags ^= WMFS_TABNOC; /* < can be disable by client_tab_next_opened */
/* TODO
if(r->flags & RULE_IGNORE_TAG)
{}
*/
c->flags |= CLIENT_RULED;
}
#define RINSTANCE 0x01
#define RCLASS 0x02
#define RROLE 0x04
@ -854,6 +884,7 @@ static void
client_apply_rule(struct client *c)
{
struct rule *r;
struct rule *defaultr = NULL;
char *wmname = NULL;
char *role = NULL;
int f;
@ -882,9 +913,11 @@ client_apply_rule(struct client *c)
XFree(data);
}
// Apply a specific rule
/* Apply a specific rule */
SLIST_FOREACH(r, &W->h.rule, next)
{
if (r->instance && !strcmp(r->instance, "*"))
defaultr = r;
if(s)
{
FLAGAPPLY(flags, (xch.res_name && r->instance && !strcmp(xch.res_name, r->instance)), RINSTANCE);
@ -895,33 +928,7 @@ client_apply_rule(struct client *c)
FLAGAPPLY(flags, ((role && r->role && !strcmp(role, r->role)) || !role || !r->role), RROLE);
if(flags & (RINSTANCE | RCLASS | RNAME) && flags & RROLE)
{
if(r->screen != -1)
c->screen = screen_gb_id(r->screen);
c->tag = c->screen->seltag;
if(r->tag != -1)
c->tag = tag_gb_id(c->screen, r->tag);
c->theme = r->theme;
/* free = false for originally free client */
if(r->flags & RULE_FREE)
c->flags |= CLIENT_FREE;
else
c->flags &= ~CLIENT_FREE;
/* Free rule is not compatible with tab rule */
if(r->flags & RULE_TAB)
W->flags ^= WMFS_TABNOC; /* < can be disable by client_tab_next_opened */
/* TODO
if(r->flags & RULE_IGNORE_TAG)
{}
*/
c->flags |= CLIENT_RULED;
}
_apply_rule(c, r);
flags = 0;
}
@ -931,35 +938,9 @@ client_apply_rule(struct client *c)
if(wmname)
free(wmname);
// Apply default rule
if (!(c->flags & CLIENT_RULED) && (r = W->crule) != NULL)
{
if(r->screen != -1)
c->screen = screen_gb_id(r->screen);
c->tag = c->screen->seltag;
if(r->tag != -1)
c->tag = tag_gb_id(c->screen, r->tag);
c->theme = r->theme;
/* free = false for originally free client */
if(r->flags & RULE_FREE)
c->flags |= CLIENT_FREE;
else
c->flags &= ~CLIENT_FREE;
/* Free rule is not compatible with tab rule */
if(r->flags & RULE_TAB)
W->flags ^= WMFS_TABNOC; /* < can be disable by client_tab_next_opened */
/* TODO
if(r->flags & RULE_IGNORE_TAG)
{}
*/
c->flags |= CLIENT_RULED;
}
/* Apply default rule */
if (!(c->flags & CLIENT_RULED) && defaultr != NULL)
_apply_rule(c, defaultr);
}
struct client*

View File

@ -261,7 +261,6 @@ config_rule(void)
n = fetch_section_count(ks);
SLIST_INIT(&W->h.rule);
W->crule = NULL;
/* [rule] */
for(i = 0; i < n; ++i)
@ -285,12 +284,7 @@ config_rule(void)
else
r->theme = W->ctheme;
if (r->name && !strcmp(r->name, "default"))
{
W->crule = r;
}
else
SLIST_INSERT_HEAD(&W->h.rule, r, next);
SLIST_INSERT_HEAD(&W->h.rule, r, next);
}
free(ks);

View File

@ -349,7 +349,6 @@ struct wmfs
char *confpath;
struct barwin *last_clicked_barwin;
struct theme *ctheme;
struct rule *crule;
/* Log file */
FILE *log;