Advertisement
Guest User

dwm-barborder-forstatus2d-6.2.diff

a guest
Jul 20th, 2021
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 KB | None | 0 0
  1. diff --git a/config.def.h b/config.def.h
  2. index ea4c3fd..2fb58b4 100644
  3. --- a/config.def.h
  4. +++ b/config.def.h
  5. @@ -14,6 +14,7 @@ static const char col_gray2[] = "#444444";
  6. static const char col_gray3[] = "#bbbbbb";
  7. static const char col_gray4[] = "#eeeeee";
  8. static const char col_cyan[] = "#005577";
  9. +static const char col_borderbar[] = "#ff0000";
  10. static const char *colors[][3] = {
  11. /* fg bg border */
  12. [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
  13. diff --git a/dwm.c b/dwm.c
  14. index dce2779..cb52095 100644
  15. --- a/dwm.c
  16. +++ b/dwm.c
  17. @@ -264,7 +264,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
  18. static Atom wmatom[WMLast], netatom[NetLast];
  19. static int running = 1;
  20. static Cur *cursor[CurLast];
  21. -static Clr **scheme;
  22. +static Clr **scheme, clrborder;
  23. static Display *dpy;
  24. static Drw *drw;
  25. static Monitor *mons, *selmon;
  26. @@ -733,12 +733,12 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
  27. text = p;
  28.  
  29. w += horizpadbar;
  30. - ret = x = m->ww - w;
  31. + ret = x = m->ww - borderpx - w;
  32.  
  33. drw_setscheme(drw, scheme[LENGTH(colors)]);
  34. drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
  35. drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
  36. - drw_rect(drw, x, 0, w, bh, 1, 1);
  37. + drw_rect(drw, x, borderpx, w, bh, 1, 1);
  38. x += horizpadbar / 2;
  39.  
  40. /* process status text */
  41. @@ -749,7 +749,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
  42.  
  43. text[i] = '\0';
  44. w = TEXTW(text) - lrpad;
  45. - drw_text(drw, x, 0, w, bh, 0, text, 0);
  46. + drw_text(drw, x, borderpx, w, bh, 0, text, 0);
  47.  
  48. x += w;
  49.  
  50. @@ -779,7 +779,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
  51. while (text[++i] != ',');
  52. int rh = atoi(text + ++i);
  53.  
  54. - drw_rect(drw, rx + x, ry + vertpadbar / 2, rw, rh, 1, 0);
  55. + drw_rect(drw, rx + x, ry + borderpx + vertpadbar / 2, rw, rh, 1, 0);
  56. } else if (text[i] == 'f') {
  57. x += atoi(text + ++i);
  58. }
  59. @@ -793,7 +793,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
  60.  
  61. if (!isCode) {
  62. w = TEXTW(text) - lrpad;
  63. - drw_text(drw, x, 0, w, bh, 0, text, 0);
  64. + drw_text(drw, x, borderpx, w, bh, 0, text, 0);
  65. }
  66.  
  67. drw_setscheme(drw, scheme[SchemeNorm]);
  68. @@ -805,15 +805,20 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
  69. void
  70. drawbar(Monitor *m)
  71. {
  72. - int x, w, tw = 0;
  73. + int x, y = borderpx, w, tw = 0;
  74. + int th = bh - borderpx * 2;
  75. + int mw = m->ww - borderpx * 2;
  76. int boxs = drw->fonts->h / 9;
  77. int boxw = drw->fonts->h / 6 + 2;
  78. unsigned int i, occ = 0, urg = 0;
  79. Client *c;
  80.  
  81. + XSetForeground(drw->dpy, drw->gc, clrborder.pixel);
  82. + XFillRectangle(drw->dpy, drw->drawable, drw->gc, 0, 0, m->ww, bh);
  83. +
  84. /* draw status first so it can be overdrawn by tags later */
  85. if (m == selmon) { /* status is only drawn on selected monitor */
  86. - tw = m->ww - drawstatusbar(m, bh, stext);
  87. + tw = mw - drawstatusbar(m, th, stext);
  88. }
  89.  
  90. for (c = m->clients; c; c = c->next) {
  91. @@ -821,32 +826,33 @@ drawbar(Monitor *m)
  92. if (c->isurgent)
  93. urg |= c->tags;
  94. }
  95. - x = 0;
  96. + x = borderpx;
  97. for (i = 0; i < LENGTH(tags); i++) {
  98. w = TEXTW(tags[i]);
  99. drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
  100. - drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
  101. + drw_text(drw, x, y, w, th, lrpad / 2, tags[i], urg & 1 << i);
  102. if (occ & 1 << i)
  103. - drw_rect(drw, x + boxs, boxs, boxw, boxw,
  104. + drw_rect(drw, x + boxs, y + boxs, boxw, boxw,
  105. m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
  106. urg & 1 << i);
  107. x += w;
  108. }
  109. w = blw = TEXTW(m->ltsymbol);
  110. drw_setscheme(drw, scheme[SchemeNorm]);
  111. - x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
  112. + x = drw_text(drw, x, y, w, th, lrpad / 2, m->ltsymbol, 0);
  113.  
  114. - if ((w = m->ww - tw - x) > bh) {
  115. + if ((w = mw - tw - x) > th) {
  116. if (m->sel) {
  117. drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
  118. - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
  119. + drw_text(drw, x, y, w, th, lrpad / 2, m->sel->name, 0);
  120. if (m->sel->isfloating)
  121. - drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
  122. + drw_rect(drw, x + boxs, y + boxs, boxw, boxw, m->sel->isfixed, 0);
  123. } else {
  124. drw_setscheme(drw, scheme[SchemeNorm]);
  125. - drw_rect(drw, x, 0, w, bh, 1, 1);
  126. + drw_rect(drw, x, y, w, th, 1, 1);
  127. }
  128. }
  129. +
  130. drw_map(drw, m->barwin, 0, 0, m->ww, bh);
  131. }
  132.  
  133. @@ -1653,7 +1659,7 @@ setup(void)
  134. if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
  135. die("no fonts could be loaded.");
  136. lrpad = drw->fonts->h;
  137. - bh = drw->fonts->h + vertpadbar;
  138. + bh = drw->fonts->h + vertpadbar + borderpx * 2;
  139. updategeom();
  140. /* init atoms */
  141. utf8string = XInternAtom(dpy, "UTF8_STRING", False);
  142. @@ -1679,6 +1685,7 @@ setup(void)
  143. scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3);
  144. for (i = 0; i < LENGTH(colors); i++)
  145. scheme[i] = drw_scm_create(drw, colors[i], 3);
  146. + drw_clr_create(drw, &clrborder, col_borderbar);
  147. /* init bars */
  148. updatebars();
  149. updatestatus();
  150.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement