dwm-noxz

[fork] suckless dwm - personal fork
git clone https://noxz.tech/git/dwm-noxz.git
Log | Files | README | LICENSE

commit: 8058a34f7a237dd7d326c2c3c7c32c168fe034ef
parent: c981511de17db4257f6e95dbd4e7ee10b7466b8a
author: Chris Noxz <chris@noxz.tech>
date:   Wed, 13 Dec 2023 20:53:56 +0100
Fix title length and centering fallback
Mdrw.c4++--
Mdwm.c8+++++---
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/drw.c b/drw.c
@@ -273,7 +273,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
 
 	usedfont = drw->fonts;
 	if (!ellipsis_width && render)
-		ellipsis_width = drw_fontset_getwidth(drw, "\u2026");
+		ellipsis_width = drw_fontset_getwidth(drw, "...");
 	while (1) {
 		ew = ellipsis_len = utf8strlen = 0;
 		utf8str = text;
@@ -327,7 +327,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
 			w -= ew;
 		}
 		if (render && overflow)
-			drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "\u2026", invert);
+			drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
 
 		if (!*text || overflow) {
 			break;
diff --git a/dwm.c b/dwm.c
@@ -95,7 +95,7 @@ typedef struct Pertag Pertag;
 typedef struct Monitor Monitor;
 typedef struct Client Client;
 struct Client {
-	char name[256];
+	char name[512];
 	float mina, maxa;
 	int x, y, w, h;
 	int oldx, oldy, oldw, oldh;
@@ -860,6 +860,7 @@ void
 drawbar(Monitor *m)
 {
 	int x, w, tw = 0;
+	int tlpad;
 	int boxs = drw->fonts->h / 9;
 	int boxw = drw->fonts->h / 6 + 2;
 	unsigned int i, j, occ = 0, urg = 0;
@@ -950,10 +951,11 @@ drawbar(Monitor *m)
 	if ((w = m->ww - tw - x) > bh) {
 		if (m->sel) {
 			drw_setscheme(drw, scheme[m == selmon ? SchemeTitleSel : SchemeTitleNorm]);
-			if (TEXTW(m->sel->name) > (m->ww - x))
+			tlpad = (m->ww - ((int)TEXTW(m->sel->name) - lrpad)) / 2 - x;
+			if (TEXTW(m->sel->name) + tlpad > (m->ww - tw - x))
 				drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
 			else
-				drw_text(drw, x, 0, w, bh, (m->ww - TEXTW(m->sel->name) + lrpad) / 2 - x, m->sel->name, 0);
+				drw_text(drw, x, 0, w, bh, tlpad, m->sel->name, 0);
 			if (m->sel->isfloating)
 				drw_rect(drw, x + boxs + 1, boxs + 1, boxw, boxw, m->sel->isfixed, ColFg);
 		} else {