Call mousemask(3X) to truly enable or disable mouse control

This commit is contained in:
WHR 2022-05-17 12:53:15 +08:00 committed by BenBE
parent ef4cbae5ea
commit d22667725a
3 changed files with 18 additions and 7 deletions

View File

@ -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);
}
}

22
CRT.c
View File

@ -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();
}

2
CRT.h
View File

@ -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);