summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--calmwm.h3
-rw-r--r--menu.c32
-rw-r--r--mousefunc.c10
-rw-r--r--xutil.c18
4 files changed, 31 insertions, 32 deletions
diff --git a/calmwm.h b/calmwm.h
index 44084ea..fd0b864 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -549,9 +549,6 @@ int			 xu_ptr_grab(Window, unsigned int, Cursor);
 int			 xu_ptr_regrab(unsigned int, Cursor);
 void			 xu_ptr_setpos(Window, int, int);
 void			 xu_ptr_ungrab(void);
-void			 xu_xft_draw(struct screen_ctx *, const char *,
-			     int, int, int);
-int			 xu_xft_width(XftFont *, const char *, int);
 void 			 xu_xorcolor(XftColor, XftColor, XftColor *);
 
 void			 xu_ewmh_net_supported(struct screen_ctx *);
diff --git a/menu.c b/menu.c
index 5c91ce1..5aefe18 100644
--- a/menu.c
+++ b/menu.c
@@ -334,6 +334,7 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
 	struct menu		*mi;
 	struct geom		 area;
 	int			 n, xsave, ysave;
+	XGlyphInfo		 extents;
 
 	if (mc->list) {
 		if (TAILQ_EMPTY(resultq)) {
@@ -352,8 +353,11 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
 	if (mc->hasprompt) {
 		(void)snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%s%s",
 		    mc->promptstr, PROMPT_SCHAR, mc->searchstr, PROMPT_ECHAR);
-		mc->geom.w = xu_xft_width(sc->xftfont, mc->dispstr,
-		    strlen(mc->dispstr));
+
+		XftTextExtentsUtf8(X_Dpy, sc->xftfont,
+		    (const FcChar8*)mc->dispstr, strlen(mc->dispstr), &extents);
+
+		mc->geom.w = extents.xOff;
 		mc->geom.h = sc->xftfont->height + 1;
 		mc->num = 1;
 	}
@@ -365,8 +369,11 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
 			(void)snprintf(mi->print, sizeof(mi->print),
 			    "%s", mi->text);
 
-		mc->geom.w = MAX(mc->geom.w, xu_xft_width(sc->xftfont,
-		    mi->print, MIN(strlen(mi->print), MENU_MAXENTRY)));
+		XftTextExtentsUtf8(X_Dpy, sc->xftfont,
+		    (const FcChar8*)mi->print,
+		    MIN(strlen(mi->print), MENU_MAXENTRY), &extents);
+
+		mc->geom.w = MAX(mc->geom.w, extents.xOff);
 		mc->geom.h += sc->xftfont->height + 1;
 		mc->num++;
 	}
@@ -400,8 +407,10 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
 	    mc->geom.w, mc->geom.h);
 
 	if (mc->hasprompt) {
-		xu_xft_draw(sc, mc->dispstr, CWM_COLOR_MENU_FONT,
-		    0, sc->xftfont->ascent);
+		XftDrawStringUtf8(sc->xftdraw,
+		    &sc->xftcolor[CWM_COLOR_MENU_FONT], sc->xftfont,
+		    0, sc->xftfont->ascent,
+		    (const FcChar8*)mc->dispstr, strlen(mc->dispstr));
 		n = 1;
 	} else
 		n = 0;
@@ -413,7 +422,10 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
 		if (mc->geom.y + y > area.h)
 			break;
 
-		xu_xft_draw(sc, mi->print, CWM_COLOR_MENU_FONT, 0, y);
+		XftDrawStringUtf8(sc->xftdraw,
+		    &sc->xftcolor[CWM_COLOR_MENU_FONT], sc->xftfont,
+		    0, y,
+		    (const FcChar8*)mi->print, strlen(mi->print));
 		n++;
 	}
 	if (mc->hasprompt && n > 1)
@@ -442,8 +454,10 @@ menu_draw_entry(struct menu_ctx *mc, struct menu_q *resultq,
 	    (sc->xftfont->height + 1) * entry, mc->geom.w,
 	    (sc->xftfont->height + 1) + sc->xftfont->descent);
 	color = (active) ? CWM_COLOR_MENU_FONT_SEL : CWM_COLOR_MENU_FONT;
-	xu_xft_draw(sc, mi->print, color,
-	    0, (sc->xftfont->height + 1) * entry + sc->xftfont->ascent + 1);
+	XftDrawStringUtf8(sc->xftdraw,
+	    &sc->xftcolor[color], sc->xftfont,
+	    0, (sc->xftfont->height + 1) * entry + sc->xftfont->ascent + 1,
+	    (const FcChar8*)mi->print, strlen(mi->print));
 }
 
 static void
diff --git a/mousefunc.c b/mousefunc.c
index 42b7fb1..3366bf1 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -39,16 +39,22 @@ mousefunc_sweep_draw(struct client_ctx *cc)
 {
 	struct screen_ctx	*sc = cc->sc;
 	char			 s[14]; /* fits " nnnn x nnnn \0" */
+	XGlyphInfo		 extents;
 
 	(void)snprintf(s, sizeof(s), " %4d x %-4d ", cc->dim.w, cc->dim.h);
 
+	XftTextExtentsUtf8(X_Dpy, sc->xftfont, (const FcChar8*)s,
+	    strlen(s), &extents);
+
 	XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0);
 	XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0,
-	    xu_xft_width(sc->xftfont, s, strlen(s)), sc->xftfont->height);
+	    extents.xOff, sc->xftfont->height);
 	XMapWindow(X_Dpy, sc->menuwin);
 	XClearWindow(X_Dpy, sc->menuwin);
 
-	xu_xft_draw(sc, s, CWM_COLOR_MENU_FONT, 0, sc->xftfont->ascent + 1);
+	XftDrawStringUtf8(sc->xftdraw, &sc->xftcolor[CWM_COLOR_MENU_FONT],
+	    sc->xftfont, 0, sc->xftfont->ascent + 1,
+	    (const FcChar8*)s, strlen(s));
 }
 
 void
diff --git a/xutil.c b/xutil.c
index eaaa0a4..39639ef 100644
--- a/xutil.c
+++ b/xutil.c
@@ -531,21 +531,3 @@ xu_xorcolor(XftColor a, XftColor b, XftColor *r)
 	r->color.blue = a.color.blue ^ b.color.blue;
 	r->color.alpha = 0xffff;
 }
-
-int
-xu_xft_width(XftFont *xftfont, const char *text, int len)
-{
-	XGlyphInfo	 extents;
-
-	XftTextExtentsUtf8(X_Dpy, xftfont, (const FcChar8*)text,
-	    len, &extents);
-
-	return(extents.xOff);
-}
-
-void
-xu_xft_draw(struct screen_ctx *sc, const char *text, int color, int x, int y)
-{
-	XftDrawStringUtf8(sc->xftdraw, &sc->xftcolor[color], sc->xftfont,
-	    x, y, (const FcChar8*)text, strlen(text));
-}