Mercurial > hg > xemacs-beta
changeset 3735:0c544f2f566c
[xemacs-hg @ 2006-12-11 10:10:18 by aidan]
2006-12-08 Aidan Kehoe <kehoea@parhasard.net>
* event-tty.c:
* event-tty.c (emacs_tty_event_pending_p):
* event-tty.c (reinit_vars_of_event_tty):
Pay attention to the dispatch event queue, and input pending
signals in emacs_tty_event_pending_p. Makes pure TTY builds more
responsive.
author | aidan |
---|---|
date | Mon, 11 Dec 2006 10:10:20 +0000 |
parents | e1f65870f845 |
children | 01830ac74073 |
files | src/ChangeLog src/event-tty.c |
diffstat | 2 files changed, 73 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Mon Dec 11 10:04:30 2006 +0000 +++ b/src/ChangeLog Mon Dec 11 10:10:20 2006 +0000 @@ -1,3 +1,12 @@ +2006-12-11 Aidan Kehoe <kehoea@parhasard.net> + + * event-tty.c: + * event-tty.c (emacs_tty_event_pending_p): + * event-tty.c (reinit_vars_of_event_tty): + Pay attention to the dispatch event queue, and input pending + signals in emacs_tty_event_pending_p. Makes pure TTY builds more + responsive. + 2006-12-11 Aidan Kehoe <kehoea@parhasard.net> * glyphs-eimage.c (png_warning_func):
--- a/src/event-tty.c Mon Dec 11 10:04:30 2006 +0000 +++ b/src/event-tty.c Mon Dec 11 10:10:20 2006 +0000 @@ -45,6 +45,8 @@ extern int mswindows_is_blocking; #endif +static int last_quit_check_signal_tick_count; + /************************************************************************/ /* timeout events */ @@ -84,22 +86,76 @@ static int emacs_tty_event_pending_p (int how_many) { + Lisp_Object event; + int tick_count_val; + + /* Cf. the comments on emacs_Xt_event_pending_p in event-xlike-inc.c . */ + if (!how_many) { EMACS_TIME sometime; - /* see if there's a pending timeout. */ + + /* (1) Any pending events in the dispatch queue? */ + if (!NILP(dispatch_event_queue)) + { + return 1; + } + + /* (2) Any TTY or process input available? */ + if (poll_fds_for_input (non_fake_input_wait_mask)) + return 1; + + /* (3) Any timeout input available? */ EMACS_GET_TIME (sometime); if (tty_timer_queue && EMACS_TIME_EQUAL_OR_GREATER (sometime, tty_timer_queue->time)) return 1; + } + else + { + /* HOW_MANY > 0 */ + EVENT_CHAIN_LOOP (event, dispatch_event_queue) + { + if (command_event_p (event)) + { + how_many--; + if (how_many <= 0) + return 1; + } + } - return poll_fds_for_input (non_fake_input_wait_mask); } - /* #### Not right! We need to *count* the number of pending events, which - means we need to have a dispatch queue and drain the pending events, - using drain_tty_devices(). */ - return poll_fds_for_input (tty_only_mask); + tick_count_val = quit_check_signal_tick_count; + + /* Checking in_modal_loop here is a bit cargo-cultish, since its use is + specific to builds with a window system. */ + if (!in_modal_loop && + (last_quit_check_signal_tick_count != tick_count_val)) + { + last_quit_check_signal_tick_count = tick_count_val; + + /* We need to drain the entire queue now -- if we only drain part of + it, we may later on end up with events actually pending but + detect_input_pending() returning false because there wasn't + another SIGIO. */ + event_stream_drain_queue (); + + if (!how_many) + return !NILP (dispatch_event_queue); + + EVENT_CHAIN_LOOP (event, dispatch_event_queue) + { + if (command_event_p (event)) + { + how_many--; + if (how_many <= 0) + return 1; + } + } + } + + return 0; } static void @@ -304,6 +360,8 @@ tty_event_stream->drain_queue_cb = emacs_tty_drain_queue; tty_event_stream->create_io_streams_cb = emacs_tty_create_io_streams; tty_event_stream->delete_io_streams_cb = emacs_tty_delete_io_streams; + + last_quit_check_signal_tick_count = 0; } void