diff --git a/src/dwm.c b/src/dwm.c index 2a609a5..3986c60 100644 --- a/src/dwm.c +++ b/src/dwm.c @@ -208,6 +208,7 @@ static void checkotherwm(void); static void cleanup(void); static void cleanupmon(Monitor *mon); static void configure(Client *c); +static void createbars(void); static Monitor *createmon(void); static void detach(Client *c); static void detachstack(Client *c); @@ -264,7 +265,6 @@ static void unfocus(Client *c, int setfocus); static void unmanage(Client *c, int destroyed); static void updatebarpos(Monitor *m); static void updatebar(Monitor *m); -static void updatebars(void); static void updateclientlist(void); static int updategeom(void); static void updatenumlockmask(void); @@ -666,6 +666,34 @@ configure(Client *c) XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce); } +void +createbars(void) +{ + unsigned int w; + Monitor *m; + XSetWindowAttributes wa = { + .override_redirect = True, + .background_pixmap = ParentRelative, + .event_mask = ButtonPressMask|ExposureMask + }; + XClassHint ch = {"polytreewm", "polytreewm"}; + for (m = mons; m; m = m->next) { + if (m->barwin) + continue; + w = m->ww; + if (showsystray && m == systraytomon(m)) + w -= getsystraywidth(); + m->barwin = XCreateWindow(dpy, root, m->wx, m->by, w, bh, 0, DefaultDepth(dpy, screen), + CopyFromParent, DefaultVisual(dpy, screen), + CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); + XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); + if (showsystray && m == systraytomon(m)) + XMapRaised(dpy, systray->win); + XMapRaised(dpy, m->barwin); + XSetClassHint(dpy, m->barwin, &ch); + } +} + Monitor * createmon(void) { @@ -1744,7 +1772,7 @@ setup(void) /* init system tray */ updatesystray(); /* init bars */ - updatebars(); + createbars(); updatestatus(); /* supporting window for NetWMCheck */ @@ -2044,34 +2072,6 @@ updatebar(Monitor *m) arrange(m); } -void -updatebars(void) -{ - unsigned int w; - Monitor *m; - XSetWindowAttributes wa = { - .override_redirect = True, - .background_pixmap = ParentRelative, - .event_mask = ButtonPressMask|ExposureMask - }; - XClassHint ch = {"polytreewm", "polytreewm"}; - for (m = mons; m; m = m->next) { - if (m->barwin) - continue; - w = m->ww; - if (showsystray && m == systraytomon(m)) - w -= getsystraywidth(); - m->barwin = XCreateWindow(dpy, root, m->wx, m->by, w, bh, 0, DefaultDepth(dpy, screen), - CopyFromParent, DefaultVisual(dpy, screen), - CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); - XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); - if (showsystray && m == systraytomon(m)) - XMapRaised(dpy, systray->win); - XMapRaised(dpy, m->barwin); - XSetClassHint(dpy, m->barwin, &ch); - } -} - void updatebarpos(Monitor *m) { diff --git a/src/dwm/handlers.c b/src/dwm/handlers.c index f11a055..fbff6c2 100644 --- a/src/dwm/handlers.c +++ b/src/dwm/handlers.c @@ -194,7 +194,7 @@ on_configure_notify(XEvent *e) sh = ev->height; if (updategeom() || dirty) { drw_resize(drw, sw, bh); - updatebars(); + createbars(); for (m = mons; m; m = m->next) { resizebarwin(m); }