add auto option to float in rules

This commit is contained in:
Julien Danjou 2008-01-06 22:21:23 +01:00
parent 7ad579898f
commit 4fbce766bf
6 changed files with 35 additions and 5 deletions

View File

@ -426,7 +426,7 @@ rules
name = <regex> name = <regex>
xproperty_name = <string> xproperty_name = <string>
xproperty_value = <regex> xproperty_value = <regex>
float = <boolean> float = <{auto,true,false}>
tags = <regex> tags = <regex>
screen = <integer> screen = <integer>
icon = <image> icon = <image>

View File

@ -668,7 +668,7 @@ config_parse(const char *confpatharg)
CFG_STR((char *) "name", NULL, CFGF_NONE), CFG_STR((char *) "name", NULL, CFGF_NONE),
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_BOOL((char *) "float", cfg_false, CFGF_NONE), CFG_STR((char *) "float", (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_BOOL((char *) "not_master", cfg_false, CFGF_NONE),
CFG_END() CFG_END()
@ -776,7 +776,7 @@ 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 = cfg_getbool(cfgsectmp, "float"); rule->isfloating = rules_get_float_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->not_master = cfg_getbool(cfgsectmp, "not_master");
if(rule->screen >= get_screen_count()) if(rule->screen >= get_screen_count())

View File

@ -36,6 +36,13 @@ typedef enum
Off Off
} Position; } Position;
typedef enum
{
Float,
Tile,
Auto,
} RuleFloat;
/** Common colors */ /** Common colors */
enum enum
{ ColBorder, ColFG, ColBG, ColLast }; { ColBorder, ColFG, ColBG, ColLast };
@ -49,7 +56,7 @@ struct Rule
char *icon; char *icon;
char *xprop; char *xprop;
int screen; int screen;
Bool isfloating; RuleFloat isfloating;
Bool not_master; Bool not_master;
regex_t *prop_r; regex_t *prop_r;
regex_t *tags_r; regex_t *tags_r;

12
rules.c
View File

@ -97,4 +97,16 @@ is_tag_match_rules(Tag *t, Rule *r)
return False; 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 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -29,6 +29,7 @@
regex_t * rules_compile_regex(char *); regex_t * rules_compile_regex(char *);
Bool client_match_rule(Client *, Rule *); Bool client_match_rule(Client *, Rule *);
Bool is_tag_match_rules(Tag *, Rule *); Bool is_tag_match_rules(Tag *, Rule *);
RuleFloat rules_get_float_from_str(const char *);
#endif #endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

12
tag.c
View File

@ -121,7 +121,17 @@ tag_client_with_rules(Client *c)
for(r = globalconf.rules; r; r = r->next) for(r = globalconf.rules; r; r = r->next)
if(client_match_rule(c, r)) 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) if(r->screen != RULE_NOSCREEN && r->screen != c->screen)
move_client_to_screen(c, r->screen, True); move_client_to_screen(c, r->screen, True);