anybar: misc improvements ref. #118

pull/143/head
bakkeby 3 years ago
parent eb66da79ca
commit 4bfda0327c

@ -4284,6 +4284,10 @@ updatebarpos(Monitor *m)
for (bar = m->bar; bar; bar = bar->next) { for (bar = m->bar; bar; bar = bar->next) {
bar->bx = m->wx + x_pad; bar->bx = m->wx + x_pad;
#if BAR_ANYBAR_PATCH && !BAR_ANYBAR_MANAGE_WIDTH_PATCH
if (bar->external)
continue;
#endif // BAR_ANYBAR_PATCH | BAR_ANYBAR_MANAGE_WIDTH_PATCH
bar->bw = m->ww - 2 * x_pad; bar->bw = m->ww - 2 * x_pad;
} }
@ -4316,9 +4320,8 @@ updatebarpos(Monitor *m)
if (bar->topbar) if (bar->topbar)
m->wy = m->wy + bar->bh + y_pad; m->wy = m->wy + bar->bh + y_pad;
m->wh -= y_pad + bar->bh; m->wh -= y_pad + bar->bh;
}
for (bar = m->bar; bar; bar = bar->next)
bar->by = (bar->topbar ? m->wy - bar->bh : m->wy + m->wh); bar->by = (bar->topbar ? m->wy - bar->bh : m->wy + m->wh);
}
} }
void void

@ -3,20 +3,21 @@ managealtbar(Window win, XWindowAttributes *wa)
{ {
Monitor *m; Monitor *m;
Bar *bar; Bar *bar;
int i; int i = 0;
if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height))) if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height)))
return; return;
for (i = 0, bar = m->bar; bar && bar->win && bar->next; bar = bar->next, ++i); // find last bar for (bar = m->bar; bar && bar->win && bar->next; bar = bar->next); // find last bar
if (!bar) { if (!bar) {
bar = m->bar = ecalloc(1, sizeof(Bar)); bar = m->bar = ecalloc(1, sizeof(Bar));
bar->topbar = topbar; bar->topbar = topbar;
} else if (bar && bar->win) { } else if (bar && bar->win) {
i = bar->idx + 1;
bar->next = ecalloc(1, sizeof(Bar)); bar->next = ecalloc(1, sizeof(Bar));
#if BAR_ANYBAR_STACK_BARS_PATCH #if BAR_ANYBAR_TOP_AND_BOTTOM_BARS_PATCH
bar->next->topbar = topbar;
#else
bar->next->topbar = !bar->topbar; bar->next->topbar = !bar->topbar;
#endif // BAR_ANYBAR_STACK_BARS_PATCH #else
bar->next->topbar = topbar;
#endif // BAR_ANYBAR_TOP_AND_BOTTOM_BARS_PATCH
bar = bar->next; bar = bar->next;
} }
bar->external = 1; bar->external = 1;
@ -25,12 +26,13 @@ managealtbar(Window win, XWindowAttributes *wa)
bar->idx = i; bar->idx = i;
bar->borderpx = 0; bar->borderpx = 0;
bar->win = win; bar->win = win;
bar->bw = wa->width;
bar->bh = wa->height; bar->bh = wa->height;
updatebarpos(m); updatebarpos(m);
arrange(m); arrange(m);
XSelectInput(dpy, win, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); XSelectInput(dpy, win, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
XMapWindow(dpy, win); XMapWindow(dpy, win);
XMoveResizeWindow(dpy, bar->win, bar->bx, -bar->by, wa->width, bar->bh); XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
arrange(selmon); arrange(selmon);
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
(unsigned char *) &win, 1); (unsigned char *) &win, 1);

@ -229,10 +229,11 @@
*/ */
#define BAR_ANYBAR_PATCH 0 #define BAR_ANYBAR_PATCH 0
/* Anybar option to stack multiple external bars at the top or at the bottom of the monitor /* Anybar option to place the next bar depending on previous bar's position (top or bottom) */
* instead of adding a second bar at the opposite side. #define BAR_ANYBAR_TOP_AND_BOTTOM_BARS_PATCH 0
*/
#define BAR_ANYBAR_STACK_BARS_PATCH 0 /* Anybar option to let dwm manage the width of the bar */
#define BAR_ANYBAR_MANAGE_WIDTH_PATCH 0
/* This patch adds a border around the status bar(s) just like the border of client windows. /* This patch adds a border around the status bar(s) just like the border of client windows.
* https://codemadness.org/paste/dwm-border-bar.patch * https://codemadness.org/paste/dwm-border-bar.patch

Loading…
Cancel
Save