initscr();
cbreak();
noecho();
assert(OK==keypad(stdscr,TRUE));
mousemask(BUTTON1_PRESSED|BUTTON1_RELEASED,NULL));
assert(has_mouse());
assert(166==mouseinterval(1));
refresh();
for(;;){
int ch=wgetch(stdscr);
// Detect mouse event and print coordinates
}
endwin();
In terminal emulator (alacritty), mouse coordinates are reported normally after a click of the left button. However, if I systemctl start gpm
then run it in tty(vt), there is no response at all wherever mouse is clicked.
How can I make it work in tty(vt) as well?
ncurses has to be configured (compile-time) to work with gpm. If you compiled it yourself, that may not be configured. If you are commenting on a prebuilt package, your question should include relevant information (system and package version).
A comment points to Arch Linux's package, which does not explicitly turn on gpm. The gpm feature is not enabled by default (hint: the INSTALL
file shows the feature as --with-gpm
), and lacking other clues, is unlikely to be part of the package, unless the development package for gpm happened to be installed on the build-server.
A further comment mentions midnight commander. Whether or not it actually uses ncurses midnight commander has not used ncurses' mouse support for quite a while. Some of that is discussed in comments on ncurses versus slang (S-Lang)
You could make this work (ncurses+gpm) either by compiling the package yourself (using --with-gpm
, taking care to have the development headers and libraries installed), or possibly a bug report to Arch might get that changed.