From befcf19ea27bcbc3a5a3c66bc903f012ce39f8e8 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 5 Feb 2008 17:31:37 +0100 Subject: [PATCH] introduce fuzzy logic: fix problem with not_master --- awesomerc.1.txt | 2 +- client.c | 31 +++++++++++++++++++++++-------- common/configopts.c | 2 +- config.c | 4 ++-- rules.c | 8 ++++---- rules.h | 2 +- structs.h | 12 ++++++------ 7 files changed, 38 insertions(+), 23 deletions(-) diff --git a/awesomerc.1.txt b/awesomerc.1.txt index 1135ffd1..39e9f411 100644 --- a/awesomerc.1.txt +++ b/awesomerc.1.txt @@ -519,10 +519,10 @@ rules xproperty_name = xproperty_value = float = <{auto,true,false}> + master = <{auto,true,false}> tags = screen = icon = - not_master = opacity = } } diff --git a/client.c b/client.c index 2c2c2e38..0e7fe9ca 100644 --- a/client.c +++ b/client.c @@ -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, diff --git a/common/configopts.c b/common/configopts.c index fa1f2b1a..608939a9 100644 --- a/common/configopts.c +++ b/common/configopts.c @@ -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() }; diff --git a/config.c b/config.c index a95eadaa..c1f875ae 100644 --- a/config.c +++ b/config.c @@ -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; diff --git a/rules.c b/rules.c index ab080f76..5cd5305d 100644 --- a/rules.c +++ b/rules.c @@ -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; } diff --git a/rules.h b/rules.h index 90e4f6ec..2a629350 100644 --- a/rules.h +++ b/rules.h @@ -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); diff --git a/structs.h b/structs.h index 8d932826..179af002 100644 --- a/structs.h +++ b/structs.h @@ -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;