aboutsummaryrefslogtreecommitdiff
path: root/dmenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'dmenu.c')
-rw-r--r--dmenu.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/dmenu.c b/dmenu.c
index 7dfc2d3..608023d 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -42,6 +42,7 @@ static void setup(void);
42static void usage(void); 42static void usage(void);
43 43
44static char text[4096]; 44static char text[4096];
45static int promptw;
45static size_t cursor = 0; 46static size_t cursor = 0;
46static const char *prompt = NULL; 47static const char *prompt = NULL;
47static const char *normbgcolor = "#cccccc"; 48static const char *normbgcolor = "#cccccc";
@@ -79,7 +80,7 @@ void
79calcoffsetsh(void) { 80calcoffsetsh(void) {
80 unsigned int w, x; 81 unsigned int w, x;
81 82
82 w = (prompt ? textw(dc, prompt) : 0) + inputw + textw(dc, "<") + textw(dc, ">"); 83 w = promptw + inputw + textw(dc, "<") + textw(dc, ">");
83 for(x = w, next = curr; next; next = next->right) 84 for(x = w, next = curr; next; next = next->right)
84 if((x += MIN(textw(dc, next->text), mw / 3)) > mw) 85 if((x += MIN(textw(dc, next->text), mw / 3)) > mw)
85 break; 86 break;
@@ -118,7 +119,7 @@ drawmenu(void) {
118 dc->y = topbar ? 0 : mh - dc->h; 119 dc->y = topbar ? 0 : mh - dc->h;
119 /* print prompt? */ 120 /* print prompt? */
120 if(prompt) { 121 if(prompt) {
121 dc->w = textw(dc, prompt); 122 dc->w = promptw;
122 drawtext(dc, prompt, selcol); 123 drawtext(dc, prompt, selcol);
123 dc->x = dc->w; 124 dc->x = dc->w;
124 } 125 }
@@ -506,7 +507,9 @@ setup(void) {
506 grabkeyboard(); 507 grabkeyboard();
507 setcanvas(dc, win, mw, mh); 508 setcanvas(dc, win, mw, mh);
508 inputw = MIN(inputw, mw/3); 509 inputw = MIN(inputw, mw/3);
510 promptw = prompt ? MIN(textw(dc, prompt), mw/5) : 0;
509 XMapRaised(dc->dpy, win); 511 XMapRaised(dc->dpy, win);
512 text[0] = '\0';
510 match(); 513 match();
511} 514}
512 515