Hello Okan,

On Oct 13 2022, Okan Demirmen wrote:
> **incomplete** but i think the right direction to use ascent+descent,
> however i've missed something, so take this with a sea full of salt (and
> yes, i'm still alive...). the menu rect is too big (by a factor of
> entries i think) now and messes with other calculations dealing with ptr
> selections/movement; i just need find the other assumptions made with this
> + 1 stuff and if i used the right surgical hammer.

I just tried your patch and the issue disappeared.

Thank you!


> 
> 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 01:40:30 -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,7 +403,7 @@ 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->height + sc->xftfont->ascent;
>  
>               /* Stop drawing when menu doesn't fit inside the screen. */
>               if (mc->geom.y + y > area.h)
> @@ -435,12 +435,12 @@ menu_draw_entry(struct menu_ctx *mc, str
>  
>       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);
> +         sc->xftfont->height * entry, 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,
> +         0, sc->xftfont->height * entry + sc->xftfont->ascent,
>           (const FcChar8*)mi->print, strlen(mi->print));
>  }
>  
> @@ -487,11 +487,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