summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2013-05-19 23:38:20 +0000
committerokan <okan>2013-05-19 23:38:20 +0000
commit5b4c55616a58c058cb1f3f80c4e04a24b8e824a3 (patch)
treee4f2b1bad1a859085f63bb4e742b35aec4bba1d7
parente41c84c752c46b78c0996489e150515751ae8ac8 (diff)
downloadcwm-5b4c55616a58c058cb1f3f80c4e04a24b8e824a3.tar.gz
cwm-5b4c55616a58c058cb1f3f80c4e04a24b8e824a3.tar.xz
cwm-5b4c55616a58c058cb1f3f80c4e04a24b8e824a3.zip
move the 2 small font helper functions to xutil.c
-rw-r--r--Makefile2
-rw-r--r--calmwm.h7
-rw-r--r--font.c51
-rw-r--r--menu.c10
-rw-r--r--mousefunc.c5
-rw-r--r--xutil.c20
6 files changed, 32 insertions, 63 deletions
diff --git a/Makefile b/Makefile
index 1bd9271..25584c7 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ PROG=		cwm
 
 SRCS=		calmwm.c screen.c xmalloc.c client.c menu.c \
 		search.c util.c xutil.c conf.c xevents.c group.c \
-		kbfunc.c mousefunc.c font.c parse.y
+		kbfunc.c mousefunc.c parse.y
 
 CPPFLAGS+=	-I${X11BASE}/include -I${X11BASE}/include/freetype2 -I${.CURDIR}
 
diff --git a/calmwm.h b/calmwm.h
index a18f92f..b45e9df 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -444,10 +444,6 @@ void			 conf_mousebind(struct conf *, char *, char *);
 void			 conf_screen(struct screen_ctx *);
 void			 conf_ungrab(struct conf *, struct keybinding *);
 
-void			 font_draw(struct screen_ctx *, const char *,
-			     Drawable, int, int, int);
-int			 font_width(XftFont *, const char *, int);
-
 void			 xev_loop(void);
 
 void			 xu_btn_grab(Window, int, u_int);
@@ -466,6 +462,9 @@ void			 xu_ptr_setpos(Window, int, int);
 void			 xu_ptr_ungrab(void);
 void			 xu_sendmsg(Window, Atom, long);
 void			 xu_set_wm_state(Window win, int);
+void			 xu_xft_draw(struct screen_ctx *, const char *,
+			     Drawable, 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/font.c b/font.c
deleted file mode 100644
index fc4f3c1..0000000
--- a/font.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * calmwm - the calm window manager
- *
- * Copyright (c) 2005 Marius Eriksen <marius@monkey.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * $OpenBSD$
- */
-
-#include <sys/param.h>
-#include <sys/queue.h>
-
-#include <err.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "calmwm.h"
-
-int
-font_width(XftFont *xftfont, const char *text, int len)
-{
-	XGlyphInfo	 extents;
-
-	XftTextExtentsUtf8(X_Dpy, xftfont, (const FcChar8*)text,
-	    len, &extents);
-
-	return (extents.xOff);
-}
-
-void
-font_draw(struct screen_ctx *sc, const char *text,
-    Drawable d, int color, int x, int y)
-{
-	XftDrawChange(sc->xftdraw, d);
-	XftDrawStringUtf8(sc->xftdraw, &sc->xftcolor[color], sc->xftfont, x, y,
-	    (const FcChar8*)text, strlen(text));
-}
diff --git a/menu.c b/menu.c
index c2bd37c..80e1ce7 100644
--- a/menu.c
+++ b/menu.c
@@ -367,7 +367,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
 	if (mc->hasprompt) {
 		(void)snprintf(mc->dispstr, sizeof(mc->dispstr), "%s%s%s%s",
 		    mc->promptstr, PROMPT_SCHAR, mc->searchstr, PROMPT_ECHAR);
-		mc->width = font_width(sc->xftfont, mc->dispstr,
+		mc->width = xu_xft_width(sc->xftfont, mc->dispstr,
 		    strlen(mc->dispstr));
 		mc->height = sc->xftfont->height + 1;
 		mc->num = 1;
@@ -384,7 +384,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
 			text = mi->text;
 		}
 
-		mc->width = MAX(mc->width, font_width(sc->xftfont, text,
+		mc->width = MAX(mc->width, xu_xft_width(sc->xftfont, text,
 		    MIN(strlen(text), MENU_MAXENTRY)));
 		mc->height += sc->xftfont->height + 1;
 		mc->num++;
@@ -419,7 +419,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
 	    mc->width, mc->height);
 
 	if (mc->hasprompt) {
-		font_draw(sc, mc->dispstr, sc->menuwin, CWM_COLOR_MENU_FONT,
+		xu_xft_draw(sc, mc->dispstr, sc->menuwin, CWM_COLOR_MENU_FONT,
 		    0, sc->xftfont->ascent);
 		n = 1;
 	} else
@@ -434,7 +434,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
 		if (mc->y + y > xine.h)
 			break;
 
-		font_draw(sc, text, sc->menuwin, CWM_COLOR_MENU_FONT, 0, y);
+		xu_xft_draw(sc, text, sc->menuwin, CWM_COLOR_MENU_FONT, 0, y);
 		n++;
 	}
 	if (mc->hasprompt && n > 1 && (mc->searchstr[0] != '\0')) {
@@ -466,7 +466,7 @@ menu_draw_entry(struct screen_ctx *sc, struct menu_ctx *mc,
 	    (sc->xftfont->height + 1) * entry, mc->width,
 	    (sc->xftfont->height + 1) + sc->xftfont->descent);
 	color = active ? CWM_COLOR_MENU_FONT_SEL : CWM_COLOR_MENU_FONT;
-	font_draw(sc, text, sc->menuwin, color,
+	xu_xft_draw(sc, text, sc->menuwin, color,
 	    0, (sc->xftfont->height + 1) * entry + sc->xftfont->ascent + 1);
 }
 
diff --git a/mousefunc.c b/mousefunc.c
index 205f073..64670b5 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -58,11 +58,12 @@ mousefunc_sweep_draw(struct client_ctx *cc)
 
 	XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0);
 	XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0,
-	    font_width(sc->xftfont, asize, strlen(asize)), sc->xftfont->height);
+	    xu_xft_width(sc->xftfont, asize, strlen(asize)),
+	    sc->xftfont->height);
 	XMapWindow(X_Dpy, sc->menuwin);
 	XClearWindow(X_Dpy, sc->menuwin);
 
-	font_draw(sc, asize, sc->menuwin, CWM_COLOR_MENU_FONT,
+	xu_xft_draw(sc, asize, sc->menuwin, CWM_COLOR_MENU_FONT,
 	    0, sc->xftfont->ascent + 1);
 }
 
diff --git a/xutil.c b/xutil.c
index bcc7366..3e2b36c 100644
--- a/xutil.c
+++ b/xutil.c
@@ -429,3 +429,23 @@ 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,
+    Drawable d, int color, int x, int y)
+{
+	XftDrawChange(sc->xftdraw, d);
+	XftDrawStringUtf8(sc->xftdraw, &sc->xftcolor[color], sc->xftfont,
+	    x, y, (const FcChar8*)text, strlen(text));
+}