diff options
| author | Fuwn <[email protected]> | 2024-05-23 16:49:08 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-05-23 16:49:08 -0700 |
| commit | 7078f320bcaa6c3cef080831fdf70852eea2b4da (patch) | |
| tree | 6e6a96b0bacbddd30b3ec9aea55ca2f2f9584a91 | |
| parent | feat: add winicon patch (diff) | |
| download | seiwm-7078f320bcaa6c3cef080831fdf70852eea2b4da.tar.xz seiwm-7078f320bcaa6c3cef080831fdf70852eea2b4da.zip | |
feat(dwm.c): add centretitle patch
| -rw-r--r-- | config.h | 1 | ||||
| -rw-r--r-- | dwm.c | 7 |
2 files changed, 8 insertions, 0 deletions
@@ -24,6 +24,7 @@ static int swallowfloating = 0; /* 1 means swallow floating windows by static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ static int showbar = 1; /* 0 means no bar */ static int topbar = 1; /* 0 means bottom bar */ +static int centretitle = 0; #define ICONSIZE 16 /* icon size */ #define ICONSPACING 5 /* space between icon and title */ static const int user_bh = 2; /* 2 is the default spacing around the bar's font */ @@ -1084,6 +1084,7 @@ void drawbar(Monitor *m) { int x, w, tw = 0, stw = 0; + int tlpad; int boxs = drw->fonts->h / 9; int boxw = drw->fonts->h / 6 + 2; unsigned int i, occ = 0, urg = 0; @@ -1127,6 +1128,12 @@ drawbar(Monitor *m) if (m->sel) { drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); drw_text(drw, x, 0, w - 2 * sp, bh, lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0), m->sel->name, 0); + if (centretitle) { + tlpad = MAX((m->ww - ((int)TEXTW(m->sel->name) - lrpad)) / 2 - x, lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0)); + drw_text(drw, x, 0, w - 2 * sp, bh, tlpad, m->sel->name, 0); + } else { + drw_text(drw, x, 0, w - 2 * sp, bh, lrpad / 2 + (m->sel->icon ? m->sel->icw + ICONSPACING : 0), m->sel->name, 0); + } if (m->sel->icon) drw_pic(drw, x + lrpad / 2, (bh - m->sel->ich) / 2, m->sel->icw, m->sel->ich, m->sel->icon); if (m->sel->isfloating) drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); |