Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.6 KiB

4 years ago
  1. From 2f6da65e84288941babde413b9c3f4a619f853a1 Mon Sep 17 00:00:00 2001
  2. From: Pavel Oborin <pavel@oborin.xyz>
  3. Date: Mon, 20 Jul 2020 21:42:43 +0300
  4. Subject: [PATCH] Fixed drawbar
  5. ---
  6. config.def.h | 2 ++
  7. dwm.c | 26 ++++++++++++++++----------
  8. 2 files changed, 18 insertions(+), 10 deletions(-)
  9. diff --git a/config.def.h b/config.def.h
  10. index 1c0b587..867312f 100644
  11. --- a/config.def.h
  12. +++ b/config.def.h
  13. @@ -5,6 +5,8 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
  14. static const unsigned int snap = 32; /* snap pixel */
  15. static const int showbar = 1; /* 0 means no bar */
  16. static const int topbar = 1; /* 0 means bottom bar */
  17. +static const int vertpad = 10; /* vertical padding of bar */
  18. +static const int sidepad = 10; /* horizontal padding of bar */
  19. static const char *fonts[] = { "monospace:size=10" };
  20. static const char dmenufont[] = "monospace:size=10";
  21. static const char col_gray1[] = "#222222";
  22. diff --git a/dwm.c b/dwm.c
  23. index 9fd0286..ec9c293 100644
  24. --- a/dwm.c
  25. +++ b/dwm.c
  26. @@ -242,6 +242,8 @@ static int screen;
  27. static int sw, sh; /* X display screen geometry width, height */
  28. static int bh, blw = 0; /* bar geometry */
  29. static int lrpad; /* sum of left and right padding for text */
  30. +static int vp; /* vertical padding for bar */
  31. +static int sp; /* side padding for bar */
  32. static int (*xerrorxlib)(Display *, XErrorEvent *);
  33. static unsigned int numlockmask = 0;
  34. static void (*handler[LASTEvent]) (XEvent *) = {
  35. @@ -568,7 +570,7 @@ configurenotify(XEvent *e)
  36. for (c = m->clients; c; c = c->next)
  37. if (c->isfullscreen)
  38. resizeclient(c, m->mx, m->my, m->mw, m->mh);
  39. - XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
  40. + XMoveResizeWindow(dpy, m->barwin, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh);
  41. }
  42. focus(NULL);
  43. arrange(NULL);
  44. @@ -706,7 +708,7 @@ drawbar(Monitor *m)
  45. if (m == selmon) { /* status is only drawn on selected monitor */
  46. drw_setscheme(drw, scheme[SchemeNorm]);
  47. tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
  48. - drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
  49. + drw_text(drw, m->ww - tw - 2 * sp, 0, tw, bh, 0, stext, 0);
  50. }
  51. for (c = m->clients; c; c = c->next) {
  52. @@ -732,12 +734,12 @@ drawbar(Monitor *m)
  53. if ((w = m->ww - tw - x) > bh) {
  54. if (m->sel) {
  55. drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
  56. - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
  57. + drw_text(drw, x, 0, w - 2 * sp, bh, lrpad / 2, m->sel->name, 0);
  58. if (m->sel->isfloating)
  59. drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
  60. } else {
  61. drw_setscheme(drw, scheme[SchemeNorm]);
  62. - drw_rect(drw, x, 0, w, bh, 1, 1);
  63. + drw_rect(drw, x, 0, w - 2 * sp, bh, 1, 1);
  64. }
  65. }
  66. drw_map(drw, m->barwin, 0, 0, m->ww, bh);
  67. @@ -1548,6 +1550,9 @@ setup(void)
  68. lrpad = drw->fonts->h;
  69. bh = drw->fonts->h + 2;
  70. updategeom();
  71. + sp = sidepad;
  72. + vp = (topbar == 1) ? vertpad : - vertpad;
  73. +
  74. /* init atoms */
  75. utf8string = XInternAtom(dpy, "UTF8_STRING", False);
  76. wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
  77. @@ -1574,6 +1579,7 @@ setup(void)
  78. /* init bars */
  79. updatebars();
  80. updatestatus();
  81. + updatebarpos(selmon);
  82. /* supporting window for NetWMCheck */
  83. wmcheckwin = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0, 0, 0);
  84. XChangeProperty(dpy, wmcheckwin, netatom[NetWMCheck], XA_WINDOW, 32,
  85. @@ -1704,7 +1710,7 @@ togglebar(const Arg *arg)
  86. {
  87. selmon->showbar = !selmon->showbar;
  88. updatebarpos(selmon);
  89. - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
  90. + XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh);
  91. arrange(selmon);
  92. }
  93. @@ -1814,7 +1820,7 @@ updatebars(void)
  94. for (m = mons; m; m = m->next) {
  95. if (m->barwin)
  96. continue;
  97. - m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
  98. + m->barwin = XCreateWindow(dpy, root, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh, 0, DefaultDepth(dpy, screen),
  99. CopyFromParent, DefaultVisual(dpy, screen),
  100. CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
  101. XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
  102. @@ -1829,11 +1835,11 @@ updatebarpos(Monitor *m)
  103. m->wy = m->my;
  104. m->wh = m->mh;
  105. if (m->showbar) {
  106. - m->wh -= bh;
  107. - m->by = m->topbar ? m->wy : m->wy + m->wh;
  108. - m->wy = m->topbar ? m->wy + bh : m->wy;
  109. + m->wh = m->wh - vertpad - bh;
  110. + m->by = m->topbar ? m->wy : m->wy + m->wh + vertpad;
  111. + m->wy = m->topbar ? m->wy + bh + vp : m->wy;
  112. } else
  113. - m->by = -bh;
  114. + m->by = -bh - vp;
  115. }
  116. void
  117. --
  118. 2.27.0