#endif
}
+#ifdef USE_INOTIFY
+static int mutt_monitor_getch(void)
+{
+ /* ncurses has its own internal buffer, so before we perform a poll,
+ * we need to make sure there isn't a character waiting */
+ timeout(0);
+ int ch = getch();
+ timeout(mutt_monitor_get_poll_timeout());
+ if (ch == ERR)
+ {
+ if (mutt_monitor_poll() != 0)
+ ch = ERR;
+ else
+ ch = getch();
+ }
+ return ch;
+}
+#endif /* USE_INOTIFY */
+
/**
* mutt_getch - Read a character from the input buffer
* @retval obj Event to process
while (ch == KEY_RESIZE)
#endif /* KEY_RESIZE */
#ifdef USE_INOTIFY
- if (mutt_monitor_poll() != 0)
- ch = ERR;
- else
-#endif
- ch = getch();
+ ch = mutt_monitor_getch();
+#else
+ ch = getch();
+#endif /* USE_INOTIFY */
mutt_sig_allow_interrupt(0);
if (SigInt)
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.
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 */