From: Kevin McCarthy Date: Sun, 10 Jun 2018 00:51:30 +0000 (+0800) Subject: Move mutt_getch() timeout value into curs_lib.c X-Git-Tag: 2019-10-25~668^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f22354e0626d1af901e2c6a21bd79603e3e404c7;p=neomutt Move mutt_getch() timeout value into curs_lib.c Change monitor.c to reference the curs_lib value, instead of vice-versa. We need to store the value for both monitor.c's poll and for mutt_monitor_ch() to perform an initial non-blocking check of ncurses' getch() buffer. --- diff --git a/curs_lib.c b/curs_lib.c index f1c0943e7..feccbf22e 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -87,6 +87,8 @@ static size_t UngetCount = 0; static size_t UngetLen = 0; static struct Event *UngetKeyEvents; +int MuttGetchTimeout = -1; + /** * mutt_refresh - Force a refresh of the screen */ @@ -126,10 +128,8 @@ void mutt_need_hard_redraw(void) */ void mutt_getch_timeout(int delay) { + MuttGetchTimeout = delay; timeout(delay); -#ifdef USE_INOTIFY - mutt_monitor_set_poll_timeout(delay); -#endif } #ifdef USE_INOTIFY @@ -139,7 +139,7 @@ static int mutt_monitor_getch(void) * we need to make sure there isn't a character waiting */ timeout(0); int ch = getch(); - timeout(mutt_monitor_get_poll_timeout()); + timeout(MuttGetchTimeout); if (ch == ERR) { if (mutt_monitor_poll() != 0) diff --git a/curs_lib.h b/curs_lib.h index 6a926f85f..0924629d2 100644 --- a/curs_lib.h +++ b/curs_lib.h @@ -35,6 +35,8 @@ struct Pager; /* These Config Variables are only used in curs_lib.c */ extern bool MetaKey; /**< interpret ALT-x as ESC-x */ +extern int MuttGetchTimeout; + /* For mutt_simple_format() justifications */ #define FMT_LEFT -1 #define FMT_CENTER 0 diff --git a/monitor.c b/monitor.c index 2e9d3c67b..48b5c7960 100644 --- a/monitor.c +++ b/monitor.c @@ -34,6 +34,7 @@ #include "mutt/mutt.h" #include "monitor.h" #include "context.h" +#include "curs_lib.h" #include "globals.h" #include "mailbox.h" #include "mutt_curses.h" @@ -56,7 +57,6 @@ static struct Monitor *Monitor = NULL; static size_t PollFdsCount = 0; static size_t PollFdsLen = 0; static struct pollfd *PollFds; -static int PollTimeout = -1; struct MonitorInfo { @@ -214,16 +214,6 @@ static int monitor_handle_ignore(int desc) return new_descr; } -void mutt_monitor_set_poll_timeout(int timeout) -{ - PollTimeout = timeout; -} - -int mutt_monitor_get_poll_timeout(void) -{ - return PollTimeout; -} - #define EVENT_BUFLEN MAX(4096, sizeof(struct inotify_event) + NAME_MAX + 1) /* mutt_monitor_poll: Waits for I/O ready file descriptors or signals. @@ -247,7 +237,7 @@ int mutt_monitor_poll(void) if (INotifyFd != -1) { - fds = poll(PollFds, PollFdsLen, PollTimeout); + fds = poll(PollFds, PollFdsLen, MuttGetchTimeout); if (fds == -1) { diff --git a/monitor.h b/monitor.h index 4d76ca001..1159abe07 100644 --- a/monitor.h +++ b/monitor.h @@ -29,8 +29,6 @@ struct Mailbox; int mutt_monitor_add(struct Mailbox *b); int mutt_monitor_remove(struct Mailbox *b); -void mutt_monitor_set_poll_timeout(int timeout); -int mutt_monitor_get_poll_timeout(void); int mutt_monitor_poll(void); #endif /* _MUTT_MONITOR_H */