On Thu 2022.10.13 at 17:30 +0200, Omar Polo wrote: > On 2022/10/13 15:16:47 +0000, Klemens Nanni <k...@openbsd.org> wrote: > > On Thu, Oct 13, 2022 at 04:39:04PM +0200, Omar Polo wrote: > > > On 2022/10/13 13:00:34 +0000, Klemens Nanni <k...@openbsd.org> wrote: > > > > On Thu, Oct 13, 2022 at 08:28:50AM -0400, Okan Demirmen wrote: > > > > > And I keep missing it! I can't reproduce this - can you share the font > > > > > you're using maybe? > > > > > > > > Whatever is the default, I never fiddled with fonts in X, no xorg.conf, > > > > `cwm -c/dev/null' shows the glitch for me on a ThinkPad X230. > > > > > > i can't reproduce it either, not with my normal cwmrc and nor with an > > > empty one. However with your patch the selected menu entry seems to > > > be... correctly sized? Without your patch the selected item seems to > > > be slightly more tall and "touch" the numbers and the parens of the > > > items below. > > > > That as well, at leat to my eye. > > > > Here are four screen shots from my X230 running `cwm -c /dev/null' > > inside Xephyr, taken with `scrot -s -q 100' so I can select the area > > without clicking into the window which would make cwm's menu disappear. > > > > "current-" and "patch-" mean cwm from current and with the +1 patch, > > respectively. > > > > "top-bottom" and "bottom-top" mean that the cursor has been moved across > > the menu top to bottom and bottom to top, respectively. > > > > current-bottom-top.png shows cropped "[]" chars in the second entry, > > whereas current-top-bottom.png and patch-*.png do not. > > Ahhh, now i see that too. it's subtle but your screenshot clearly > shows that the selected items hides the top row of fixes from the item > belows it. I've never noticed it before 'cause the selected items > here has a black background (due to my ~/.Xdefaults.), but it happens > for me too. Actually, i get what it looks like a "pixel perfect" > result by subtracting two instead of one from descent in menu.c, but i > was just playing with it -- need to re-read that part more closely.
okay, i see it now! **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. 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;