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
547readstdin(void) 547readstdin(void)
548{ 548{
549 char buf[sizeof text], *p; 549 char buf[sizeof text], *p;
550 size_t i, imax = 0, size = 0; 550 size_t i, size = 0;
551 unsigned int tmpmax = 0;
552 551
553 /* read each line from stdin and add it to the item list */ 552 /* read each line from stdin and add it to the item list */
554 for (i = 0; fgets(buf, sizeof buf, stdin); i++) { 553 for (i = 0; fgets(buf, sizeof buf, stdin); i++) {
@@ -560,15 +559,9 @@ readstdin(void)
560 if (!(items[i].text = strdup(buf))) 559 if (!(items[i].text = strdup(buf)))
561 die("cannot strdup %u bytes:", strlen(buf) + 1); 560 die("cannot strdup %u bytes:", strlen(buf) + 1);
562 items[i].out = 0; 561 items[i].out = 0;
563 drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL);
564 if (tmpmax > inputw) {
565 inputw = tmpmax;
566 imax = i;
567 }
568 } 562 }
569 if (items) 563 if (items)
570 items[i].text = NULL; 564 items[i].text = NULL;
571 inputw = items ? TEXTW(items[imax].text) : 0;
572 lines = MIN(lines, i); 565 lines = MIN(lines, i);
573} 566}
574 567
@@ -614,12 +607,13 @@ static void
614setup(void) 607setup(void)
615{ 608{
616 int x, y, i, j; 609 int x, y, i, j;
617 unsigned int du; 610 unsigned int du, tmp;
618 XSetWindowAttributes swa; 611 XSetWindowAttributes swa;
619 XIM xim; 612 XIM xim;
620 Window w, dw, *dws; 613 Window w, dw, *dws;
621 XWindowAttributes wa; 614 XWindowAttributes wa;
622 XClassHint ch = {"dmenu", "dmenu"}; 615 XClassHint ch = {"dmenu", "dmenu"};
616 struct item *item;
623#ifdef XINERAMA 617#ifdef XINERAMA
624 XineramaScreenInfo *info; 618 XineramaScreenInfo *info;
625 Window pw; 619 Window pw;
@@ -677,7 +671,12 @@ setup(void)
677 mw = wa.width; 671 mw = wa.width;
678 } 672 }
679 promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; 673 promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
680 inputw = MIN(inputw, mw/3); 674 for (item = items; item && item->text; ++item) {
675 if ((tmp = textw_clamp(item->text, mw/3)) > inputw) {
676 if ((inputw = tmp) == mw/3)
677 break;
678 }
679 }
681 match(); 680 match();
682 681
683 /* create menu window */ 682 /* create menu window */