Commit 1acb708b authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

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.
parent 96b1449f
Pipeline #23566690 passed with stages
in 14 minutes 6 seconds
......@@ -76,6 +76,7 @@ static size_t UngetCount = 0;
static size_t UngetLen = 0;
static event_t *UngetKeyEvents;
int MuttGetchTimeout = -1;
mutt_window_t *MuttHelpWindow = NULL;
mutt_window_t *MuttIndexWindow = NULL;
......@@ -121,10 +122,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
......@@ -136,7 +135,7 @@ static int mutt_monitor_getch (void)
* we need to make sure there isn't a character waiting */
timeout (0);
ch = getch ();
timeout (mutt_monitor_get_poll_timeout ());
timeout (MuttGetchTimeout);
if (ch == ERR)
{
if (mutt_monitor_poll () != 0)
......
......@@ -30,6 +30,7 @@
#include "buffy.h"
#include "monitor.h"
#include "mx.h"
#include "mutt_curses.h"
#include <errno.h>
#include <sys/stat.h>
......@@ -50,7 +51,6 @@ static MONITOR *Monitor = NULL;
static size_t PollFdsCount = 0;
static size_t PollFdsLen = 0;
static struct pollfd *PollFds;
static int PollTimeout = -1;
typedef struct monitorinfo_t
{
......@@ -203,16 +203,6 @@ static int monitor_handle_ignore (int descr)
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.
......@@ -237,7 +227,7 @@ int mutt_monitor_poll (void)
if (INotifyFd != -1)
{
fds = poll (PollFds, PollFdsLen, PollTimeout);
fds = poll (PollFds, PollFdsLen, MuttGetchTimeout);
if (fds == -1)
{
......
......@@ -25,8 +25,6 @@ WHERE int MonitorFilesChanged INITVAL (0);
int mutt_monitor_add (BUFFY *b);
int mutt_monitor_remove (BUFFY *b);
#endif
void mutt_monitor_set_poll_timeout (int timeout);
int mutt_monitor_get_poll_timeout (void);
int mutt_monitor_poll (void);
#endif /* MONITOR_H */
......@@ -86,6 +86,8 @@ void mutt_curs_set (int);
#define CI_is_return(c) ((c) == '\r' || (c) == '\n')
#endif
extern int MuttGetchTimeout;
event_t mutt_getch (void);
void mutt_getch_timeout (int);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment