summaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
authorJackson Taylor <jtaylor@classicalconversations.com>2023-06-14 16:42:33 -0400
committerJackson Taylor <jtaylor@classicalconversations.com>2023-06-14 16:42:33 -0400
commit2d044272a6cf6ba04401fe2797f99a6a67ace834 (patch)
tree9a92e416f02878bc81d82f5ded512479230b1234 /dwm.c
parent8079e24e2e7f37afee853c34979a4b68d5c9274d (diff)
Add centered window name patch
This centers the window name in the top bar
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/dwm.c b/dwm.c
index ffa9df2e..b1e72d78 100644
--- a/dwm.c
+++ b/dwm.c
@@ -738,8 +738,12 @@ drawbar(Monitor *m)
if ((w = m->ww - tw - x) > bh) {
if (m->sel) {
+ /* fix overflow when window name is bigger than window width */
+ int mid = (m->ww - (int)TEXTW(m->sel->name)) / 2 - x;
+ /* make sure name will not overlap on tags even when it is very long */
+ mid = mid >= lrpad / 2 ? mid : lrpad / 2;
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
+ drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0);
if (m->sel->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
} else {