diff --git a/libs/draw.c b/libs/draw.c index e852e30..dbbd467 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -573,58 +573,43 @@ void drawmenu_layer(void) { calcoffsets(); get_mh(); - // why have an empty line? - if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps)) { - y -= bh; - mh -= bh; + // bh must be removed from menu height resizing later + if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps) && lines) { + y -= bh; + } - if (!protocol && (hideimage || !image)) { -#if USEX - XResizeWindow(dpy, win, mw - 2 * sp - 2 * borderwidth, mh); - drw_resize(drw, mw - 2 * sp - 2 * borderwidth, mh); -#endif - } else if (protocol && (hideimage || !image)) { -#if USEWAYLAND - state.width = mw; - state.height = mh; + if (!hideprompt && !fullscreen) { + w = promptw; + x = drawprompt(x, y, w); + } - set_layer_size(&state, state.width, state.height); -#endif - } - } + if (!hideinput && !fullscreen) { + w = (lines > 0 || !matches) ? mw - x : inputw; + x = drawinput(x, y, w); + } - if (!hideprompt && !fullscreen) { - w = promptw; - x = drawprompt(x, y, w); - } + if (!hidemode && !fullscreen) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext); - if (!hideinput && !fullscreen) { - w = (lines > 0 || !matches) ? mw - x : inputw; - x = drawinput(x, y, w); - } + // draw the items, this function also calls drawrarrow() and drawlarrow() + if (!hideitem) drawitem(x, y, w); - if (!hidemode && !fullscreen) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext); + if (!hidematchcount && !fullscreen) { + w = numberWidth; + drawnumber(mw - numberWidth - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w); + } - // draw the items, this function also calls drawrarrow() and drawlarrow() - if (!hideitem) drawitem(x, y, w); + if (!hidemode && !fullscreen) { + w = modeWidth; + drawmode(mw - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w); + } - if (!hidematchcount && !fullscreen) { - w = numberWidth; - drawnumber(mw - numberWidth - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w); - } - - if (!hidemode && !fullscreen) { - w = modeWidth; - drawmode(mw - modeWidth - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w); - } - - if (!hidecaps && !fullscreen) { - w = capsWidth; - drawcaps(mw - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w); - } + if (!hidecaps && !fullscreen) { + w = capsWidth; + drawcaps(mw - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w); + } #if USEX - drawimage(); - drw_map(drw, win, 0, 0, mw, mh); + drawimage(); + drw_map(drw, win, 0, 0, mw, mh); #endif } diff --git a/libs/img.c b/libs/img.c index 1175397..9ae30c2 100644 --- a/libs/img.c +++ b/libs/img.c @@ -107,16 +107,17 @@ void drawimage(void) { if (height > width) width = height; - drw_img(drw, leftmargin+(imagewidth-width)/2+xta, wta+leftmargin); + drw_img(drw, leftmargin + (imagewidth - width) / 2 + xta, wta + leftmargin); } else if (imageposition == 1 && image) { // bottom mode = 1 if (height > width) width = height; - drw_img(drw, leftmargin+(imagewidth-width)/2+xta, mh-height-leftmargin); + + drw_img(drw, leftmargin + (imagewidth - width) / 2 + xta, mh - height - leftmargin); } else if (imageposition == 2 && image) { // center mode = 2 - drw_img(drw, leftmargin+(imagewidth-width)/2+xta, (mh-wta-height)/2+wta); + drw_img(drw, leftmargin + (imagewidth - width) / 2 + xta, (mh - wta - height) / 2 + wta); } else if (image) { // top center - int minh = MIN(height, mh-bh-leftmargin*2); - drw_img(drw, leftmargin+(imagewidth-width)/2+xta, (minh-height)/2+wta+leftmargin); + int minh = MIN(height, mh - bh - leftmargin * 2); + drw_img(drw, leftmargin + (imagewidth - width) / 2 + xta, (minh - height) / 2 + wta + leftmargin); } } @@ -354,7 +355,6 @@ void resizetoimageheight(int imagewidth, int imageheight) { void resizetoimageheight_x11(int imageheight) { int omh = mh, olines = lines; lines = reallines; - int wtr = 0; int x, y; #if USEXINERAMA @@ -370,16 +370,8 @@ void resizetoimageheight_x11(int imageheight) { lines = (imageheight + imagegaps * 2) / bh; } - if (hideprompt && hideinput && hidemode && hidematchcount) { - wtr = bh; - } - get_mh(); - if (mh - bh < imageheight + imagegaps * 2) { - mh = (imageheight + imagegaps * 2 + bh) - wtr; - } - // init xinerama screens #if USEXINERAMA int i = 0; diff --git a/libs/wl/wayland.c b/libs/wl/wayland.c index d4cd667..8ccdc6e 100644 --- a/libs/wl/wayland.c +++ b/libs/wl/wayland.c @@ -243,7 +243,8 @@ void buttonpress_wl(uint32_t button, double ex, double ey) { if (!hidemode) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext); if (!hidecaps) capsWidth = pango_caps ? TEXTWM(capstext) : TEXTW(capstext); - if (!strcmp(capstext, "")) capsWidth = 0; // No caps lock width for no chars + if (!strcmp(capstext, "")) + capsWidth = 0; click = ClickWindow; // Used as a default, will be overriden. @@ -543,14 +544,14 @@ void resizeclient_wl(struct state *state) { reallines = lines; get_mh(); + if (hideprompt && hideinput && hidemode && hidematchcount && hidecaps) { + mh -= bh; + } + if (mh == omh) { return; } - // why have an empty line? when there's nothing to draw there anyway? - if (hideprompt && hideinput && hidemode && hidematchcount) - mh += bh; - state->width = mw; state->height = mh; diff --git a/libs/x11/client.c b/libs/x11/client.c index 35a63f6..da395df 100644 --- a/libs/x11/client.c +++ b/libs/x11/client.c @@ -98,6 +98,10 @@ void resizeclient_x11(void) { get_mh(); + if (hideprompt && hideinput && hidemode && hidematchcount && hidecaps) { + mh -= bh; + } + // init xinerama screens #if USEXINERAMA int i = 0; @@ -157,10 +161,6 @@ void resizeclient_x11(void) { } } - // why have an empty line? when there's nothing to draw there anyway? - if (hideprompt && hideinput && hidemode && hidematchcount) - mh += bh; - // no window/invalid window or menu height we had before is the same as the current window height if (!win || omh == mh) return; diff --git a/libs/x11/mouse.c b/libs/x11/mouse.c index a57d2de..8d3bf9c 100644 --- a/libs/x11/mouse.c +++ b/libs/x11/mouse.c @@ -26,7 +26,9 @@ void buttonpress_x11(XEvent *e) { if (!hidemode) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext); if (!hidecaps) capsWidth = pango_caps ? TEXTWM(capstext) : TEXTW(capstext); - if (!strcmp(capstext, "")) capsWidth = 0; // no caps lock width for no chars + if (!strcmp(capstext, "")) + capsWidth = 0; + if (ev->window != win) return; // if incorrect or wrong window, return click = ClickWindow; // clicking anywhere, we use this and override it if we clicked on something specific diff --git a/spmenu.c b/spmenu.c index 86cdbc8..340e313 100644 --- a/spmenu.c +++ b/spmenu.c @@ -469,6 +469,10 @@ void get_width(void) { void get_mh(void) { mh = (lines + 1) * bh; mh += 2 * menumarginv; + + if ((hideprompt && hideinput && hidemode && hidematchcount && hidecaps) && lines) { + mh -= bh; + } } void set_mode(void) {