diff --git a/libs/draw.c b/libs/draw.c index 71b6d7f..ec99492 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -567,6 +567,7 @@ void drawmenu_layer(void) { y += menumarginv; calcoffsets(); + get_mh(); // why have an empty line? if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps @@ -576,7 +577,7 @@ void drawmenu_layer(void) { )) { #endif y -= bh; - mh = (lines + 1) * bh - bh + 2 * menumarginv; + mh -= bh; if (!protocol) { #if USEX @@ -594,7 +595,7 @@ void drawmenu_layer(void) { #if USEIMAGE else if (hideprompt && hideinput && hidemode && hidematchcount && hidecaps) { y -= bh; - mh = (lines + 1) * bh - bh + 2 * menumarginv; + mh -= bh; #if USEWAYLAND if (protocol) { diff --git a/libs/img.c b/libs/img.c index 6957113..1175397 100644 --- a/libs/img.c +++ b/libs/img.c @@ -374,10 +374,10 @@ void resizetoimageheight_x11(int imageheight) { wtr = bh; } - mh = MAX((lines + 1) * bh + 2 * menumarginv, ((lines + 1) * bh) - wtr + 2 * menumarginv); + get_mh(); if (mh - bh < imageheight + imagegaps * 2) { - mh = (imageheight + imagegaps * 2 + bh) - wtr + 2 * menumarginv; + mh = (imageheight + imagegaps * 2 + bh) - wtr; } // init xinerama screens @@ -478,10 +478,10 @@ void resizetoimageheight_wl(int imageheight) { wtr = bh; } - mh = MAX((lines + 1) * bh + 2 * menumarginv, ((lines + 1) * bh) - wtr + 2 * menumarginv); + get_mh(); if (mh - bh < imageheight + imagegaps * 2) { - mh = (imageheight + imagegaps * 2 + bh) - wtr + 2 * menumarginv; + mh = (imageheight + imagegaps * 2 + bh) - wtr; } if (omh == mh) { diff --git a/libs/wl/init.c b/libs/wl/init.c index 65e26a4..aa21055 100644 --- a/libs/wl/init.c +++ b/libs/wl/init.c @@ -33,7 +33,7 @@ void handle_wl(void) { create_layer(&state, "spmenu"); mw = (menuwidth > 0 ? menuwidth : output_width); - mh = (lines + 1) * bh + 2 * menumarginv; + get_mh(); if (menuposition == 2) { mw = MIN(MAX(max_textw() + promptw, minwidth), output_width); diff --git a/libs/wl/wayland.c b/libs/wl/wayland.c index 2d240d8..d4cd667 100644 --- a/libs/wl/wayland.c +++ b/libs/wl/wayland.c @@ -541,7 +541,7 @@ void resizeclient_wl(struct state *state) { bh = MAX(drw->font->h, drw->font->h + 2 + lineheight); lines = MIN(ic, MAX(lines, 0)); reallines = lines; - mh = (lines + 1) * bh + 2 * menumarginv; + get_mh(); if (mh == omh) { return; diff --git a/libs/x11/client.c b/libs/x11/client.c index f283a87..35a63f6 100644 --- a/libs/x11/client.c +++ b/libs/x11/client.c @@ -96,7 +96,7 @@ void resizeclient_x11(void) { if (image) resizetoimageheight(imagewidth, imageheight); #endif - mh = (lines + 1) * bh + 2 * menumarginv; + get_mh(); // init xinerama screens #if USEXINERAMA diff --git a/libs/x11/init.c b/libs/x11/init.c index d047109..43732aa 100644 --- a/libs/x11/init.c +++ b/libs/x11/init.c @@ -134,7 +134,7 @@ void prepare_window_size_x11(void) { reallines = lines; lrpad = drw->font->h + textpadding; - mh = (lines + 1) * bh + 2 * menumarginv; // lines + 1 * bh is the menu height + get_mh(); return; } diff --git a/spmenu.c b/spmenu.c index a765272..86cdbc8 100644 --- a/spmenu.c +++ b/spmenu.c @@ -197,6 +197,7 @@ static void grabfocus(void); #endif static void resizeclient(void); static void get_width(void); +static void get_mh(void); static void set_mode(void); static void handle(void); static void appenditem(struct item *item, struct item **list, struct item **last); @@ -465,6 +466,11 @@ void get_width(void) { inputw = mw / 3; } +void get_mh(void) { + mh = (lines + 1) * bh; + mh += 2 * menumarginv; +} + void set_mode(void) { if (!type) { // no typing allowed, require normal mode mode = 0;