summary refs log tree commit diff
path: root/menu.c
diff options
context:
space:
mode:
authoroga <oga>2008-06-15 02:47:46 +0000
committeroga <oga>2008-06-15 02:47:46 +0000
commit07cd0b1ac55f819f42b2936339843bb85e7630bb (patch)
tree0e40db1dce753062bb6d979553e426b18cb71269 /menu.c
parent96d7310b4a224d50aeb2e5e94031d14b9bd6daf5 (diff)
downloadcwm-07cd0b1ac55f819f42b2936339843bb85e7630bb.tar.gz
cwm-07cd0b1ac55f819f42b2936339843bb85e7630bb.tar.xz
cwm-07cd0b1ac55f819f42b2936339843bb85e7630bb.zip
Rip out and burn the HASH_* stuff. We don't need a SPLAY tree for one font.
makes the code a lot simpler. While here rearrange the font handling functions
to be less shit.

ok and help okan@.
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/menu.c b/menu.c
index df870fd..6db9a53 100644
--- a/menu.c
+++ b/menu.c
@@ -74,7 +74,6 @@ menu_filter(struct menu_q *menuq, char *prompt, char *initial, int dummy,
 	XEvent			 e;
 	Window			 focuswin;
 	int			 Mask, focusrevert;
-	struct fontdesc		*font = DefaultFont;
 
 	TAILQ_INIT(&resultq);
 
@@ -92,7 +91,7 @@ menu_filter(struct menu_q *menuq, char *prompt, char *initial, int dummy,
 		    PROMPT_SCHAR);
 		snprintf(mc.dispstr, sizeof(mc.dispstr), "%s%s%c", mc.promptstr,
 		    mc.searchstr, PROMPT_ECHAR);
-		mc.width = font_width(font, mc.dispstr, strlen(mc.dispstr));
+		mc.width = font_width(mc.dispstr, strlen(mc.dispstr));
 		mc.hasprompt = 1;
 	}
 
@@ -106,7 +105,7 @@ menu_filter(struct menu_q *menuq, char *prompt, char *initial, int dummy,
 	mc.entry = mc.prev = -1;
 
 	XMoveResizeWindow(X_Dpy, sc->menuwin, mc.x, mc.y, mc.width,
-	    sc->fontheight);
+	    font_height());
 	XSelectInput(X_Dpy, sc->menuwin, Mask);
 	XMapRaised(X_Dpy, sc->menuwin);
 
@@ -260,7 +259,6 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
 	int		 dy;
 	int		 xsave, ysave;
 	int		 warp;
-	struct fontdesc	*font = DefaultFont;
 
 	if (mc->list) {
 		if (TAILQ_EMPTY(resultq) && mc->list) {
@@ -280,8 +278,8 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
 	if (mc->hasprompt) {
 		snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%c",
 		    mc->promptstr, mc->searchstr, PROMPT_ECHAR);
-		mc->width = font_width(font, mc->dispstr, strlen(mc->dispstr));
-		dy = sc->fontheight;
+		mc->width = font_width(mc->dispstr, strlen(mc->dispstr));
+		dy = font_height();
 		mc->num = 1;
 	}
 
@@ -296,9 +294,9 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
 			text = mi->text;
 		}
 
-		mc->width = MAX(mc->width, font_width(font, text,
+		mc->width = MAX(mc->width, font_width(text,
 		    MIN(strlen(text), MENU_MAXENTRY)));
-		dy += sc->fontheight;
+		dy += font_height();
 		mc->num++;
 	}
 
@@ -322,8 +320,8 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
 	XMoveResizeWindow(X_Dpy, sc->menuwin, mc->x, mc->y, mc->width, dy);
 
 	if (mc->hasprompt) {
-		font_draw(font, mc->dispstr, strlen(mc->dispstr), sc->menuwin,
-		    0, font_ascent(font) + 1);
+		font_draw(sc, mc->dispstr, strlen(mc->dispstr), sc->menuwin,
+		    0, font_ascent() + 1);
 		n = 1;
 	} else
 		n = 0;
@@ -332,20 +330,18 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
 		char *text = mi->print[0] != '\0' ?
 		    mi->print : mi->text;
 
-		font_draw(font, text,
-		    MIN(strlen(text), MENU_MAXENTRY),
-		    sc->menuwin,
-		    0, n*sc->fontheight + font_ascent(font) + 1);
+		font_draw(sc, text, MIN(strlen(text), MENU_MAXENTRY),
+		    sc->menuwin, 0, n*font_height() + font_ascent() + 1);
 		n++;
 	}
 
 	if (mc->hasprompt && n > 1)
 		XFillRectangle(X_Dpy, sc->menuwin, sc->gc,
-		    0, sc->fontheight, mc->width, sc->fontheight);
+		    0, font_height(), mc->width, font_height());
 
 	if (mc->noresult)
 		XFillRectangle(X_Dpy, sc->menuwin, sc->gc,
-		    0, 0, mc->width, sc->fontheight);
+		    0, 0, mc->width, font_height());
 }
 
 void
@@ -356,11 +352,11 @@ menu_handle_move(XEvent *e, struct menu_ctx *mc, struct screen_ctx *sc)
 
 	if (mc->prev != -1)
 		XFillRectangle(X_Dpy, sc->menuwin, sc->gc, 0,
-		    sc->fontheight * mc->prev, mc->width, sc->fontheight);
+		    font_height() * mc->prev, mc->width, font_height());
 	if (mc->entry != -1) {
 		xu_ptr_regrab(MenuGrabMask, Cursor_select);
 		XFillRectangle(X_Dpy, sc->menuwin, sc->gc, 0,
-		    sc->fontheight * mc->entry, mc->width, sc->fontheight);
+		    font_height() * mc->entry, mc->width, font_height());
 	} else
 		xu_ptr_regrab(MenuGrabMask, Cursor_default);
 }
@@ -392,10 +388,10 @@ menu_handle_release(XEvent *e, struct menu_ctx *mc, struct screen_ctx *sc,
 static int
 menu_calc_entry(struct screen_ctx *sc, struct menu_ctx *mc, int x, int y)
 {
-	int entry = y / sc->fontheight;
+	int entry = y / font_height();
 
 	/* in bounds? */
-	if (x < 0 || x > mc->width || y < 0 || y > sc->fontheight*mc->num ||
+	if (x < 0 || x > mc->width || y < 0 || y > font_height()*mc->num ||
 	    entry < 0 || entry >= mc->num)
 		entry = -1;