]> granicus.if.org Git - neomutt/commitdiff
Move mutt_getch() timeout value into curs_lib.c
authorKevin McCarthy <kevin@8t8.us>
Sun, 10 Jun 2018 00:51:30 +0000 (08:51 +0800)
committerRichard Russon <rich@flatcap.org>
Mon, 3 Sep 2018 01:04:32 +0000 (02:04 +0100)
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.

curs_lib.c
curs_lib.h
monitor.c
monitor.h

index f1c0943e748111b619f3a55580d28548649ec885..feccbf22e9ac19720b920fba32225c9f874f7d18 100644 (file)
@@ -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)
index 6a926f85f5ce66caf9860bd6610fc4cfc349b890..0924629d2560509dde92e9df9d2dd666757180e4 100644 (file)
@@ -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
index 2e9d3c67b3651b895f2e5057659f0fbe48409e5d..48b5c7960946c951d49bbdc89562c00ff876da64 100644 (file)
--- 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)
     {
index 4d76ca001fe5d3ca4e97195fd4dc247844e693a4..1159abe07badc9766b9fa7e9037ad7d81687ec1c 100644 (file)
--- 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 */