Merge pull request #41 from kidanger/master

Ajoute la possibilité de créer une règle "par défaut".
This commit is contained in:
Martin Duquesnoy 2012-04-15 13:32:36 -07:00
commit 7aaae95b6c

View File

@ -847,6 +847,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
@ -855,6 +885,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;
@ -883,8 +914,11 @@ client_apply_rule(struct client *c)
XFree(data); XFree(data);
} }
/* 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 +929,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;
} }
@ -930,6 +938,10 @@ client_apply_rule(struct client *c)
if(wmname) if(wmname)
free(wmname); free(wmname);
/* Apply default rule */
if (!(c->flags & CLIENT_RULED) && defaultr != NULL)
_apply_rule(c, defaultr);
} }
struct client* struct client*