aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dmenu.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/dmenu.c b/dmenu.c
index cde394b..d989d39 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -547,8 +547,7 @@ static void
readstdin(void)
{
char buf[sizeof text], *p;
- size_t i, imax = 0, size = 0;
- unsigned int tmpmax = 0;
+ size_t i, size = 0;
/* read each line from stdin and add it to the item list */
for (i = 0; fgets(buf, sizeof buf, stdin); i++) {
@@ -560,15 +559,9 @@ readstdin(void)
if (!(items[i].text = strdup(buf)))
die("cannot strdup %u bytes:", strlen(buf) + 1);
items[i].out = 0;
- drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL);
- if (tmpmax > inputw) {
- inputw = tmpmax;
- imax = i;
- }
}
if (items)
items[i].text = NULL;
- inputw = items ? TEXTW(items[imax].text) : 0;
lines = MIN(lines, i);
}
@@ -614,12 +607,13 @@ static void
setup(void)
{
int x, y, i, j;
- unsigned int du;
+ unsigned int du, tmp;
XSetWindowAttributes swa;
XIM xim;
Window w, dw, *dws;
XWindowAttributes wa;
XClassHint ch = {"dmenu", "dmenu"};
+ struct item *item;
#ifdef XINERAMA
XineramaScreenInfo *info;
Window pw;
@@ -677,7 +671,12 @@ setup(void)
mw = wa.width;
}
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
- inputw = MIN(inputw, mw/3);
+ for (item = items; item && item->text; ++item) {
+ if ((tmp = textw_clamp(item->text, mw/3)) > inputw) {
+ if ((inputw = tmp) == mw/3)
+ break;
+ }
+ }
match();
/* create menu window */