X-Git-Url: https://git.xinqibao.xyz/dmenu.git/blobdiff_plain/849f1dd7a3ac1fc6d6a88a9e2b7d7dedbcd0befc..c7a8f17bd20d3ba05e38a91430c565579d9f55bb:/dmenu.c?ds=sidebyside diff --git a/dmenu.c b/dmenu.c index 9b6a382..f6e6931 100644 --- a/dmenu.c +++ b/dmenu.c @@ -39,6 +39,10 @@ static void setup(void); static void usage(void); static char text[BUFSIZ]; +static int bh, mw, mh; +static int inputw = 0; +static int lines = 0; +static int promptw; static size_t cursor = 0; static const char *font = NULL; static const char *prompt = NULL; @@ -46,10 +50,6 @@ static const char *normbgcolor = "#cccccc"; static const char *normfgcolor = "#000000"; static const char *selbgcolor = "#0066ff"; static const char *selfgcolor = "#ffffff"; -static unsigned int bh, mw, mh; -static unsigned int inputw = 0; -static unsigned int lines = 0; -static unsigned int promptw; static unsigned long normcol[ColLast]; static unsigned long selcol[ColLast]; static Atom utf8; @@ -132,7 +132,7 @@ drawmenu(void) { if(next) drawtext(dc, ">", normcol); } - commitdraw(dc, win, mw, mh); + mapdraw(dc, win, mw, mh); } char * @@ -444,6 +444,7 @@ setup(void) { /* menu geometry */ bh = dc->font.height + 2; + lines = MAX(lines, 0); mh = (lines + 1) * bh; #ifdef XINERAMA if((info = XineramaQueryScreens(dc->dpy, &n))) { @@ -477,7 +478,7 @@ setup(void) { CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); grabkeyboard(); - setcanvas(dc, mw, mh); + resizedraw(dc, mw, mh); inputw = MIN(inputw, mw/3); promptw = prompt ? MIN(textw(dc, prompt), mw/5) : 0; XMapRaised(dc->dpy, win);