0
  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?

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
Darren Ng
  • 373
  • 5
  • 12
  • 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). – Thomas Dickey Jun 13 '20 at 08:20
  • It's a prebuilt distro package, and [here](https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/ncurses#n22) is how they built it. – Darren Ng Jun 13 '20 at 11:20
  • The package script doesn't mention gpm, and the [configure script](https://github.com/ThomasDickey/ncurses-snapshots/blob/300538725582f4f9adaa5852f2342666be0dc3f6/INSTALL#L949) doesn't turn that on by default. If the gpm development files happened to be available, it might have been in the package. – Thomas Dickey Jun 13 '20 at 12:32

1 Answers1

2

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.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • midnight commander seems to be using libgpm directly [key.c](https://repo.or.cz/midnight-commander.git/blob/HEAD:/lib/tty/key.c) [mouse.c](https://repo.or.cz/midnight-commander.git/blob/HEAD:/lib/tty/mouse.c) – Darren Ng Jun 13 '20 at 13:29
  • I'm aware of that, but it's going astray from the question :-) By the way, if the question's answered, you might *accept* it. – Thomas Dickey Jun 13 '20 at 13:54