Manage Polybar

This commit is contained in:
Alex Kotov 2021-12-05 18:27:19 +05:00
parent fa8f4cd541
commit c43af37bf3
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 37 additions and 2 deletions

View file

@ -170,6 +170,7 @@ static void incnmaster(const Arg *arg);
static int isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info);
static void killclient(const Arg *arg);
static void manage(Window w, XWindowAttributes *wa);
static void managepolybar(Window w, XWindowAttributes *wa);
static Monitor *monitor_create();
static void monitor_destroy(Monitor *mon);
static void movemouse(const Arg *arg);
@ -1189,6 +1190,40 @@ void manage(Window w, XWindowAttributes *wa)
focus(NULL);
}
void managepolybar(Window w, XWindowAttributes *wa)
{
Monitor *m = recttomon(wa->x, wa->y, wa->width, wa->height);
if (!m) return;
XSelectInput(
xbase->x_display,
w,
EnterWindowMask | FocusChangeMask | PropertyChangeMask | StructureNotifyMask
);
XMoveResizeWindow(
xbase->x_display,
w,
wa->x,
wa->y,
wa->width,
wa->height
);
XMapWindow(xbase->x_display, w);
XChangeProperty(
xbase->x_display,
xbase->x_root,
xbase->atoms->netatom[NetClientList],
XA_WINDOW,
32,
PropModeAppend,
(unsigned char*)&w,
1
);
}
Monitor *monitor_create()
{
Monitor *const m = ecalloc(1, sizeof(Monitor));
@ -1733,7 +1768,7 @@ void scan()
}
if (winpolybar(wins[i])) {
// do nothing
managepolybar(wins[i], &wa);
} else if (
wa.map_state == IsViewable
||

View file

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