From fb1627e8cc74ce3991130926adea14815df52aba Mon Sep 17 00:00:00 2001 From: Raphael Khaiat Date: Wed, 5 Jan 2011 01:25:12 +0100 Subject: [PATCH] Fix Feature #22 : set a default tag and/or screen where to send client that have no tag/screen specific rule. Feature requested by philpep --- src/client.c | 27 ++++++++++++++++++++++++++- src/config.c | 2 ++ src/structs.h | 2 ++ src/tag.c | 2 +- wmfsrc | 3 +++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/client.c b/src/client.c index a0486af..e966cb3 100644 --- a/src/client.c +++ b/src/client.c @@ -1007,6 +1007,8 @@ client_set_rules(Client *c) ulong n, il; uchar *data = NULL; char wwrole[256] = { 0 }; + Bool applied_tag_rule = False; + Bool applied_screen_rule = False; memset(&xch, 0, sizeof(xch)); @@ -1060,6 +1062,10 @@ client_set_rules(Client *c) } tags[c->screen][c->tag].layout.func(c->screen); + + /* Deprecated but still in use */ + applied_tag_rule = True; + applied_screen_rule = True; } /* }}} */ @@ -1076,7 +1082,10 @@ client_set_rules(Client *c) c->screen = conf.rule[i].screen; if(conf.rule[i].tag != -1) + { c->tag = conf.rule[i].tag; + applied_tag_rule = True; + } if(conf.rule[i].free) c->flags |= FreeFlag; @@ -1096,12 +1105,28 @@ client_set_rules(Client *c) client_focus(NULL); } - if(! conf.rule[i].ignoretags) + if(!conf.rule[i].ignoretags) tags[c->screen][c->tag].layout.func(c->screen); } } } + if(!applied_tag_rule && conf.client.default_open_tag > 0 && conf.client.default_open_tag < (uint)conf.ntag[selscreen]) + { + c->tag = conf.client.default_open_tag; + + client_focus_next(c); + tags[c->screen][c->tag].request_update = True; + } + + if(!applied_screen_rule && conf.client.default_open_screen > -1 && conf.client.default_open_screen < screen_count()) + { + c->screen = conf.client.default_open_screen; + + client_focus_next(c); + tags[c->screen][c->tag].request_update = True; + } + return; } diff --git a/src/config.c b/src/config.c index 6afa98c..d024433 100644 --- a/src/config.c +++ b/src/config.c @@ -286,6 +286,8 @@ conf_client_section(void) conf.client.padding = fetch_opt_first(sec, "0", "padding").num; conf.client.autofree = fetch_opt_first(sec, "", "autofree").str; conf.client.automax = fetch_opt_first(sec, "", "automax").str; + conf.client.default_open_tag = fetch_opt_first(sec, "0", "default_open_tag").num; + conf.client.default_open_screen = fetch_opt_first(sec, "-1", "default_open_screen").num; mouse = fetch_section(sec, "mouse"); diff --git a/src/structs.h b/src/structs.h index 3ed0243..364fa41 100644 --- a/src/structs.h +++ b/src/structs.h @@ -443,6 +443,8 @@ typedef struct uint padding; MouseBinding *mouse; int nmouse; + uint default_open_tag; + int default_open_screen; } client; struct { diff --git a/src/tag.c b/src/tag.c index 6b02f15..c9fe731 100644 --- a/src/tag.c +++ b/src/tag.c @@ -58,7 +58,7 @@ tag_set(int tag) { if(tag <= 0) seltag[selscreen] = conf.ntag[selscreen]; - else if(tag > conf.ntag[selscreen]) + else if(tag > conf.ntag[selscreen]) seltag[selscreen] = 1; else seltag[selscreen] = tag; diff --git a/wmfsrc b/wmfsrc index 2955efc..9eb2a1b 100644 --- a/wmfsrc +++ b/wmfsrc @@ -163,6 +163,9 @@ resize_corner_normal = "#191919" resize_corner_focus = "#003366" +# default_open_tag = 4 # send all client that have no tag rule in this default tag +# default_open_screen = 1 # same as above but for the screen + # Space between tiled clients padding = 0