about summary refs log tree commit diff
path: root/menu.c
diff options
context:
space:
mode:
authorokan <okan>2012-10-23 16:08:59 +0000
committerokan <okan>2012-10-23 16:08:59 +0000
commit710347df1b5545daf215a24699540e7940ba6fa7 (patch)
tree8790db5c9fe6067585bd60717e43426eb7507169 /menu.c
parent637c52abf81512406d0f157357d961e72628f1da (diff)
downloadcwm-710347df1b5545daf215a24699540e7940ba6fa7.tar.gz
cwm-710347df1b5545daf215a24699540e7940ba6fa7.tar.xz
cwm-710347df1b5545daf215a24699540e7940ba6fa7.zip
add a height to struct menu and use it in the most obvious of places.
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/menu.c b/menu.c
index 7a64cb2..b3ac7ec 100644
--- a/menu.c
+++ b/menu.c
@@ -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,