summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-03-10 14:38:37 +0000
committerRichard M. Stallman <rms@gnu.org>1996-03-10 14:38:37 +0000
commit2b6466867394b60cb2e5f583ac1453c6e7b17c6d (patch)
tree79ec9a18e38c6ee4fb84ee94f09e2a4ca22ebc45
parentfe588c5132524316ae1a0914324708d9d7e34259 (diff)
downloademacs-2b6466867394b60cb2e5f583ac1453c6e7b17c6d.tar.gz
[!subprocesses] (wait_reading_process_input):
Port the timer changes from the other wait_reading_process_input.
-rw-r--r--src/process.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/src/process.c b/src/process.c
index 1ff26c83259..9d4e3aa2db6 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3853,6 +3853,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
for (;;)
{
int nfds;
+ int timeout_reduced_for_timers = 0;
if (XINT (read_kbd))
FD_SET (0, &waitchannels);
@@ -3865,6 +3866,8 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
if (XINT (read_kbd) >= 0)
QUIT;
+ /* Compute time from now till when time limit is up */
+ /* Exit if already run out */
if (timeout_p)
{
EMACS_GET_TIME (*timeout_p);
@@ -3873,6 +3876,29 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
break;
}
+ /* If our caller will not immediately handle keyboard events,
+ run timer events directly.
+ (Callers that will immediately read keyboard events
+ call timer_delay on their own.) */
+ if (read_kbd >= 0)
+ {
+ EMACS_TIME timer_delay;
+ int old_timers_run = timers_run;
+ timer_delay = timer_check (1);
+ if (timers_run != old_timers_run && do_display)
+ redisplay_preserve_echo_area ();
+ if (! EMACS_TIME_NEG_P (timer_delay) && timeout_p)
+ {
+ EMACS_TIME difference;
+ EMACS_SUB_TIME (difference, timer_delay, *timeout_p);
+ if (EMACS_TIME_NEG_P (difference))
+ {
+ *timeout_p = timer_delay;
+ timeout_reduced_for_timers = 1;
+ }
+ }
+ }
+
/* Cause C-g and alarm signals to take immediate action,
and cause input available signals to zero out timeout. */
if (XINT (read_kbd) < 0)
@@ -3883,9 +3909,23 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
if (frame_garbaged && do_display)
redisplay_preserve_echo_area ();
- if (XINT (read_kbd) && detect_input_pending ())
- nfds = 0;
- else
+ nfds = 1;
+ if (XINT (read_kbd) < 0 && detect_input_pending ())
+ {
+ swallow_events (do_display);
+ if (detect_input_pending ())
+ nfds = 0;
+ }
+
+ if ((XINT (read_kbd) > 0)
+ && detect_input_pending_run_timers (do_display))
+ {
+ swallow_events (do_display);
+ if (detect_input_pending_run_timers (do_display))
+ nfds = 0;
+ }
+
+ if (nfds)
nfds = select (1, &waitchannels, (SELECT_TYPE *)0, (SELECT_TYPE *)0,
timeout_p);
@@ -3914,7 +3954,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
/* If we have timed out (nfds == 0) or found some input (nfds > 0),
we should exit. */
- if (nfds >= 0)
+ if (nfds >= 0 && ! timeout_reduced_for_timers)
break;
}