diff --git a/config.def.h b/config.def.h index a3b5b48..050e351 100644 --- a/config.def.h +++ b/config.def.h @@ -20,7 +20,7 @@ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 0; /* 0 means bottom bar */ static const int user_bh = 50; /* 0 means that dwm will calculate bar height, >= 1 means dwm will user_bh as bar height */ static const int vertpad = 8; /* vertical padding of bar */ -static const int sidepad = 5; /* horizontal padding of bar */ +static const int sidepad = 5; /* horizontal padding of bar */ static const char *fonts[] = { "JetBrainsMonoNL Nerd Font:size=20", "Iosevka Nerd Font:size=20" , @@ -32,6 +32,7 @@ static const char col_gray1[] = "#101010"; static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#b9b9b9"; static const char col_gray4[] = "#525252"; +static const char col_borderbar[] = "#525252"; static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, diff --git a/dwm.c b/dwm.c index 18f7b3b..36f2d24 100644 --- a/dwm.c +++ b/dwm.c @@ -341,7 +341,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast]; static int running = 1; static Cur *cursor[CurLast]; -static Clr **scheme; +static Clr **scheme, clrborder; static Display *dpy; static Drw *drw; static Monitor *mons, *selmon; @@ -947,6 +947,8 @@ drawstatusbar(Monitor *m, int bh, char* stext) { short isCode = 0; char *text; char *p; + int mw = m->ww - borderpx * 2; + int th = bh - borderpx * 2; len = strlen(stext) + 1 ; if (!(text = (char*) malloc(sizeof(char)*len))) @@ -985,12 +987,12 @@ drawstatusbar(Monitor *m, int bh, char* stext) { text = p; w += 2; /* 1px padding on both sides */ - ret = x = m->ww - w; + ret = x = m->ww - w - borderpx * 2; drw_setscheme(drw, scheme[LENGTH(colors)]); drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; - drw_rect(drw, x, 0, w, bh, 1, 1); + drw_rect(drw, x, borderpx, w + borderpx - sp * 2, th, 1, 1); x++; /* process status text */ @@ -1001,7 +1003,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) { text[i] = '\0'; w = TEXTW(text, statusfontindex) - lrpad; - drw_text(drw, x, 0, w, bh, 0, text, 0, statusfontindex); + drw_text(drw, x, borderpx, w + borderpx, bh, 0, text, 0, statusfontindex); x += w; @@ -1045,7 +1047,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) { if (!isCode) { w = TEXTW(text, statusfontindex) - lrpad; - drw_text(drw, x, 0, w, bh, 0, text, 0, statusfontindex); + drw_text(drw, x - 2 * sp, borderpx, w + borderpx, th, 0, text, 0, statusfontindex); } drw_setscheme(drw, scheme[SchemeNorm]); @@ -1057,12 +1059,17 @@ drawstatusbar(Monitor *m, int bh, char* stext) { void drawbar(Monitor *m) { - int x, w, tw = 0, stw = 0; + int x, y = borderpx, w, tw = 0, stw = 0; + int th = bh - borderpx * 2; + int mw = m->ww - borderpx * 2; int boxs = drw->fonts->h / 9; int boxw = drw->fonts->h / 6 + 2; unsigned int i, occ = 0, urg = 0; Client *c; + XSetForeground(drw->dpy, drw->gc, clrborder.pixel); + XFillRectangle(drw->dpy, drw->drawable, drw->gc, 0, 0, m->ww, bh); + if (!m->showbar) return; @@ -1071,10 +1078,6 @@ drawbar(Monitor *m) /* draw status first so it can be overdrawn by tags later */ if (m == selmon || 1) { /* status is only drawn on selected monitor */ - // drw_setscheme(drw, scheme[SchemeNorm]); - // tw = TEXTW(stext, statusfontindex) - lrpad + 2; /* 2px right padding */ - // drw_text(drw, m->ww - tw - stw, 0, tw, bh, 0, stext, 0, statusfontindex); - // tw = m->ww - drawstatusbar(m, bh, stext); tw = statusw = m->ww - drawstatusbar(m, bh, stext); } @@ -1084,14 +1087,14 @@ drawbar(Monitor *m) if (c->isurgent) urg |= c->tags; } - x = 0; + x = borderpx; for (i = 0; i < LENGTH(tags); i++) { /* Do not draw vacant tags */ if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) continue; w = TEXTW(tags[i], statusfontindex); drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i, statusfontindex); + drw_text(drw, x, y, w , th, lrpad / 2, tags[i], urg & 1 << i, statusfontindex); if (ulineall || m->tagset[m->seltags] & 1 << i) drw_rect(drw, x + ulinepad, bh - ulinestroke - ulinevoffset, w - (ulinepad * 2), ulinestroke, 1, 0); @@ -1099,17 +1102,21 @@ drawbar(Monitor *m) } w = TEXTW(m->ltsymbol, statusfontindex); drw_setscheme(drw, scheme[SchemeNorm]); - x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0, statusfontindex); + x = drw_text(drw, x, y, w, th, lrpad / 2, m->ltsymbol, 0, statusfontindex); - if ((w = m->ww - tw - stw - x) > bh) { + // if ((w = m->ww - tw - x) > th) { + if ((w = mw - tw - x) > th) { if (m->sel) { drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); - drw_text(drw, x, 0, w - 2 * sp, bh, lrpad / 2, m->sel->name, 0, statusfontindex); + + drw_text(drw, x, y, w - 1, th, lrpad / 2, m->sel->name, 0, statusfontindex); if (m->sel->isfloating) - drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); + drw_rect(drw, x + boxs, y + boxs, boxw, boxw, m->sel->isfixed, 0); } else { drw_setscheme(drw, scheme[SchemeNorm]); - drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1); + // drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1); + // drw_rect(drw, x, y, w - 2 * sp, th, 1, 1); + drw_rect(drw, x, y, w - 1, th, 1, 1); } } drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh); @@ -2033,7 +2040,8 @@ resizebarwin(Monitor *m) { unsigned int w = m->ww; if (showsystray && m == systraytomon(m)) w -= getsystraywidth(); - XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, w, bh); + // XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, w, bh); + XMoveResizeWindow(dpy, m->barwin, m->wx + sp, m->by + vp, w - 2 * sp, bh); } void @@ -2419,6 +2427,7 @@ setup(void) die("no fonts could be loaded."); lrpad = drw->fonts->h; bh = user_bh ? user_bh : drw->fonts->h + 2; + bh = bh + borderpx * 2; sp = sidepad; vp = (topbar == 1) ? vertpad : - vertpad; updategeom(); @@ -2456,6 +2465,8 @@ setup(void) scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3); for (i = 0; i < LENGTH(colors); i++) scheme[i] = drw_scm_create(drw, colors[i], 3); + + drw_clr_create(drw, &clrborder, col_borderbar); /* init system tray */ updatesystray(); /* init bars */ @@ -2813,7 +2824,7 @@ updatebars(void) 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), + m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);