commit 00a5e13c9bee45208dc3864109e42e377f3580c6
parent df2566972ee893214a8fb521fa67bb3e47f8fa74
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date:   Sun,  9 Oct 2022 12:43:57 +0200

Make input width dynamic

Diffstat:
Mdmenu.c | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/dmenu.c b/dmenu.c @@ -621,12 +621,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; @@ -684,7 +685,12 @@ setup(void) mw = wa.width; } promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; - inputw = mw / 3; /* input width: ~33% of monitor width */ + 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 */