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_name = <string>
xproperty_value = <regex> xproperty_value = <regex>
float = <{auto,true,false}> float = <{auto,true,false}>
master = <{auto,true,false}>
tags = <regex> tags = <regex>
screen = <integer> screen = <integer>
icon = <image> icon = <image>
not_master = <boolean>
opacity = <float> opacity = <float>
} }
} }

View File

@ -351,10 +351,10 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
{ {
case Auto: case Auto:
break; break;
case Float: case Yes:
client_setfloating(c, True); client_setfloating(c, True);
break; break;
case Tile: case No:
client_setfloating(c, False); client_setfloating(c, False);
break; break;
} }
@ -391,12 +391,27 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
} }
/* attach to the stack */ /* attach to the stack */
if((rule = rule_matching_client(c)) && rule->not_master) 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); client_list_append(&globalconf.clients, c);
else if(globalconf.screens[c->screen].new_become_master) break;
case Auto:
rule = NULL;
break;
}
if(!rule)
{
if(globalconf.screens[c->screen].new_become_master)
client_list_push(&globalconf.clients, c); client_list_push(&globalconf.clients, c);
else else
client_list_append(&globalconf.clients, c); client_list_append(&globalconf.clients, c);
}
/* some windows require this */ /* some windows require this */
XMoveResizeWindow(globalconf.display, c->win, c->geometry.x, c->geometry.y, 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 *) "tags", NULL, CFGF_NONE),
CFG_STR((char *) "icon", NULL, CFGF_NONE), CFG_STR((char *) "icon", NULL, CFGF_NONE),
CFG_STR((char *) "float", (char *) "auto", 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_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_FLOAT((char *) "opacity", -1.0f, CFGF_NONE),
CFG_END() CFG_END()
}; };

View File

@ -494,9 +494,9 @@ config_parse(const char *confpatharg)
rule->xprop = a_strdup(cfg_getstr(cfgsectmp, "xproperty_name")); rule->xprop = a_strdup(cfg_getstr(cfgsectmp, "xproperty_name"));
rule->xpropval_r = rules_compile_regex(cfg_getstr(cfgsectmp, "xproperty_value")); rule->xpropval_r = rules_compile_regex(cfg_getstr(cfgsectmp, "xproperty_value"));
rule->icon = a_strdup(cfg_getstr(cfgsectmp, "icon")); 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->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"); rule->opacity = cfg_getfloat(cfgsectmp, "opacity");
if(rule->screen >= globalconf.nscreen) if(rule->screen >= globalconf.nscreen)
rule->screen = 0; rule->screen = 0;

View File

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

View File

@ -28,7 +28,7 @@
regex_t * rules_compile_regex(char *); regex_t * rules_compile_regex(char *);
Bool tag_match_rule(Tag *, Rule *); 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 *); Rule * rule_matching_client(Client *);
DO_SLIST(Rule, rule, p_delete); DO_SLIST(Rule, rule, p_delete);

View File

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