From 2ab8fb83ba7d210c7c377b5b417f79822a6f7724 Mon Sep 17 00:00:00 2001 From: nia Date: Wed, 14 Jul 2021 20:17:13 +0200 Subject: [PATCH] netbsd: Support curses libraries without ncurses mouse support This adds a configure check for the ncurses getmouse() function and disables mouse-related code paths when mouse support is not present in the curses library. This is necessary for stable versions of NetBSD's libcurses, the development version has stub mouse functions for compatibility with ncurses. Signed-off-by: Nia Alarie --- CRT.c | 4 ++++ InfoScreen.c | 2 ++ ScreenManager.c | 2 ++ configure.ac | 1 + 4 files changed, 9 insertions(+) diff --git a/CRT.c b/CRT.c index 16cfd63a..4bd409c1 100644 --- a/CRT.c +++ b/CRT.c @@ -836,7 +836,9 @@ void CRT_init(const Settings* settings, bool allowUnicode) { nonl(); intrflush(stdscr, false); keypad(stdscr, true); +#ifdef HAVE_GETMOUSE mouseinterval(0); +#endif curs_set(0); if (has_colors()) { @@ -910,10 +912,12 @@ void CRT_init(const Settings* settings, bool allowUnicode) { #endif CRT_treeStrAscii; +#ifdef HAVE_GETMOUSE #if NCURSES_MOUSE_VERSION > 1 mousemask(BUTTON1_RELEASED | BUTTON4_PRESSED | BUTTON5_PRESSED, NULL); #else mousemask(BUTTON1_RELEASED, NULL); +#endif #endif CRT_degreeSign = initDegreeSign(); diff --git a/InfoScreen.c b/InfoScreen.c index 259ecee3..a62b7c0d 100644 --- a/InfoScreen.c +++ b/InfoScreen.c @@ -106,6 +106,7 @@ void InfoScreen_run(InfoScreen* this) { } } +#ifdef HAVE_GETMOUSE if (ch == KEY_MOUSE) { MEVENT mevent; int ok = getmouse(&mevent); @@ -127,6 +128,7 @@ void InfoScreen_run(InfoScreen* this) { #endif } } +#endif if (this->inc->active) { IncSet_handleKey(this->inc, ch, panel, IncSet_getListItemValue, this->lines); diff --git a/ScreenManager.c b/ScreenManager.c index 8ec60119..c50d1c4a 100644 --- a/ScreenManager.c +++ b/ScreenManager.c @@ -172,6 +172,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { ch = getch(); HandlerResult result = IGNORED; +#ifdef HAVE_GETMOUSE if (ch == KEY_MOUSE && this->settings->enableMouse) { ch = ERR; MEVENT mevent; @@ -212,6 +213,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { } } } +#endif if (ch == ERR) { if (sortTimeout > 0) sortTimeout--; diff --git a/configure.ac b/configure.ac index bb92816f..be40187a 100644 --- a/configure.ac +++ b/configure.ac @@ -352,6 +352,7 @@ if test "$my_htop_platform" = "solaris"; then AC_DEFINE([ERR], [(-1)], [Predefine ncurses macro.]) fi AC_CHECK_FUNCS( [set_escdelay] ) +AC_CHECK_FUNCS( [getmouse] ) AC_ARG_ENABLE([hwloc],