diff options
Diffstat (limited to 'dmenu.c')
-rw-r--r-- | dmenu.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -42,6 +42,7 @@ static void setup(void); | |||
42 | static void usage(void); | 42 | static void usage(void); |
43 | 43 | ||
44 | static char text[4096]; | 44 | static char text[4096]; |
45 | static int promptw; | ||
45 | static size_t cursor = 0; | 46 | static size_t cursor = 0; |
46 | static const char *prompt = NULL; | 47 | static const char *prompt = NULL; |
47 | static const char *normbgcolor = "#cccccc"; | 48 | static const char *normbgcolor = "#cccccc"; |
@@ -79,7 +80,7 @@ void | |||
79 | calcoffsetsh(void) { | 80 | calcoffsetsh(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 | ||