92f77de7deb4b5b9fc2dcf958264093458123497.diff 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. diff --git a/src/config.def.h.rej b/src/config.def.h.rej
  2. new file mode 100644
  3. index 0000000..82ea963
  4. --- /dev/null
  5. +++ b/src/config.def.h.rej
  6. @@ -0,0 +1,13 @@
  7. +--- config.def.h
  8. ++++ config.def.h
  9. +@@ -5,6 +5,10 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
  10. + static const unsigned int snap = 32; /* snap pixel */
  11. + static const int showbar = 1; /* 0 means no bar */
  12. + static const int topbar = 1; /* 0 means bottom bar */
  13. ++static const int usealtbar = 1; /* 1 means use non-dwm status bar */
  14. ++static const char *altbarclass = "Polybar"; /* Alternate bar class name */
  15. ++static const char *alttrayname = "tray"; /* Polybar tray instance name */
  16. ++static const char *altbarcmd = "$HOME/bar.sh"; /* Alternate bar launch command */
  17. + static const char *fonts[] = { "monospace:size=10" };
  18. + static const char dmenufont[] = "monospace:size=10";
  19. + static const char col_gray1[] = "#222222";
  20. diff --git a/src/config.h b/src/config.h
  21. index 1e3fec2..43aa1e2 100644
  22. --- a/src/config.h
  23. +++ b/src/config.h
  24. @@ -17,6 +17,12 @@ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display
  25. static const int showsystray = 1; /* 0 means no systray */
  26. static const int showbar = 1; /* 0 means no bar */
  27. static const int topbar = 1; /* 0 means bottom bar */
  28. +
  29. +static const int usealtbar = 1; /* 1 means use non-dwm status bar */
  30. +static const char *altbarclass = "Polybar"; /* Alternate bar class name */
  31. +static const char *alttrayname = "tray"; /* Polybar tray instance name */
  32. +static const char *altbarcmd = "$HOME/bar.sh"; /* Alternate bar launch command */
  33. +
  34. static const char *fonts[] = { "monospace:size=11", "Noto Color Emoji:size=11", "Nerd Font Mono:weight=bold:size=15:antialias=true:hinting=true" };
  35. static const char dmenufont[] = "monospace:size=11";
  36. @@ -24,8 +30,6 @@ static const char dmenufont[] = "monospace:size=11";
  37. // Autostart programs
  38. static const char *const autostart[] = {
  39. - // Start my build of slstatus
  40. - "slstatus", NULL,
  41. // Keyboard layouts switch (requires setxkbmap)
  42. "setxkbmap", "-model", "pc101", "-layout", "us,ar", "-variant", ",,", "-option", "grp:win_space_toggle", NULL,
  43. // "xkbset", "exp", "=sticky", "-twokey", "-latchlock", NULL, // sticky keys
  44. diff --git a/src/dwm.c b/src/dwm.c
  45. index eb423c5..0499e58 100644
  46. --- a/src/dwm.c
  47. +++ b/src/dwm.c
  48. @@ -47,8 +47,8 @@
  49. /* macros */
  50. #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
  51. #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
  52. -#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
  53. - * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
  54. +#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->mx+(m)->mw) - MAX((x),(m)->mx)) \
  55. + * MAX(0, MIN((y)+(h),(m)->my+(m)->mh) - MAX((y),(m)->my)))
  56. #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]) || C->issticky)
  57. #define LENGTH(X) (sizeof X / sizeof X[0])
  58. #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
  59. @@ -137,7 +137,8 @@ struct Monitor {
  60. float mfact;
  61. int nmaster;
  62. int num;
  63. - int by; /* bar geometry */
  64. + int by, bh; /* bar geometry */
  65. + int tx, tw; /* bar tray geometry */
  66. int mx, my, mw, mh; /* screen size */
  67. int wx, wy, ww, wh; /* window area */
  68. unsigned int seltags;
  69. @@ -150,6 +151,7 @@ struct Monitor {
  70. Client *stack;
  71. Monitor *next;
  72. Window barwin;
  73. + Window traywin;
  74. const Layout *lt[2];
  75. Pertag *pertag;
  76. };
  77. @@ -208,6 +210,8 @@ static void incnmaster(const Arg *arg);
  78. static void keypress(XEvent *e);
  79. static void killclient(const Arg *arg);
  80. static void manage(Window w, XWindowAttributes *wa);
  81. +static void managealtbar(Window win, XWindowAttributes *wa);
  82. +static void managetray(Window win, XWindowAttributes *wa);
  83. static void mappingnotify(XEvent *e);
  84. static void maprequest(XEvent *e);
  85. static void monocle(Monitor *m);
  86. @@ -227,6 +231,7 @@ static void resizerequest(XEvent *e);
  87. static void restack(Monitor *m);
  88. static void run(void);
  89. static void scan(void);
  90. +static void scantray(void);
  91. static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, long d4);
  92. static void sendmon(Client *c, Monitor *m);
  93. static void setclientstate(Client *c, long state);
  94. @@ -240,6 +245,7 @@ static void seturgent(Client *c, int urg);
  95. static void showhide(Client *c);
  96. static void sigchld(int unused);
  97. static void spawn(const Arg *arg);
  98. +static void spawnbar();
  99. static Monitor *systraytomon(Monitor *m);
  100. static void tag(const Arg *arg);
  101. static void tagmon(const Arg *arg);
  102. @@ -251,6 +257,8 @@ static void toggletag(const Arg *arg);
  103. static void toggleview(const Arg *arg);
  104. static void unfocus(Client *c, int setfocus);
  105. static void unmanage(Client *c, int destroyed);
  106. +static void unmanagealtbar(Window w);
  107. +static void unmanagetray(Window w);
  108. static void unmapnotify(XEvent *e);
  109. static void updatebarpos(Monitor *m);
  110. static void updatebars(void);
  111. @@ -269,6 +277,7 @@ static void view(const Arg *arg);
  112. static Client *wintoclient(Window w);
  113. static Monitor *wintomon(Window w);
  114. static Client *wintosystrayicon(Window w);
  115. +static int wmclasscontains(Window win, const char *class, const char *name);
  116. static int xerror(Display *dpy, XErrorEvent *ee);
  117. static int xerrordummy(Display *dpy, XErrorEvent *ee);
  118. static int xerrorstart(Display *dpy, XErrorEvent *ee);
  119. @@ -595,8 +604,10 @@ cleanupmon(Monitor *mon)
  120. for (m = mons; m && m->next != mon; m = m->next);
  121. m->next = mon->next;
  122. }
  123. - XUnmapWindow(dpy, mon->barwin);
  124. - XDestroyWindow(dpy, mon->barwin);
  125. + if (!usealtbar) {
  126. + XUnmapWindow(dpy, mon->barwin);
  127. + XDestroyWindow(dpy, mon->barwin);
  128. + }
  129. free(mon);
  130. }
  131. @@ -779,6 +790,7 @@ createmon(void)
  132. m->nmaster = nmaster;
  133. m->showbar = showbar;
  134. m->topbar = topbar;
  135. + m->bh = bh;
  136. m->lt[0] = &layouts[0];
  137. m->lt[1] = &layouts[1 % LENGTH(layouts)];
  138. strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
  139. @@ -803,10 +815,15 @@ void
  140. destroynotify(XEvent *e)
  141. {
  142. Client *c;
  143. + Monitor *m;
  144. XDestroyWindowEvent *ev = &e->xdestroywindow;
  145. if ((c = wintoclient(ev->window)))
  146. unmanage(c, 1);
  147. + else if ((m = wintomon(ev->window)) && m->barwin == ev->window)
  148. + unmanagealtbar(ev->window);
  149. + else if (m->traywin == ev->window)
  150. + unmanagetray(ev->window);
  151. else if ((c = wintosystrayicon(ev->window))) {
  152. removesystrayicon(c);
  153. resizebarwin(selmon);
  154. @@ -855,6 +872,8 @@ dirtomon(int dir)
  155. void
  156. drawbar(Monitor *m)
  157. {
  158. + if (usealtbar) return;
  159. +
  160. int x, w, tw = 0, stw = 0;
  161. int boxs = drw->fonts->h / 9;
  162. int boxw = drw->fonts->h / 6 + 2;
  163. @@ -1325,6 +1344,8 @@ maprequest(XEvent *e)
  164. return;
  165. if (wa.override_redirect)
  166. return;
  167. + if (wmclasscontains(ev->window, altbarclass, ""))
  168. + managealtbar(ev->window, &wa);
  169. if (!wintoclient(ev->window))
  170. manage(ev->window, &wa);
  171. }
  172. @@ -1525,7 +1546,7 @@ resizebarwin(Monitor *m) {
  173. unsigned int w = m->ww;
  174. if (showsystray && m == systraytomon(m) && !systrayonleft)
  175. w -= getsystraywidth();
  176. - XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, w, bh);
  177. + XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, m->bh);
  178. }
  179. void
  180. @@ -1668,8 +1689,10 @@ scan(void)
  181. for (i = 0; i < num; i++) {
  182. if (!XGetWindowAttributes(dpy, wins[i], &wa)
  183. || wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
  184. - continue;
  185. - if (wa.map_state == IsViewable || getstate(wins[i]) == IconicState)
  186. + continue;
  187. + if (wmclasscontains(wins[i], altbarclass, ""))
  188. + managealtbar(wins[i], &wa);
  189. + else if (wa.map_state == IsViewable || getstate(wins[i]) == IconicState)
  190. manage(wins[i], &wa);
  191. }
  192. for (i = 0; i < num; i++) { /* now the transients */
  193. @@ -1684,6 +1707,28 @@ scan(void)
  194. }
  195. }
  196. +
  197. +void
  198. +scantray(void)
  199. +{
  200. + unsigned int num;
  201. + Window d1, d2, *wins = NULL;
  202. + XWindowAttributes wa;
  203. +
  204. + if (XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
  205. + for (unsigned int i = 0; i < num; i++) {
  206. + if (wmclasscontains(wins[i], altbarclass, alttrayname)) {
  207. + if (!XGetWindowAttributes(dpy, wins[i], &wa))
  208. + break;
  209. + managetray(wins[i], &wa);
  210. + }
  211. + }
  212. + }
  213. +
  214. + if (wins)
  215. + XFree(wins);
  216. +}
  217. +
  218. void
  219. sendmon(Client *c, Monitor *m)
  220. {
  221. @@ -1848,7 +1893,7 @@ setup(void)
  222. if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
  223. die("no fonts could be loaded.");
  224. lrpad = drw->fonts->h;
  225. - bh = drw->fonts->h + 2;
  226. + bh = usealtbar ? 0 : drw->fonts->h + 2;
  227. updategeom();
  228. /* init atoms */
  229. utf8string = XInternAtom(dpy, "UTF8_STRING", False);
  230. @@ -1906,6 +1951,7 @@ setup(void)
  231. XSelectInput(dpy, root, wa.event_mask);
  232. grabkeys();
  233. focus(NULL);
  234. + spawnbar();
  235. }
  236. @@ -1980,6 +2026,13 @@ spawn(const Arg *arg)
  237. }
  238. }
  239. +void
  240. +spawnbar()
  241. +{
  242. + if (*altbarcmd)
  243. + system(altbarcmd);
  244. +}
  245. +
  246. void
  247. tag(const Arg *arg)
  248. {
  249. @@ -2001,9 +2054,19 @@ tagmon(const Arg *arg)
  250. void
  251. togglebar(const Arg *arg)
  252. {
  253. + /**
  254. + * Polybar tray does not raise maprequest event. It must be manually scanned
  255. + * for. Scanning it too early while the tray is being populated would give
  256. + * wrong dimensions.
  257. + */
  258. + if (!selmon->traywin)
  259. + scantray();
  260. +
  261. selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
  262. updatebarpos(selmon);
  263. resizebarwin(selmon);
  264. + //TODO: 2022-07-17 Test
  265. + XMoveResizeWindow(dpy, selmon->traywin, selmon->tx, selmon->by, selmon->tw, selmon->bh);
  266. if (showsystray) {
  267. XWindowChanges wc;
  268. if (!selmon->showbar)
  269. @@ -2018,6 +2081,38 @@ togglebar(const Arg *arg)
  270. arrange(selmon);
  271. }
  272. +
  273. +void
  274. +unmanagealtbar(Window w)
  275. +{
  276. + Monitor *m = wintomon(w);
  277. +
  278. + if (!m)
  279. + return;
  280. +
  281. + m->barwin = 0;
  282. + m->by = 0;
  283. + m->bh = 0;
  284. + updatebarpos(m);
  285. + arrange(m);
  286. +}
  287. +
  288. +void
  289. +unmanagetray(Window w)
  290. +{
  291. + Monitor *m = wintomon(w);
  292. +
  293. + if (!m)
  294. + return;
  295. +
  296. + m->traywin = 0;
  297. + m->tx = 0;
  298. + m->tw = 0;
  299. + updatebarpos(m);
  300. + arrange(m);
  301. +}
  302. +
  303. +
  304. void
  305. togglefloating(const Arg *arg)
  306. {
  307. @@ -2134,6 +2229,7 @@ void
  308. unmapnotify(XEvent *e)
  309. {
  310. Client *c;
  311. + Monitor *m;
  312. XUnmapEvent *ev = &e->xunmap;
  313. if ((c = wintoclient(ev->window))) {
  314. @@ -2141,7 +2237,10 @@ unmapnotify(XEvent *e)
  315. setclientstate(c, WithdrawnState);
  316. else
  317. unmanage(c, 0);
  318. - }
  319. + } else if ((m = wintomon(ev->window)) && m->barwin == ev->window)
  320. + unmanagealtbar(ev->window);
  321. + else if (m->traywin == ev->window)
  322. + unmanagetray(ev->window);
  323. else if ((c = wintosystrayicon(ev->window))) {
  324. /* KLUDGE! sometimes icons occasionally unmap their windows, but do
  325. * _not_ destroy them. We map those windows back */
  326. @@ -2153,6 +2252,8 @@ unmapnotify(XEvent *e)
  327. void
  328. updatebars(void)
  329. {
  330. + if (usealtbar) return;
  331. +
  332. unsigned int w;
  333. Monitor *m;
  334. XSetWindowAttributes wa = {
  335. @@ -2184,11 +2285,11 @@ updatebarpos(Monitor *m)
  336. m->wy = m->my;
  337. m->wh = m->mh;
  338. if (m->showbar) {
  339. - m->wh -= bh;
  340. + m->wh -= m->bh;
  341. m->by = m->topbar ? m->wy : m->wy + m->wh;
  342. - m->wy = m->topbar ? m->wy + bh : m->wy;
  343. + m->wy = m->topbar ? m->wy + m->bh : m->wy;
  344. } else
  345. - m->by = -bh;
  346. + m->by = -m->bh;
  347. }
  348. void
  349. @@ -2491,6 +2592,45 @@ updatewindowtype(Client *c)
  350. c->isfloating = 1;
  351. }
  352. +
  353. +void
  354. +managealtbar(Window win, XWindowAttributes *wa)
  355. +{
  356. + Monitor *m;
  357. + if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height)))
  358. + return;
  359. +
  360. + m->barwin = win;
  361. + m->by = wa->y;
  362. + bh = m->bh = wa->height;
  363. + updatebarpos(m);
  364. + arrange(m);
  365. + XSelectInput(dpy, win, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
  366. + XMoveResizeWindow(dpy, win, wa->x, wa->y, wa->width, wa->height);
  367. + XMapWindow(dpy, win);
  368. + XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
  369. + (unsigned char *) &win, 1);
  370. +}
  371. +
  372. +void
  373. +managetray(Window win, XWindowAttributes *wa)
  374. +{
  375. + Monitor *m;
  376. + if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height)))
  377. + return;
  378. +
  379. + m->traywin = win;
  380. + m->tx = wa->x;
  381. + m->tw = wa->width;
  382. + updatebarpos(m);
  383. + arrange(m);
  384. + XSelectInput(dpy, win, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
  385. + XMoveResizeWindow(dpy, win, wa->x, wa->y, wa->width, wa->height);
  386. + XMapWindow(dpy, win);
  387. + XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
  388. + (unsigned char *) &win, 1);
  389. +}
  390. +
  391. void
  392. updatewmhints(Client *c)
  393. {
  394. @@ -2581,13 +2721,36 @@ wintomon(Window w)
  395. if (w == root && getrootptr(&x, &y))
  396. return recttomon(x, y, 1, 1);
  397. for (m = mons; m; m = m->next)
  398. - if (w == m->barwin)
  399. + if (w == m->barwin || w == m->traywin)
  400. return m;
  401. if ((c = wintoclient(w)))
  402. return c->mon;
  403. return selmon;
  404. }
  405. +
  406. +int
  407. +wmclasscontains(Window win, const char *class, const char *name)
  408. +{
  409. + XClassHint ch = { NULL, NULL };
  410. + int res = 1;
  411. +
  412. + if (XGetClassHint(dpy, win, &ch)) {
  413. + if (ch.res_name && strstr(ch.res_name, name) == NULL)
  414. + res = 0;
  415. + if (ch.res_class && strstr(ch.res_class, class) == NULL)
  416. + res = 0;
  417. + } else
  418. + res = 0;
  419. +
  420. + if (ch.res_class)
  421. + XFree(ch.res_class);
  422. + if (ch.res_name)
  423. + XFree(ch.res_name);
  424. +
  425. + return res;
  426. +}
  427. +
  428. /* There's no way to check accesses to destroyed windows, thus those cases are
  429. * ignored (especially on UnmapNotify's). Other types of errors call Xlibs
  430. * default error handler, which may call exit. */
  431. diff --git a/src/dwm.c.rej b/src/dwm.c.rej
  432. new file mode 100644
  433. index 0000000..7e375c6
  434. --- /dev/null
  435. +++ b/src/dwm.c.rej
  436. @@ -0,0 +1,112 @@
  437. +--- dwm.c
  438. ++++ dwm.c
  439. +@@ -47,8 +47,8 @@
  440. + /* macros */
  441. + #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
  442. + #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
  443. +-#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
  444. +- * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
  445. ++#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->mx+(m)->mw) - MAX((x),(m)->mx)) \
  446. ++ * MAX(0, MIN((y)+(h),(m)->my+(m)->mh) - MAX((y),(m)->my)))
  447. + #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
  448. + #define LENGTH(X) (sizeof X / sizeof X[0])
  449. + #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
  450. +@@ -199,6 +203,7 @@ static void resizemouse(const Arg *arg);
  451. + static void restack(Monitor *m);
  452. + static void run(void);
  453. + static void scan(void);
  454. ++static void scantray(void);
  455. + static int sendevent(Client *c, Atom proto);
  456. + static void sendmon(Client *c, Monitor *m);
  457. + static void setclientstate(Client *c, long state);
  458. +@@ -211,6 +216,7 @@ static void seturgent(Client *c, int urg);
  459. + static void showhide(Client *c);
  460. + static void sigchld(int unused);
  461. + static void spawn(const Arg *arg);
  462. ++static void spawnbar();
  463. + static void tag(const Arg *arg);
  464. + static void tagmon(const Arg *arg);
  465. + static void tile(Monitor *);
  466. +@@ -236,6 +244,7 @@ static void updatewmhints(Client *c);
  467. + static void view(const Arg *arg);
  468. + static Client *wintoclient(Window w);
  469. + static Monitor *wintomon(Window w);
  470. ++static int wmclasscontains(Window win, const char *class, const char *name);
  471. + static int xerror(Display *dpy, XErrorEvent *ee);
  472. + static int xerrordummy(Display *dpy, XErrorEvent *ee);
  473. + static int xerrorstart(Display *dpy, XErrorEvent *ee);
  474. +@@ -576,7 +587,7 @@ configurenotify(XEvent *e)
  475. + for (c = m->clients; c; c = c->next)
  476. + if (c->isfullscreen)
  477. + resizeclient(c, m->mx, m->my, m->mw, m->mh);
  478. +- XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
  479. ++ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, m->bh);
  480. + }
  481. + focus(NULL);
  482. + arrange(NULL);
  483. +@@ -658,10 +670,15 @@ void
  484. + destroynotify(XEvent *e)
  485. + {
  486. + Client *c;
  487. ++ Monitor *m;
  488. + XDestroyWindowEvent *ev = &e->xdestroywindow;
  489. +
  490. + if ((c = wintoclient(ev->window)))
  491. + unmanage(c, 1);
  492. ++ else if ((m = wintomon(ev->window)) && m->barwin == ev->window)
  493. ++ unmanagealtbar(ev->window);
  494. ++ else if (m->traywin == ev->window)
  495. ++ unmanagetray(ev->window);
  496. + }
  497. +
  498. + void
  499. +@@ -705,6 +722,9 @@ dirtomon(int dir)
  500. + void
  501. + drawbar(Monitor *m)
  502. + {
  503. ++ if (usealtbar)
  504. ++ return;
  505. ++
  506. + int x, w, tw = 0;
  507. + int boxs = drw->fonts->h / 9;
  508. + int boxw = drw->fonts->h / 6 + 2;
  509. +@@ -1785,9 +1879,18 @@ tile(Monitor *m)
  510. + void
  511. + togglebar(const Arg *arg)
  512. + {
  513. ++ /**
  514. ++ * Polybar tray does not raise maprequest event. It must be manually scanned
  515. ++ * for. Scanning it too early while the tray is being populated would give
  516. ++ * wrong dimensions.
  517. ++ */
  518. ++ if (!selmon->traywin)
  519. ++ scantray();
  520. ++
  521. + selmon->showbar = !selmon->showbar;
  522. + updatebarpos(selmon);
  523. +- XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
  524. ++ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, selmon->bh);
  525. ++ XMoveResizeWindow(dpy, selmon->traywin, selmon->tx, selmon->by, selmon->tw, selmon->bh);
  526. + arrange(selmon);
  527. + }
  528. +
  529. +@@ -1912,12 +2046,18 @@ unmapnotify(XEvent *e)
  530. + setclientstate(c, WithdrawnState);
  531. + else
  532. + unmanage(c, 0);
  533. +- }
  534. ++ } else if ((m = wintomon(ev->window)) && m->barwin == ev->window)
  535. ++ unmanagealtbar(ev->window);
  536. ++ else if (m->traywin == ev->window)
  537. ++ unmanagetray(ev->window);
  538. + }
  539. +
  540. + void
  541. + updatebars(void)
  542. + {
  543. ++ if (usealtbar)
  544. ++ return;
  545. ++
  546. + Monitor *m;
  547. + XSetWindowAttributes wa = {
  548. + .override_redirect = True,