diff options
Diffstat (limited to '')
-rw-r--r-- | calmwm.h | 7 | ||||
-rw-r--r-- | font.c | 24 | ||||
-rw-r--r-- | menu.c | 34 | ||||
-rw-r--r-- | mousefunc.c | 15 |
4 files changed, 32 insertions, 48 deletions
@@ -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.192 2013/04/29 00:56:47 okan Exp $ + * $OpenBSD: calmwm.h,v 1.193 2013/05/02 17:25:15 okan Exp $ */ #ifndef _CALMWM_H_ @@ -450,14 +450,11 @@ void conf_ignore(struct conf *, char *); void conf_mousebind(struct conf *, char *, char *); void conf_ungrab(struct conf *, struct keybinding *); -int font_ascent(struct screen_ctx *); -int font_descent(struct screen_ctx *); void font_draw(struct screen_ctx *, const char *, int, Drawable, int, int, int); -u_int font_height(struct screen_ctx *); void font_init(struct screen_ctx *, const char *, const char **); -int font_width(struct screen_ctx *, const char *, int); +int font_width(XftFont *, const char *, int); void xev_loop(void); @@ -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: font.c,v 1.24 2012/12/17 18:34:06 okan Exp $ + * $OpenBSD: font.c,v 1.25 2013/05/02 17:25:15 okan Exp $ */ #include <sys/param.h> @@ -30,24 +30,6 @@ #include "calmwm.h" -int -font_ascent(struct screen_ctx *sc) -{ - return (sc->xftfont->ascent); -} - -int -font_descent(struct screen_ctx *sc) -{ - return (sc->xftfont->descent); -} - -u_int -font_height(struct screen_ctx *sc) -{ - return (sc->xftfont->height + 1); -} - void font_init(struct screen_ctx *sc, const char *name, const char **color) { @@ -82,11 +64,11 @@ font_init(struct screen_ctx *sc, const char *name, const char **color) } int -font_width(struct screen_ctx *sc, const char *text, int len) +font_width(XftFont *xftfont, const char *text, int len) { XGlyphInfo extents; - XftTextExtentsUtf8(X_Dpy, sc->xftfont, (const FcChar8*)text, + XftTextExtentsUtf8(X_Dpy, xftfont, (const FcChar8*)text, len, &extents); return (extents.xOff); @@ -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.54 2013/04/08 13:02:31 okan Exp $ + * $OpenBSD: menu.c,v 1.55 2013/05/02 17:25:15 okan Exp $ */ #include <sys/param.h> @@ -122,9 +122,11 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt, prompt, PROMPT_SCHAR); (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)); + mc.width = font_width(sc->xftfont, mc.dispstr, + strlen(mc.dispstr)); mc.hasprompt = 1; } + mc.height = sc->xftfont->height + 1; if (initial != NULL) (void)strlcpy(mc.searchstr, initial, sizeof(mc.searchstr)); @@ -135,8 +137,7 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt, mc.print = print; mc.entry = mc.prev = -1; - XMoveResizeWindow(X_Dpy, sc->menuwin, mc.x, mc.y, mc.width, - font_height(sc)); + XMoveResizeWindow(X_Dpy, sc->menuwin, mc.x, mc.y, mc.width, mc.height); XSelectInput(X_Dpy, sc->menuwin, evmask); XMapRaised(X_Dpy, sc->menuwin); @@ -164,6 +165,7 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt, goto out; /* FALLTHROUGH */ case Expose: + fprintf(stderr, "expose\n"); menu_draw(sc, &mc, menuq, &resultq); break; case MotionNotify: @@ -373,8 +375,9 @@ 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", mc->promptstr, mc->searchstr, PROMPT_ECHAR); - mc->width = font_width(sc, mc->dispstr, strlen(mc->dispstr)); - mc->height = font_height(sc); + mc->width = font_width(sc->xftfont, mc->dispstr, + strlen(mc->dispstr)); + mc->height = sc->xftfont->height + 1; mc->num = 1; } @@ -389,9 +392,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(sc, text, + mc->width = MAX(mc->width, font_width(sc->xftfont, text, MIN(strlen(text), MENU_MAXENTRY))); - mc->height += font_height(sc); + mc->height += sc->xftfont->height + 1; mc->num++; } @@ -425,7 +428,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, if (mc->hasprompt) { font_draw(sc, mc->dispstr, strlen(mc->dispstr), sc->menuwin, 0, - 0, font_ascent(sc)); + 0, sc->xftfont->ascent); n = 1; } else n = 0; @@ -433,7 +436,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, TAILQ_FOREACH(mi, resultq, resultentry) { char *text = mi->print[0] != '\0' ? mi->print : mi->text; - int y = n * font_height(sc) + font_ascent(sc) + 1; + int y = n * (sc->xftfont->height + 1) + sc->xftfont->ascent + 1; /* Stop drawing when menu doesn't fit inside the screen. */ if (mc->y + y > xine.h) @@ -469,10 +472,10 @@ menu_draw_entry(struct screen_ctx *sc, struct menu_ctx *mc, color = active ? CWM_COLOR_MENU_FG : CWM_COLOR_MENU_BG; text = mi->print[0] != '\0' ? mi->print : mi->text; XftDrawRect(sc->xftdraw, &sc->xftcolor[color], 0, - font_height(sc) * entry, mc->width, - font_height(sc) + font_descent(sc)); + (sc->xftfont->height + 1) * entry, mc->width, + (sc->xftfont->height + 1) + sc->xftfont->descent); font_draw(sc, text, strlen(text), sc->menuwin, active, - 0, font_height(sc) * entry + font_ascent(sc) + 1); + 0, (sc->xftfont->height + 1) * entry + sc->xftfont->ascent + 1); } static void @@ -525,11 +528,12 @@ menu_calc_entry(struct screen_ctx *sc, struct menu_ctx *mc, int x, int y) { int entry; - entry = y / font_height(sc); + entry = y / (sc->xftfont->height + 1); /* in bounds? */ if (x < 0 || x > mc->width || y < 0 || - y > font_height(sc) * mc->num || entry < 0 || entry >= mc->num) + y > (sc->xftfont->height + 1) * mc->num || + entry < 0 || entry >= mc->num) entry = -1; if (mc->hasprompt && entry == 0) diff --git a/mousefunc.c b/mousefunc.c index f975d13..a011bf8 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.46 2013/04/08 15:43:04 okan Exp $ + * $OpenBSD: mousefunc.c,v 1.47 2013/05/02 17:25:15 okan Exp $ */ #include <sys/param.h> @@ -55,23 +55,24 @@ mousefunc_sweep_draw(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; char asize[10]; /* fits "nnnnxnnnn\0" */ - int width, width_size, width_name; + int width, width_size, width_name, height; (void)snprintf(asize, sizeof(asize), "%dx%d", (cc->geom.w - cc->hint.basew) / cc->hint.incw, (cc->geom.h - cc->hint.baseh) / cc->hint.inch); - width_size = font_width(sc, asize, strlen(asize)) + 4; - width_name = font_width(sc, cc->name, strlen(cc->name)) + 4; + width_size = font_width(sc->xftfont, asize, strlen(asize)) + 4; + width_name = font_width(sc->xftfont, cc->name, strlen(cc->name)) + 4; width = MAX(width_size, width_name); + height = sc->xftfont->height + 1; XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0); - XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0, width, font_height(sc) * 2); + XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0, width, height * 2); XMapWindow(X_Dpy, sc->menuwin); XClearWindow(X_Dpy, sc->menuwin); font_draw(sc, cc->name, strlen(cc->name), sc->menuwin, 0, - 2, font_ascent(sc) + 1); + 2, sc->xftfont->ascent + 1); font_draw(sc, asize, strlen(asize), sc->menuwin, 0, - width / 2 - width_size / 2, font_height(sc) + font_ascent(sc) + 1); + width / 2 - width_size / 2, height + sc->xftfont->ascent + 1); } void |