barmodules: refactoring updatebarpos

This commit is contained in:
bakkeby 2020-07-21 11:35:26 +02:00
parent d7a7ac67ee
commit ff72f80029

21
dwm.c
View File

@ -884,7 +884,6 @@ buttonpress(XEvent *e)
XButtonPressedEvent *ev = &e->xbutton; XButtonPressedEvent *ev = &e->xbutton;
const BarRule *br; const BarRule *br;
BarClickArg carg = { 0, 0, 0, 0 }; BarClickArg carg = { 0, 0, 0, 0 };
click = ClkRootWin; click = ClkRootWin;
/* focus monitor if necessary */ /* focus monitor if necessary */
if ((m = wintomon(ev->window)) && m != selmon if ((m = wintomon(ev->window)) && m != selmon
@ -3478,23 +3477,25 @@ updatebarpos(Monitor *m)
int x_pad = 0; int x_pad = 0;
#endif // BAR_PADDING_PATCH #endif // BAR_PADDING_PATCH
for (num_bars = 0, bar = m->bar; bar; bar = bar->next, num_bars++); if (!m->showbar) {
if (m->showbar) for (bar = m->bar; bar; bar = bar->next)
bar->by = -bh - y_pad;
return;
}
for (num_bars = 0, bar = m->bar; bar; bar = bar->next, num_bars++)
if (bar->topbar)
m->wy = m->my + bh + y_pad;
m->wh = m->wh - y_pad * num_bars - bh * num_bars; m->wh = m->wh - y_pad * num_bars - bh * num_bars;
for (bar = m->bar; bar; bar = bar->next) { for (bar = m->bar; bar; bar = bar->next) {
bar->bx = m->mx + x_pad; bar->bx = m->mx + x_pad;
bar->bw = m->ww - 2 * x_pad; bar->bw = m->ww - 2 * x_pad;
bar->bh = bh; bar->bh = bh;
if (m->showbar) { if (bar->topbar)
if (bar->topbar) {
m->wy = m->wy + bh + y_pad;
bar->by = m->wy - bh; bar->by = m->wy - bh;
} else else
bar->by = m->wy + m->wh; bar->by = m->wy + m->wh;
} else {
bar->by = -bh - y_pad;
}
} }
} }