On 2024-01-01 05:14 +0100, наб wrote: > Package: libncursesw6 > Version: 6.4+20231121-1 > Severity: normal > > Dear Maintainer, > > I am attaching a repro.c program that when built with > cc -O3 -g -Wall -Wextra -DNCURSES_WIDECHAR -D_GNU_SOURCE repro.c > -lncursesw -ltinfo -o repro
You might just as well have said that you are hacking on the urlview package… > presents a UI in the form of > first line > -> L1 > L2 > L3 > L4 > L5 > last line > > Mousing is enabled, and if you click on a line the cursor on the left > moves to select it. > > The first line and last line are on stdscr, the rest of the screen is > urlswin = newpad(LINES, COLS), rendered via > pnoutrefresh(urlswin, /**/ url[first_on_page].cursor_y + fudge, 0, /**/ 1 > /*title line*/, 0, LINES - 2, COLS); > > On KEY_MOUSE and BUTTON1_CLICKED: > getmouse(&ev); > if(!wmouse_trafo(urlswin, &ev.y, &ev.x, false)) > break; > and the line targeted is found and selected. > > Clicking on first line correctly hits the break. > Clicking on last line incorrectly continues on. > > This shows as scrolling to the next screen > (since the line selected is L6, which would be under last line). > > This /only happens/ if the lines go all the way to the line above last. > If you click on any line below a non-full screen (s/1000/10/ or scroll down), > nothing happens. > Is this a weird thing with the edge of the screen? > Or with how pnoutrefresh accounts for the undrawn parts of the pad? Neither. It's that the urlswin pad is larger than what fits on the screen, and the wmouse_trafo() function is not designed to work with that. If you look at its source[1], you can see that it calls wenclose() to decide if the mouse event happened inside the window, and the latter simply looks at the window coordinates[2]. If you insist on using a pad larger than the screen size, you will have to work around that limitation somehow, I am afraid. For instance, after calling getmouse(&ev), check if ev.y is in the area that you allocated on the screen for the visible parts of urlswin. Cheers, Sven 1. https://sources.debian.org/src/ncurses/6.4%2B20240113-1/ncurses/base/lib_mouse.c/#L2051 2. https://sources.debian.org/src/ncurses/6.4%2B20240113-1/ncurses/base/lib_mouse.c/#L1993