From 12fc01b824622b5d07c019026f8607cee466ebcd Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sun, 6 Jun 2010 23:34:11 +0200 Subject: [PATCH] Client: add autofree option in client section (Feature #9 requested by lidstah (and tamtam)) See default wmfsrc --- src/client.c | 12 +++++++++--- src/config.c | 1 + src/structs.h | 1 + src/wmfs.h | 2 +- wmfsrc.in | 4 ++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/client.c b/src/client.c index 4cc1652..fd92502 100644 --- a/src/client.c +++ b/src/client.c @@ -719,7 +719,7 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar) free(t); client_attach(c); - client_set_wanted_tag(c); + client_set_rules(c); client_get_name(c); client_raise(c); client_focus(c); @@ -972,11 +972,11 @@ client_swap(Client *c1, Client *c2) return; } -/** Set the wanted tag of a client +/** Set the wanted tag or autofree of a client *\param c Client pointer */ void -client_set_wanted_tag(Client *c) +client_set_rules(Client *c) { XClassHint xch = { 0 }; int i, j, k; @@ -989,6 +989,12 @@ client_set_wanted_tag(Client *c) XGetClassHint(dpy, c->win, &xch); + /* Auto free */ + if((xch.res_name && strstr(conf.client.autofree, xch.res_name)) + || (xch.res_class && strstr(conf.client.autofree, xch.res_class))) + c->flags |= FreeFlag; + + /* Wanted tag */ for(i = 0; i < screen_count(); ++i) for(j = 1; j < conf.ntag[i] + 1; ++j) if(tags[i][j].clients) diff --git a/src/config.c b/src/config.c index 49b6846..e5bced5 100644 --- a/src/config.c +++ b/src/config.c @@ -269,6 +269,7 @@ conf_client_section(void) conf.client.mod |= char_to_modkey(fetch_opt_first(sec, "Alt", "modifier").str, key_list); conf.client.set_new_win_master = fetch_opt_first(sec, "true", "set_new_win_master").bool; conf.client.padding = fetch_opt_first(sec, "0", "padding").num; + conf.client.autofree = fetch_opt_first(sec, "", "autofree").str; mouse = fetch_section(sec, "mouse"); diff --git a/src/structs.h b/src/structs.h index dca13bc..0847b9e 100644 --- a/src/structs.h +++ b/src/structs.h @@ -396,6 +396,7 @@ typedef struct Bool place_at_mouse; Bool border_shadow; int borderheight; + char *autofree; uint bordernormal; uint borderfocus; uint resizecorner_normal; diff --git a/src/wmfs.h b/src/wmfs.h index 40b3509..c497549 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -187,7 +187,7 @@ void client_raise(Client *c); void client_unhide(Client *c); void client_unmanage(Client *c); void client_unmap(Client *c); -void client_set_wanted_tag(Client *c); +void client_set_rules(Client *c); void client_update_attributes(Client *c); void uicb_client_raise(uicb_t); void uicb_client_next(uicb_t); diff --git a/wmfsrc.in b/wmfsrc.in index cb4f92b..7779ea6 100644 --- a/wmfsrc.in +++ b/wmfsrc.in @@ -127,8 +127,12 @@ # Space between tiled clients padding = 0 + # Modifier for mouse use modifier = "Alt" + # Set automatic free client + # autofree = "xterm|MPlayer" + [mouse] button = "1" func = "client_raise" [/mouse] [mouse] button = "1" func = "mouse_move" [/mouse] [mouse] button = "3" func = "client_raise" [/mouse]