From d22667725a980e75a3c635567ec5c9400bcde02b Mon Sep 17 00:00:00 2001 From: WHR Date: Tue, 17 May 2022 12:53:15 +0800 Subject: [PATCH] Call mousemask(3X) to truly enable or disable mouse control --- Action.c | 1 + CRT.c | 22 +++++++++++++++------- CRT.h | 2 ++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Action.c b/Action.c index 99c0fe0b..27a9ef5d 100644 --- a/Action.c +++ b/Action.c @@ -88,6 +88,7 @@ static void Action_runSetup(State* st) { ScreenManager_run(scr, NULL, NULL, "Setup"); ScreenManager_delete(scr); if (st->settings->changed) { + CRT_setMouse(st->settings->enableMouse); Header_writeBackToSettings(st->header); } } diff --git a/CRT.c b/CRT.c index 583b6266..868f2377 100644 --- a/CRT.c +++ b/CRT.c @@ -900,6 +900,20 @@ void CRT_resetSignalHandlers(void) { signal(SIGQUIT, SIG_DFL); } +void CRT_setMouse(bool enabled) { +#ifdef HAVE_GETMOUSE + if (enabled) { +#if NCURSES_MOUSE_VERSION > 1 + mousemask(BUTTON1_RELEASED | BUTTON4_PRESSED | BUTTON5_PRESSED, NULL); +#else + mousemask(BUTTON1_RELEASED, NULL); +#endif + } else { + mousemask(0, NULL); + } +#endif +} + void CRT_init(const Settings* settings, bool allowUnicode) { redirectStderr(); @@ -993,13 +1007,7 @@ IGNORE_WCASTQUAL_END #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_setMouse(settings->enableMouse); CRT_degreeSign = initDegreeSign(); } diff --git a/CRT.h b/CRT.h index eae4722d..297e8964 100644 --- a/CRT.h +++ b/CRT.h @@ -185,6 +185,8 @@ extern int CRT_scrollWheelVAmount; extern ColorScheme CRT_colorScheme; +void CRT_setMouse(bool enabled); + void CRT_init(const Settings* settings, bool allowUnicode); void CRT_done(void);