From 27692ca057da9cc48b3c32b83586e0778594399b Mon Sep 17 00:00:00 2001 From: tsxv478 Date: Wed, 21 Sep 2022 03:34:51 +0300 Subject: do not calculate width when centered, always use same width --- config.def.h | 2 +- dmenu.c | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/config.def.h b/config.def.h index 70b495d..2602882 100644 --- a/config.def.h +++ b/config.def.h @@ -3,7 +3,7 @@ static int topbar = 0; /* -b option; if 0, dmenu appears at bottom */ static int centered = 0; /* -c option; centers dmenu on screen */ -static int min_width = 500; /* minimum width when centered */ +static int centered_width = 800; /* width when centered */ /* -fn option overrides fonts[0]; default X11 font or font set */ static const char *fonts[] = { "monospace:size=11" diff --git a/dmenu.c b/dmenu.c index 3afa794..980d3cf 100644 --- a/dmenu.c +++ b/dmenu.c @@ -96,15 +96,6 @@ calcoffsets(void) break; } -static int -max_textw(void) -{ - int len = 0; - for (struct item *item = items; item && item->text; item++) - len = MAX(TEXTW(item->text), len); - return len; -} - static void cleanup(void) { @@ -677,7 +668,7 @@ setup(void) break; if (centered) { - mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width); + mw = centered_width; x = info[i].x_org + ((info[i].width - mw) / 2); y = info[i].y_org + ((info[i].height - mh) / 2); } else { @@ -695,7 +686,7 @@ setup(void) parentwin); if (centered) { - mw = MIN(MAX(max_textw() + promptw, min_width), wa.width); + mw = centered_width; x = (wa.width - mw) / 2; y = (wa.height - mh) / 2; } else { -- cgit v1.2.3