diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | calmwm.h | 9 | ||||
-rw-r--r-- | font.c | 51 | ||||
-rw-r--r-- | menu.c | 12 | ||||
-rw-r--r-- | mousefunc.c | 7 | ||||
-rw-r--r-- | xutil.c | 22 |
6 files changed, 37 insertions, 68 deletions
@@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.19 2011/06/23 22:48:59 naddy Exp $ +# $OpenBSD: Makefile,v 1.20 2013/05/19 23:38:20 okan Exp $ .include <bsd.xconf.mk> @@ -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} @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.204 2013/05/19 23:16:29 okan Exp $ + * $OpenBSD: calmwm.h,v 1.205 2013/05/19 23:38:21 okan Exp $ */ #ifndef _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 *); @@ -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: font.c,v 1.28 2013/05/19 23:16:29 okan Exp $ - */ - -#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)); -} @@ -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.61 2013/05/14 12:35:56 okan Exp $ + * $OpenBSD: menu.c,v 1.62 2013/05/19 23:38:21 okan Exp $ */ #include <sys/param.h> @@ -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 f16ca95..98b96df 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -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: mousefunc.c,v 1.50 2013/05/14 12:35:56 okan Exp $ + * $OpenBSD: mousefunc.c,v 1.51 2013/05/19 23:38:21 okan Exp $ */ #include <sys/param.h> @@ -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); } @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: xutil.c,v 1.62 2013/05/19 23:09:59 okan Exp $ + * $OpenBSD: xutil.c,v 1.63 2013/05/19 23:38:21 okan Exp $ */ #include <sys/param.h> @@ -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)); +} |