dwm-custom/patch/sizehints_ruled.c

34 lines
869 B
C
Raw Normal View History

2024-05-22 17:29:40 +02:00
void
checkfloatingrules(Client *c)
{
const char *class, *instance;
Atom wintype;
char role[64];
unsigned int i;
const Rule *r;
XClassHint ch = { NULL, NULL };
XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : broken;
instance = ch.res_name ? ch.res_name : broken;
wintype = getatomprop(c, netatom[NetWMWindowType], XA_ATOM);
gettextprop(c->win, wmatom[WMWindowRole], role, sizeof(role));
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->role || strstr(role, r->role))
&& (!r->instance || strstr(instance, r->instance))
&& (!r->wintype || wintype == XInternAtom(dpy, r->wintype, False)))
{
c->isfloating = r->isfloating;
}
}
if (ch.res_class)
XFree(ch.res_class);
if (ch.res_name)
XFree(ch.res_name);
}