> A workaroud is to have a thread call getch() in blocking mode and then serve the result on a pipe whose other end goes in the select. But this solution seems awkward to me, especially considering that STDIN_FILENO is instead always available to the application, and compared with having a function like getmousefd() that returns _mouse_fd.
> This function would be similar to ConnectionNumber(Display *) in XWindow: it returns a file descriptor to be used in a select, so that the application may then call XNextEvent() or similar if something can be read there. I believe it is not supposed to be used in any other way.
--- ncurses-6.1/include/curses.tail 2016-02-13 17:37:45.000000000 +0100
+++ ncurses-6.1-withmousefd/include/curses.tail 2019-06-26 10:57:05.755049847 +0200
@@ -95,6 +95,7 @@
MEVENT;
extern NCURSES_EXPORT(bool) has_mouse(void);
+extern NCURSES_EXPORT(int) getmousefd(void);
extern NCURSES_EXPORT(int) getmouse (MEVENT *);
extern NCURSES_EXPORT(int) ungetmouse (MEVENT *);
extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *);
@@ -105,6 +106,7 @@
#if NCURSES_SP_FUNCS
extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_mouse) (SCREEN*);
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(getmousefd) (SCREEN*);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *);
extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, mmask_t *);
--- ncurses-6.1/ncurses/base/lib_mouse.c 2017-11-18 23:12:06.000000000 +0100
+++ ncurses-6.1-withmousefd/ncurses/base/lib_mouse.c 2019-06-26 10:56:53.138048893 +0200
@@ -2005,3 +2005,17 @@
}
returnBool(result);
}
+
+NCURSES_EXPORT(int)
+_nc_getmousefd(SCREEN *scr) {
+ return scr->_mouse_fd;
+}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+getmousefd(void)
+{
+ return _nc_getmousefd(CURRENT_SCREEN);
+}
+#endif
+