dwm-centeredwindowname-20190907-cb3f58a.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-centeredwindowname-20190907-cb3f58a.diff (1129B)
---
1 From 9cff68c93cb727e97fa486f011b294511e110176 Mon Sep 17 00:00:00 2001
2 From: MahouShoujoMivutilde <MahouShoujoMivutilde@users.noreply.github.com>
3 Date: Sat, 7 Sep 2019 20:04:16 +0300
4 Subject: [PATCH] Centers windows names on status bar.
5
6 In original version when name is very long mid variable can turn negative, this patch variation takes this into account. This makes sure name will not overlap on tags.
7 ---
8 dwm.c | 5 ++++-
9 1 file changed, 4 insertions(+), 1 deletion(-)
10
11 diff --git a/dwm.c b/dwm.c
12 index 4465af1..3d0eac4 100644
13 --- a/dwm.c
14 +++ b/dwm.c
15 @@ -730,8 +730,11 @@ drawbar(Monitor *m)
16
17 if ((w = m->ww - sw - x) > bh) {
18 if (m->sel) {
19 + int mid = (m->ww - TEXTW(m->sel->name)) / 2 - x;
20 + /* make sure name will not overlap on tags even when it is very long */
21 + mid = mid >= lrpad / 2 ? mid : lrpad / 2;
22 drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
23 - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
24 + drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0);
25 if (m->sel->isfloating)
26 drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
27 } else {
28 --
29 2.23.0
30