clean code
This commit is contained in:
95
src/client.c
95
src/client.c
@@ -846,6 +846,36 @@ client_frame_new(struct client *c)
|
|||||||
XReparentWindow(W->dpy, c->win, c->frame, c->border, c->tbarw);
|
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 RINSTANCE 0x01
|
||||||
#define RCLASS 0x02
|
#define RCLASS 0x02
|
||||||
#define RROLE 0x04
|
#define RROLE 0x04
|
||||||
@@ -854,6 +884,7 @@ static void
|
|||||||
client_apply_rule(struct client *c)
|
client_apply_rule(struct client *c)
|
||||||
{
|
{
|
||||||
struct rule *r;
|
struct rule *r;
|
||||||
|
struct rule *defaultr = NULL;
|
||||||
char *wmname = NULL;
|
char *wmname = NULL;
|
||||||
char *role = NULL;
|
char *role = NULL;
|
||||||
int f;
|
int f;
|
||||||
@@ -882,9 +913,11 @@ client_apply_rule(struct client *c)
|
|||||||
XFree(data);
|
XFree(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply a specific rule
|
/* Apply a specific rule */
|
||||||
SLIST_FOREACH(r, &W->h.rule, next)
|
SLIST_FOREACH(r, &W->h.rule, next)
|
||||||
{
|
{
|
||||||
|
if (r->instance && !strcmp(r->instance, "*"))
|
||||||
|
defaultr = r;
|
||||||
if(s)
|
if(s)
|
||||||
{
|
{
|
||||||
FLAGAPPLY(flags, (xch.res_name && r->instance && !strcmp(xch.res_name, r->instance)), RINSTANCE);
|
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);
|
FLAGAPPLY(flags, ((role && r->role && !strcmp(role, r->role)) || !role || !r->role), RROLE);
|
||||||
|
|
||||||
if(flags & (RINSTANCE | RCLASS | RNAME) && flags & RROLE)
|
if(flags & (RINSTANCE | RCLASS | RNAME) && flags & RROLE)
|
||||||
{
|
_apply_rule(c, 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;
|
|
||||||
}
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -931,35 +938,9 @@ client_apply_rule(struct client *c)
|
|||||||
if(wmname)
|
if(wmname)
|
||||||
free(wmname);
|
free(wmname);
|
||||||
|
|
||||||
// Apply default rule
|
/* Apply default rule */
|
||||||
if (!(c->flags & CLIENT_RULED) && (r = W->crule) != NULL)
|
if (!(c->flags & CLIENT_RULED) && defaultr != NULL)
|
||||||
{
|
_apply_rule(c, defaultr);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct client*
|
struct client*
|
||||||
|
|||||||
@@ -261,7 +261,6 @@ config_rule(void)
|
|||||||
n = fetch_section_count(ks);
|
n = fetch_section_count(ks);
|
||||||
|
|
||||||
SLIST_INIT(&W->h.rule);
|
SLIST_INIT(&W->h.rule);
|
||||||
W->crule = NULL;
|
|
||||||
|
|
||||||
/* [rule] */
|
/* [rule] */
|
||||||
for(i = 0; i < n; ++i)
|
for(i = 0; i < n; ++i)
|
||||||
@@ -285,12 +284,7 @@ config_rule(void)
|
|||||||
else
|
else
|
||||||
r->theme = W->ctheme;
|
r->theme = W->ctheme;
|
||||||
|
|
||||||
if (r->name && !strcmp(r->name, "default"))
|
SLIST_INSERT_HEAD(&W->h.rule, r, next);
|
||||||
{
|
|
||||||
W->crule = r;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SLIST_INSERT_HEAD(&W->h.rule, r, next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(ks);
|
free(ks);
|
||||||
|
|||||||
@@ -349,7 +349,6 @@ struct wmfs
|
|||||||
char *confpath;
|
char *confpath;
|
||||||
struct barwin *last_clicked_barwin;
|
struct barwin *last_clicked_barwin;
|
||||||
struct theme *ctheme;
|
struct theme *ctheme;
|
||||||
struct rule *crule;
|
|
||||||
|
|
||||||
/* Log file */
|
/* Log file */
|
||||||
FILE *log;
|
FILE *log;
|
||||||
|
|||||||
Reference in New Issue
Block a user