the below seems to work: Walter (thanks!) found the spot i missed on
replacing height with ascent+descent.

please let me know.

regards,
okan

Index: menu.c
===================================================================
RCS file: /home/open/cvs/xenocara/app/cwm/menu.c,v
retrieving revision 1.109
diff -u -p -r1.109 menu.c
--- menu.c      27 Feb 2020 14:56:39 -0000      1.109
+++ menu.c      14 Oct 2022 18:03:39 -0000
@@ -355,7 +355,7 @@ menu_draw(struct menu_ctx *mc, struct me
        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->geom.h = sc->xftfont->ascent + sc->xftfont->descent;
        mc->num = 1;
 
        TAILQ_FOREACH(mi, resultq, resultentry) {
@@ -364,7 +364,7 @@ menu_draw(struct menu_ctx *mc, struct me
                    (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->geom.h += sc->xftfont->ascent + sc->xftfont->descent;
                mc->num++;
        }
 
@@ -403,15 +403,15 @@ menu_draw(struct menu_ctx *mc, struct me
            (const FcChar8*)mc->dispstr, strlen(mc->dispstr));
 
        TAILQ_FOREACH(mi, resultq, resultentry) {
-               int y = n * (sc->xftfont->height + 1) + sc->xftfont->ascent + 1;
+               int y = n * (sc->xftfont->ascent + sc->xftfont->descent);
 
                /* Stop drawing when menu doesn't fit inside the screen. */
-               if (mc->geom.y + y > area.h)
+               if (mc->geom.y + y >= area.h)
                        break;
 
                XftDrawStringUtf8(mc->xftdraw,
                    &sc->xftcolor[CWM_COLOR_MENU_FONT], sc->xftfont,
-                   0, y,
+                   0, y + sc->xftfont->ascent,
                    (const FcChar8*)mi->print, strlen(mi->print));
                n++;
        }
@@ -425,7 +425,7 @@ menu_draw_entry(struct menu_ctx *mc, str
 {
        struct screen_ctx       *sc = mc->sc;
        struct menu             *mi;
-       int                      color, i = 1;
+       int                      color, i = 1, y;
 
        TAILQ_FOREACH(mi, resultq, resultentry)
                if (entry == i++)
@@ -433,14 +433,13 @@ menu_draw_entry(struct menu_ctx *mc, str
        if (mi == NULL)
                return;
 
+       y = entry * (sc->xftfont->ascent + sc->xftfont->descent);
        color = (active) ? CWM_COLOR_MENU_FG : CWM_COLOR_MENU_BG;
-       XftDrawRect(mc->xftdraw, &sc->xftcolor[color], 0,
-           (sc->xftfont->height + 1) * entry, mc->geom.w,
-           (sc->xftfont->height + 1) + sc->xftfont->descent);
+       XftDrawRect(mc->xftdraw, &sc->xftcolor[color], 0, y,
+           mc->geom.w, sc->xftfont->ascent + sc->xftfont->descent);
        color = (active) ? CWM_COLOR_MENU_FONT_SEL : CWM_COLOR_MENU_FONT;
        XftDrawStringUtf8(mc->xftdraw,
-           &sc->xftcolor[color], sc->xftfont,
-           0, (sc->xftfont->height + 1) * entry + sc->xftfont->ascent + 1,
+           &sc->xftcolor[color], sc->xftfont, 0, y + sc->xftfont->ascent,
            (const FcChar8*)mi->print, strlen(mi->print));
 }
 
@@ -487,11 +486,11 @@ menu_calc_entry(struct menu_ctx *mc, int
        struct screen_ctx       *sc = mc->sc;
        int                      entry;
 
-       entry = y / (sc->xftfont->height + 1);
+       entry = y / (sc->xftfont->ascent + sc->xftfont->descent);
 
        /* in bounds? */
        if (x < 0 || x > mc->geom.w || y < 0 ||
-           y > (sc->xftfont->height + 1) * mc->num ||
+           y > (sc->xftfont->ascent + sc->xftfont->descent) * mc->num ||
            entry < 0 || entry >= mc->num)
                entry = -1;
 

Reply via email to