Detect Polybar

This commit is contained in:
Alex Kotov 2021-12-05 18:05:23 +05:00
parent 30bc46a7d0
commit 9ff7725016
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
2 changed files with 42 additions and 2 deletions

View File

@ -209,6 +209,7 @@ static void updatesizehints(Client *c);
static void updatetitle(Client *c);
static void updatewindowtype(Client *c);
static void updatewmhints(Client *c);
static bool winpolybar(Window w);
static Client *wintoclient(Window w);
static Monitor *wintomon(Window w);
static void wmcheckwin_create();
@ -1731,7 +1732,9 @@ void scan()
continue;
}
if (
if (winpolybar(wins[i])) {
// do nothing
} else if (
wa.map_state == IsViewable
||
getstate(wins[i]) == IconicState
@ -2278,6 +2281,41 @@ Client *wintoclient(Window w)
return NULL;
}
bool winpolybar(const Window w)
{
XClassHint ch = { NULL, NULL };
bool result = true;
if (XGetClassHint(xbase->x_display, w, &ch)) {
if (
ch.res_class
&&
strstr(ch.res_class, "Polybar") == NULL
&&
strstr(ch.res_class, "polybar") == NULL
) {
result = false;
}
if (
ch.res_name
&&
strstr(ch.res_name, "Polybar") == NULL
&&
strstr(ch.res_name, "polybar") == NULL
) {
result = false;
}
} else {
result = false;
}
if (ch.res_class) XFree(ch.res_class);
if (ch.res_name) XFree(ch.res_name);
return result;
}
Monitor *wintomon(Window w)
{
{

View File

@ -244,7 +244,9 @@ void on_map_request(XEvent *e)
if (!XGetWindowAttributes(xbase->x_display, ev->window, &wa)) return;
if (wa.override_redirect) return;
if (!wintoclient(ev->window)) {
if (winpolybar(ev->window)) {
// do nothing
} else if (!wintoclient(ev->window)) {
manage(ev->window, &wa);
}
}