Re: cwm: do not overlap menu entries
On 2022/10/14 14:11:19 -0400, Okan Demirmen wrote: > the below seems to work: Walter (thanks!) found the spot i missed on > replacing height with ascent+descent. > > please let me know. diff reads fine works for me too, thanks!
Re: cwm: do not overlap menu entries
On Fri, Oct 14, 2022 at 02:11:19PM -0400, Okan Demirmen wrote: > the below seems to work: Walter (thanks!) found the spot i missed on > replacing height with ascent+descent. > > please let me know. Works just fine for me, no more visual glitches, thanks!
Re: cwm: do not overlap menu entries
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 - 1.109 +++ menu.c 14 Oct 2022 18:03:39 - @@ -355,7 +355,7 @@ menu_draw(struct menu_ctx *mc, struct me XftTextExtentsUtf8(X_Dpy, sc->xftfont, (const FcChar8*)mc->dispstr, strlen(mc->dispstr), ); 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), ); 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, >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, >xftcolor[color], 0, - (sc->xftfont->height + 1) * entry, mc->geom.w, - (sc->xftfont->height + 1) + sc->xftfont->descent); + XftDrawRect(mc->xftdraw, >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, - >xftcolor[color], sc->xftfont, - 0, (sc->xftfont->height + 1) * entry + sc->xftfont->ascent + 1, + >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;
Re: cwm: do not overlap menu entries
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.c27 Feb 2020 14:56:39 - 1.109 > +++ menu.c14 Oct 2022 01:40:30 - > @@ -355,7 +355,7 @@ menu_draw(struct menu_ctx *mc, struct me > XftTextExtentsUtf8(X_Dpy, sc->xftfont, > (const FcChar8*)mc->dispstr, strlen(mc->dispstr), ); > 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), ); > 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, >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, > >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; > > >
Re: cwm: do not overlap menu entries
On Thu 2022.10.13 at 17:30 +0200, Omar Polo wrote: > On 2022/10/13 15:16:47 +, Klemens Nanni wrote: > > On Thu, Oct 13, 2022 at 04:39:04PM +0200, Omar Polo wrote: > > > On 2022/10/13 13:00:34 +, Klemens Nanni 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 - 1.109 +++ menu.c 14 Oct 2022 01:40:30 - @@ -355,7 +355,7 @@ menu_draw(struct menu_ctx *mc, struct me XftTextExtentsUtf8(X_Dpy, sc->xftfont, (const FcChar8*)mc->dispstr, strlen(mc->dispstr), ); 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), ); 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, >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, >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 /
Re: cwm: do not overlap menu entries
On Oct 13 2022, Walter Alejandro Iglesias wrote: > On Oct 13 2022, Klemens Nanni 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. > > > > > > In my case I can reproduce it with TrueType fonts (eg DejaVu Monospace), Not with all truetype fonts and sizes. It depends on how each font distributes vertical space (especially below). Here some fonts and sizes I can reproduce the issue: DejaVu Monospace 15 or 18 FreeMono 15 or 18 Liberation Mono all sizes Liberation Mono is the most affected because is the less vertically centered. -- Walter
Re: cwm: do not overlap menu entries
On Oct 13 2022, Klemens Nanni 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. > > In my case I can reproduce it with TrueType fonts (eg DejaVu Monospace), with bitmap fonts (eg Fixed) doesn't happen. I observe the overlapping in any menu, not only the windows one. Months ago I tried to fix this issue playing with the "height + 1" values, but since all cwm patches I been sending lately were ignored I lost interest. By the way, I'm glad Okan is still alive. :-) -- Walter
Re: cwm: do not overlap menu entries
On 2022/10/13 15:16:47 +, Klemens Nanni wrote: > On Thu, Oct 13, 2022 at 04:39:04PM +0200, Omar Polo wrote: > > On 2022/10/13 13:00:34 +, Klemens Nanni 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.
Re: cwm: do not overlap menu entries
On Thu, Oct 13, 2022 at 04:39:04PM +0200, Omar Polo wrote: > On 2022/10/13 13:00:34 +, Klemens Nanni 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. current-bottom-top.png Description: Binary data current-top-bottom.png Description: Binary data patch-bottom-top.png Description: Binary data patch-top-bottom.png Description: Binary data
Re: cwm: do not overlap menu entries
On 2022/10/13 13:00:34 +, Klemens Nanni 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.
Re: cwm: do not overlap menu entries
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.
Re: cwm: do not overlap menu entries
On Wed 2022.10.12 at 21:42 +, Klemens Nanni wrote: > This has annoyed me for a long time... > > 1. have at least two windows > 2. open the window menu with M-slash (alt+/) > 3. show all windows with C-A (ctrl+a) > 4. move cursor over list from top to bottom, >observe no glitch > 5. move cursor over list from bottom to top, >observe "[" and "]" chars in entries being drawn over at the top, >i.e. upper entries overlap lower ones > > It's easy to miss but hard to unsee. And I keep missing it! I can't reproduce this - can you share the font you're using maybe? > Today I looked and came up with the following fix, drawing menu entries > without overlap. > > All these `height + 1' spread across seem off, but they seem consistent. > > Okan, is there a better way to fix this? > > > This is trivial to reproduce wihout messing with your running X: > > $ Xephyr :1 & > $ xterm -display 1 & > $ xterm -display 1 & > $ DISPLAY=:1 ./obj/cwm > > Then click on the background/root window to navigate the window menu. > > > Index: app/cwm/menu.c > === > RCS file: /cvs/xenocara/app/cwm/menu.c,v > retrieving revision 1.109 > diff -u -p -r1.109 menu.c > --- app/cwm/menu.c27 Feb 2020 14:56:39 - 1.109 > +++ app/cwm/menu.c12 Oct 2022 21:24:17 - > @@ -436,7 +436,7 @@ menu_draw_entry(struct menu_ctx *mc, str > color = (active) ? CWM_COLOR_MENU_FG : CWM_COLOR_MENU_BG; > XftDrawRect(mc->xftdraw, >xftcolor[color], 0, > (sc->xftfont->height + 1) * entry, mc->geom.w, > - (sc->xftfont->height + 1) + sc->xftfont->descent); > + (sc->xftfont->height + 1) + sc->xftfont->descent - 1); > color = (active) ? CWM_COLOR_MENU_FONT_SEL : CWM_COLOR_MENU_FONT; > XftDrawStringUtf8(mc->xftdraw, > >xftcolor[color], sc->xftfont,
cwm: do not overlap menu entries
This has annoyed me for a long time... 1. have at least two windows 2. open the window menu with M-slash (alt+/) 3. show all windows with C-A (ctrl+a) 4. move cursor over list from top to bottom, observe no glitch 5. move cursor over list from bottom to top, observe "[" and "]" chars in entries being drawn over at the top, i.e. upper entries overlap lower ones It's easy to miss but hard to unsee. Today I looked and came up with the following fix, drawing menu entries without overlap. All these `height + 1' spread across seem off, but they seem consistent. Okan, is there a better way to fix this? This is trivial to reproduce wihout messing with your running X: $ Xephyr :1 & $ xterm -display 1 & $ xterm -display 1 & $ DISPLAY=:1 ./obj/cwm Then click on the background/root window to navigate the window menu. Index: app/cwm/menu.c === RCS file: /cvs/xenocara/app/cwm/menu.c,v retrieving revision 1.109 diff -u -p -r1.109 menu.c --- app/cwm/menu.c 27 Feb 2020 14:56:39 - 1.109 +++ app/cwm/menu.c 12 Oct 2022 21:24:17 - @@ -436,7 +436,7 @@ menu_draw_entry(struct menu_ctx *mc, str color = (active) ? CWM_COLOR_MENU_FG : CWM_COLOR_MENU_BG; XftDrawRect(mc->xftdraw, >xftcolor[color], 0, (sc->xftfont->height + 1) * entry, mc->geom.w, - (sc->xftfont->height + 1) + sc->xftfont->descent); + (sc->xftfont->height + 1) + sc->xftfont->descent - 1); color = (active) ? CWM_COLOR_MENU_FONT_SEL : CWM_COLOR_MENU_FONT; XftDrawStringUtf8(mc->xftdraw, >xftcolor[color], sc->xftfont,