On Mon, Feb 09, 2026 at 03:24:02PM +0100, Vincent Lefevre wrote:
> With ncurses 6.6, mouseinterval(0) causes getmouse errors in Termux,
> as shown by the following example:
>
> #include <curses.h>
> #include <stdio.h>
>
> int main()
> {
> initscr();
> cbreak();
> noecho();
>
> // Enables keypad mode. This makes (at least for me) mouse events getting
> // reported as KEY_MOUSE, instead as of random letters.
> keypad(stdscr, TRUE);
>
> // See https://github.com/termux/termux-packages/issues/28372
I took a quick look with disabling the release-button responses in xterm,
but saw no difference in behavior using the (correctly-written) ncurses
test program for ncurses 6.5 vs 6.5
I'll correct this example and see if there's some more insight to be had :-)
> mouseinterval(0);
>
> // Don't mask any mouse events
> mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
>
> printf("\033[?1003h\n"); // Makes the terminal report mouse movement events
There's no fflush here, so the program behavior is indeterminate.
For instance, this bug could account for the behavior you're reporting.
> for (;;) {
> int c = wgetch(stdscr);
>
> // Exit the program on new line fed
> if (c == '\n')
> break;
>
> char buffer[512];
> size_t max_size = sizeof(buffer);
> if (c == ERR) {
> snprintf(buffer, max_size, "Nothing happened.");
> }
> else if (c == KEY_MOUSE) {
> MEVENT event;
> if (getmouse(&event) == OK) {
> snprintf(buffer, max_size, "Mouse at row=%d, column=%d
> bstate=0x%08lx",
> event.y, event.x, (unsigned long) event.bstate);
> }
> else {
> snprintf(buffer, max_size, "Got bad mouse event.");
> }
> }
> else {
> snprintf(buffer, max_size, "Pressed key %d (%s)", c, keyname(c));
> }
>
> move(0, 0);
> insertln();
> addstr(buffer);
> clrtoeol();
> move(0, 0);
> }
>
> printf("\033[?1003l\n"); // Disable mouse movement events, as l = low
same bug here.
> endwin();
>
> return 0;
> }
>
> This is the program from
>
> https://gist.github.com/sylt/93d3f7b77e7f3a881603
>
> where "mouseinterval(0);" has been added as instructed at
>
> https://github.com/termux/termux-packages/issues/28372
>
> To reproduce the error, run this program directly in the Termux
> terminal (no ssh), and tap (click) several times on the screen.
> In my case, a "Got bad mouse event." message appears at the 7th
> time (periodically). Note: make sure that they correspond to
> clicks, i.e. do not generate mouse movements (the problem still
> seems to be reproducible if there are mouse movements between
> the clicks, though).
>
> In the above termux-packages issue, Robert Kirkman bisected it to
>
>
> https://github.com/ThomasDickey/ncurses-snapshots/commit/04b97b07ab93bac2ba9ab92a2c3776ddae75bfaa#r169954711
>
> There is a mention of a problem in htop
>
> https://github.com/htop-dev/htop/issues/1769
>
> due to this commit, but I cannot reproduce it, even though I get
> "Got bad mouse event." messages with the above test program.
>
> --
> Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
> Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)
>
>
--
Thomas E. Dickey <[email protected]>
https://invisible-island.net
signature.asc
Description: PGP signature
