diff --git a/dwm/dwm.c b/dwm/dwm.c --- a/dwm/dwm.c +++ b/dwm/dwm.c @@ -126,6 +126,7 @@ const char *class; const char *instance; const char *title; + const char *role; unsigned int tags; Bool isfloating, centre; int monitor; @@ -295,10 +296,29 @@ /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; +char * +getprop(Window w, const char *prop) +{ + Atom atom, adummy; + unsigned char *val = NULL; + int idummy; + unsigned long ldummy; + + atom = XInternAtom(dpy, prop, True); + + if(atom) + XGetWindowProperty(dpy, w, atom, 0, BUFSIZ, False, XA_STRING, + &adummy, &idummy, &ldummy, &ldummy, &val); + + return (char *)val; +} + + + /* function implementations */ void applyrules(Client *c) { - const char *class, *instance; + const char *class, *instance, *role; char centre = 1; unsigned int i; const Rule *r; @@ -310,11 +330,13 @@ if(XGetClassHint(dpy, c->win, &ch)) { class = ch.res_class ? ch.res_class : broken; instance = ch.res_name ? ch.res_name : broken; + role = (role = getprop(c->win, "WM_WINDOW_ROLE")) ? role : broken; for(i = 0; i < LENGTH(rules); i++) { r = &rules[i]; if((!r->title || strstr(c->name, r->title)) && (!r->class || strstr(class, r->class)) - && (!r->instance || strstr(instance, r->instance))) + && (!r->instance || strstr(instance, r->instance)) + && (!r->role || strstr(role, r->role))) { c->isfloating = r->isfloating; c->tags |= r->tags;