introduce fuzzy logic: fix problem with not_master

This commit is contained in:
Julien Danjou 2008-02-05 17:31:37 +01:00
parent 0e890697ac
commit befcf19ea2
7 changed files with 38 additions and 23 deletions

View File

@ -519,10 +519,10 @@ rules
xproperty_name = <string>
xproperty_value = <regex>
float = <{auto,true,false}>
master = <{auto,true,false}>
tags = <regex>
screen = <integer>
icon = <image>
not_master = <boolean>
opacity = <float>
}
}

View File

@ -351,10 +351,10 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
{
case Auto:
break;
case Float:
case Yes:
client_setfloating(c, True);
break;
case Tile:
case No:
client_setfloating(c, False);
break;
}
@ -391,12 +391,27 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
}
/* attach to the stack */
if((rule = rule_matching_client(c)) && rule->not_master)
client_list_append(&globalconf.clients, c);
else if(globalconf.screens[c->screen].new_become_master)
client_list_push(&globalconf.clients, c);
else
client_list_append(&globalconf.clients, c);
if((rule = rule_matching_client(c)))
switch(rule->ismaster)
{
case Yes:
client_list_push(&globalconf.clients, c);
break;
case No:
client_list_append(&globalconf.clients, c);
break;
case Auto:
rule = NULL;
break;
}
if(!rule)
{
if(globalconf.screens[c->screen].new_become_master)
client_list_push(&globalconf.clients, c);
else
client_list_append(&globalconf.clients, c);
}
/* some windows require this */
XMoveResizeWindow(globalconf.display, c->win, c->geometry.x, c->geometry.y,

View File

@ -238,8 +238,8 @@ cfg_opt_t rule_opts[] =
CFG_STR((char *) "tags", NULL, CFGF_NONE),
CFG_STR((char *) "icon", NULL, CFGF_NONE),
CFG_STR((char *) "float", (char *) "auto", CFGF_NONE),
CFG_STR((char *) "master", (char *) "auto", CFGF_NONE),
CFG_INT((char *) "screen", RULE_NOSCREEN, CFGF_NONE),
CFG_BOOL((char *) "not_master", cfg_false, CFGF_NONE),
CFG_FLOAT((char *) "opacity", -1.0f, CFGF_NONE),
CFG_END()
};

View File

@ -494,9 +494,9 @@ config_parse(const char *confpatharg)
rule->xprop = a_strdup(cfg_getstr(cfgsectmp, "xproperty_name"));
rule->xpropval_r = rules_compile_regex(cfg_getstr(cfgsectmp, "xproperty_value"));
rule->icon = a_strdup(cfg_getstr(cfgsectmp, "icon"));
rule->isfloating = rules_get_float_from_str(cfg_getstr(cfgsectmp, "float"));
rule->isfloating = rules_get_fuzzy_from_str(cfg_getstr(cfgsectmp, "float"));
rule->screen = cfg_getint(cfgsectmp, "screen");
rule->not_master = cfg_getbool(cfgsectmp, "not_master");
rule->ismaster = rules_get_fuzzy_from_str(cfg_getstr(cfgsectmp, "master"));
rule->opacity = cfg_getfloat(cfgsectmp, "opacity");
if(rule->screen >= globalconf.nscreen)
rule->screen = 0;

View File

@ -107,13 +107,13 @@ rule_matching_client(Client *c)
return NULL;
}
RuleFloat
rules_get_float_from_str(const char *str)
Fuzzy
rules_get_fuzzy_from_str(const char *str)
{
if(!a_strcmp(str, "true") || !a_strcmp(str, "yes"))
return Float;
return Yes;
else if(!a_strcmp(str, "false") || !a_strcmp(str, "no"))
return Tile;
return No;
return Auto;
}

View File

@ -28,7 +28,7 @@
regex_t * rules_compile_regex(char *);
Bool tag_match_rule(Tag *, Rule *);
RuleFloat rules_get_float_from_str(const char *);
Fuzzy rules_get_fuzzy_from_str(const char *);
Rule * rule_matching_client(Client *);
DO_SLIST(Rule, rule, p_delete);

View File

@ -40,10 +40,10 @@ typedef enum
/** Rules for floating rule */
typedef enum
{
Float,
Tile,
Auto,
} RuleFloat;
Yes,
No,
Auto
} Fuzzy;
/** Common colors */
enum
@ -60,8 +60,8 @@ struct Rule
char *icon;
char *xprop;
int screen;
RuleFloat isfloating;
Bool not_master;
Fuzzy isfloating;
Fuzzy ismaster;
double opacity;
regex_t *prop_r;
regex_t *tags_r;