diff options
author | okan | 2012-10-23 16:08:59 +0000 |
---|---|---|
committer | okan | 2012-10-23 16:08:59 +0000 |
commit | ee40d3a297552e8382afafefeba1d125004cc9c6 (patch) | |
tree | b2425e8d96d660c3af04a801b62636f3bce44e9b | |
parent | fc956523c1ae1e53c438dcdfd56d7eb65af90f60 (diff) | |
download | cwm-ee40d3a297552e8382afafefeba1d125004cc9c6.tar.gz |
add a height to struct menu and use it in the most obvious of places.
Diffstat (limited to '')
-rw-r--r-- | menu.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: menu.c,v 1.38 2012/10/23 15:50:15 okan Exp $ + * $OpenBSD: menu.c,v 1.39 2012/10/23 16:08:59 okan Exp $ */ #include <sys/param.h> @@ -51,6 +51,7 @@ struct menu_ctx { int noresult; int prev; int entry; + int height; int width; int num; int x; @@ -301,7 +302,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, struct menu *mi; XineramaScreenInfo *xine; int xmin, xmax, ymin, ymax; - int n, dy, xsave, ysave; + int n, xsave, ysave; if (mc->list) { if (TAILQ_EMPTY(resultq) && mc->list) { @@ -317,12 +318,12 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, mc->num = 0; mc->width = 0; - dy = 0; + mc->height = 0; if (mc->hasprompt) { (void)snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%s", mc->promptstr, mc->searchstr, PROMPT_ECHAR); mc->width = font_width(sc, mc->dispstr, strlen(mc->dispstr)); - dy = font_height(sc); + mc->height = font_height(sc); mc->num = 1; } @@ -339,7 +340,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, mc->width = MAX(mc->width, font_width(sc, text, MIN(strlen(text), MENU_MAXENTRY))); - dy += font_height(sc); + mc->height += font_height(sc); mc->num++; } @@ -365,19 +366,20 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, mc->width = xmax - xmin; } - if (mc->y + dy >= ymax) - mc->y = ymax - dy; + if (mc->y + mc->height >= ymax) + mc->y = ymax - mc->height; /* never hide the top of the menu */ if (mc->y < ymin) { mc->y = ymin; - dy = ymax - ymin; + mc->height = ymax - ymin; } if (mc->x != xsave || mc->y != ysave) xu_ptr_setpos(sc->rootwin, mc->x, mc->y); XClearWindow(X_Dpy, sc->menuwin); - XMoveResizeWindow(X_Dpy, sc->menuwin, mc->x, mc->y, mc->width, dy); + XMoveResizeWindow(X_Dpy, sc->menuwin, mc->x, mc->y, + mc->width, mc->height); if (mc->hasprompt) { font_draw(sc, mc->dispstr, strlen(mc->dispstr), sc->menuwin, |