sizehints ruled: have rule checks take window type and role into account ref. #229

This commit is contained in:
bakkeby 2022-02-11 09:44:40 +01:00
parent 4366f72390
commit 24ca9b4243

View File

@ -2,6 +2,10 @@ void
checkfloatingrules(Client *c) checkfloatingrules(Client *c)
{ {
const char *class, *instance; const char *class, *instance;
Atom wintype;
#if WINDOWROLERULE_PATCH
char role[64];
#endif // WINDOWROLERULE_PATCH
unsigned int i; unsigned int i;
const Rule *r; const Rule *r;
XClassHint ch = { NULL, NULL }; XClassHint ch = { NULL, NULL };
@ -9,13 +13,23 @@ checkfloatingrules(Client *c)
XGetClassHint(dpy, c->win, &ch); XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : broken; class = ch.res_class ? ch.res_class : broken;
instance = ch.res_name ? ch.res_name : broken; instance = ch.res_name ? ch.res_name : broken;
wintype = getatomprop(c, netatom[NetWMWindowType]);
#if WINDOWROLERULE_PATCH
gettextprop(c->win, wmatom[WMWindowRole], role, sizeof(role));
#endif // WINDOWROLERULE_PATCH
for (i = 0; i < LENGTH(rules); i++) { for (i = 0; i < LENGTH(rules); i++) {
r = &rules[i]; r = &rules[i];
if ((!r->title || strstr(c->name, r->title)) if ((!r->title || strstr(c->name, r->title))
&& (!r->class || strstr(class, r->class)) && (!r->class || strstr(class, r->class))
&& (!r->instance || strstr(instance, r->instance))) #if WINDOWROLERULE_PATCH
&& (!r->role || strstr(role, r->role))
#endif // WINDOWROLERULE_PATCH
&& (!r->instance || strstr(instance, r->instance))
&& (!r->wintype || wintype == XInternAtom(dpy, r->wintype, False)))
{
c->isfloating = r->isfloating; c->isfloating = r->isfloating;
}
} }
if (ch.res_class) if (ch.res_class)
XFree(ch.res_class); XFree(ch.res_class);