From 69ec9d7db05d3d4d838976923b4edbc17adae4d6 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Fri, 29 Jul 2011 17:17:21 +0200 Subject: [PATCH] Apply pierreN patch: _NET_WM_NAME attribute in rules --- src/client.c | 16 ++++++++++++++-- src/config.c | 1 + src/structs.h | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/client.c b/src/client.c index 8239696..2a4417e 100644 --- a/src/client.c +++ b/src/client.c @@ -590,6 +590,7 @@ client_set_rules(Client *c) ulong n, il; uchar *data = NULL; char wwrole[256] = { 0 }; + char netwmname[256] = { 0 }; bool applied_tag_rule = False; bool applied_screen_rule = False; @@ -612,14 +613,25 @@ client_set_rules(Client *c) XFree(data); } - /* Apply Rule if class || instance || role match */ + /* Get _NET_WM_NAME */ + if(XGetWindowProperty(dpy, c->win, ATOM("_NET_WM_NAME"), 0, 0x77777777, False, + ATOM("UTF8_STRING"), &rf, &f, &n, &il, &data) == Success && data) + { + strncpy(netwmname, (char*)data, sizeof(netwmname)); + XFree(data); + } + + /* Apply Rule if class || instance || role || name match */ for(i = 0; i < conf.nrule; ++i) { if((xch.res_class && conf.rule[i].class && !strcmp(xch.res_class, conf.rule[i].class)) || (xch.res_name && conf.rule[i].instance && !strcmp(xch.res_name, conf.rule[i].instance))) { - if((strlen(wwrole) && conf.rule[i].role && !strcmp(wwrole, conf.rule[i].role)) + if( ((strlen(wwrole) && conf.rule[i].role && !strcmp(wwrole, conf.rule[i].role)) || (!strlen(wwrole) || !conf.rule[i].role)) + && + ((strlen(netwmname) && conf.rule[i].name && !strcmp(netwmname, conf.rule[i].name)) + || (!strlen(netwmname) || !conf.rule[i].name)) ) { if(conf.rule[i].screen != -1) c->screen = conf.rule[i].screen; diff --git a/src/config.c b/src/config.c index 5542fe9..e5a8e8f 100644 --- a/src/config.c +++ b/src/config.c @@ -678,6 +678,7 @@ conf_rule_section(void) conf.rule[i].class = fetch_opt_first(rule[i], "", "class").str; conf.rule[i].instance = fetch_opt_first(rule[i], "", "instance").str; conf.rule[i].role = fetch_opt_first(rule[i], "", "role").str; + conf.rule[i].name = fetch_opt_first(rule[i], "", "name").str; conf.rule[i].screen = fetch_opt_first(rule[i], "-1", "screen").num; conf.rule[i].tag = fetch_opt_first(rule[i], "-1", "tag").num; conf.rule[i].free = fetch_opt_first(rule[i], "false", "free").boolean; diff --git a/src/structs.h b/src/structs.h index 2665ae1..2dcd96a 100644 --- a/src/structs.h +++ b/src/structs.h @@ -384,6 +384,7 @@ typedef struct char *class; char *instance; char *role; + char *name; int screen; int tag; bool free;