X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu.c;h=175cbdc39585705cfb69c76789178cdf288ea3bf;hb=b54c179d585871d9c96311696f58824edeff09e4;hp=7dfc2d3481077b1777da9cda319872d7d82f7268;hpb=a7aee433ccfd2590e0785a7b93a89d8d0593a234;p=dmenu.git diff --git a/dmenu.c b/dmenu.c index 7dfc2d3..175cbdc 100644 --- a/dmenu.c +++ b/dmenu.c @@ -51,6 +51,7 @@ static const char *selfgcolor = "#ffffff"; static unsigned int inputw = 0; static unsigned int lines = 0; static unsigned int mw, mh; +static unsigned int promptw; static unsigned long normcol[ColLast]; static unsigned long selcol[ColLast]; static Atom utf8; @@ -79,7 +80,7 @@ void calcoffsetsh(void) { unsigned int w, x; - w = (prompt ? textw(dc, prompt) : 0) + inputw + textw(dc, "<") + textw(dc, ">"); + w = promptw + inputw + textw(dc, "<") + textw(dc, ">"); for(x = w, next = curr; next; next = next->right) if((x += MIN(textw(dc, next->text), mw / 3)) > mw) break; @@ -118,7 +119,7 @@ drawmenu(void) { dc->y = topbar ? 0 : mh - dc->h; /* print prompt? */ if(prompt) { - dc->w = textw(dc, prompt); + dc->w = promptw; drawtext(dc, prompt, selcol); dc->x = dc->w; } @@ -506,7 +507,9 @@ setup(void) { grabkeyboard(); setcanvas(dc, win, mw, mh); inputw = MIN(inputw, mw/3); + promptw = prompt ? MIN(textw(dc, prompt), mw/5) : 0; XMapRaised(dc->dpy, win); + text[0] = '\0'; match(); }