From 4fbce766bfade4b36454fe432ed10df0810fb7f7 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 6 Jan 2008 22:21:23 +0100 Subject: [PATCH] add auto option to float in rules --- awesomerc.1.txt | 2 +- config.c | 4 ++-- config.h | 9 ++++++++- rules.c | 12 ++++++++++++ rules.h | 1 + tag.c | 12 +++++++++++- 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/awesomerc.1.txt b/awesomerc.1.txt index 17cccfb6a..7b5043327 100644 --- a/awesomerc.1.txt +++ b/awesomerc.1.txt @@ -426,7 +426,7 @@ rules name = xproperty_name = xproperty_value = - float = + float = <{auto,true,false}> tags = screen = icon = diff --git a/config.c b/config.c index 918d349e5..5398b1f54 100644 --- a/config.c +++ b/config.c @@ -668,7 +668,7 @@ config_parse(const char *confpatharg) CFG_STR((char *) "name", NULL, CFGF_NONE), CFG_STR((char *) "tags", NULL, CFGF_NONE), CFG_STR((char *) "icon", NULL, CFGF_NONE), - CFG_BOOL((char *) "float", cfg_false, CFGF_NONE), + CFG_STR((char *) "float", (char *) "auto", CFGF_NONE), CFG_INT((char *) "screen", RULE_NOSCREEN, CFGF_NONE), CFG_BOOL((char *) "not_master", cfg_false, CFGF_NONE), CFG_END() @@ -776,7 +776,7 @@ 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 = cfg_getbool(cfgsectmp, "float"); + rule->isfloating = rules_get_float_from_str(cfg_getstr(cfgsectmp, "float")); rule->screen = cfg_getint(cfgsectmp, "screen"); rule->not_master = cfg_getbool(cfgsectmp, "not_master"); if(rule->screen >= get_screen_count()) diff --git a/config.h b/config.h index 754507164..2b065c540 100644 --- a/config.h +++ b/config.h @@ -36,6 +36,13 @@ typedef enum Off } Position; +typedef enum +{ + Float, + Tile, + Auto, +} RuleFloat; + /** Common colors */ enum { ColBorder, ColFG, ColBG, ColLast }; @@ -49,7 +56,7 @@ struct Rule char *icon; char *xprop; int screen; - Bool isfloating; + RuleFloat isfloating; Bool not_master; regex_t *prop_r; regex_t *tags_r; diff --git a/rules.c b/rules.c index 8e2800d8e..533a6d869 100644 --- a/rules.c +++ b/rules.c @@ -97,4 +97,16 @@ is_tag_match_rules(Tag *t, Rule *r) return False; } + +RuleFloat +rules_get_float_from_str(const char *str) +{ + if(!a_strcmp(str, "true") || !a_strcmp(str, "yes")) + return Float; + else if(!a_strcmp(str, "false") || !a_strcmp(str, "no")) + return Tile; + + return Auto; +} + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/rules.h b/rules.h index 390b76a40..2664eb937 100644 --- a/rules.h +++ b/rules.h @@ -29,6 +29,7 @@ regex_t * rules_compile_regex(char *); Bool client_match_rule(Client *, Rule *); Bool is_tag_match_rules(Tag *, Rule *); +RuleFloat rules_get_float_from_str(const char *); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/tag.c b/tag.c index 66386950e..c5dde1ede 100644 --- a/tag.c +++ b/tag.c @@ -121,7 +121,17 @@ tag_client_with_rules(Client *c) for(r = globalconf.rules; r; r = r->next) if(client_match_rule(c, r)) { - c->isfloating = r->isfloating; + switch(r->isfloating) + { + case Tile: + c->isfloating = False; + break; + case Float: + c->isfloating = True; + break; + default: + break; + } if(r->screen != RULE_NOSCREEN && r->screen != c->screen) move_client_to_screen(c, r->screen, True);