diff options
author | Steven Tamm <steventamm@mac.com> | 2004-07-19 04:42:43 +0000 |
---|---|---|
committer | Steven Tamm <steventamm@mac.com> | 2004-07-19 04:42:43 +0000 |
commit | e082ac9deb976fa9ea3e09d639191bee9e9d5315 (patch) | |
tree | 82a1728cf854c76c67afea7fcd1cc5fc81a44688 /src/mac.c | |
parent | 1204e81c9e8cc713c8d19116873d9d96a9471467 (diff) | |
download | emacs-e082ac9deb976fa9ea3e09d639191bee9e9d5315.tar.gz emacs-e082ac9deb976fa9ea3e09d639191bee9e9d5315.tar.bz2 emacs-e082ac9deb976fa9ea3e09d639191bee9e9d5315.zip |
Fixes for Ctrl-G support on carbon, replacing old timeout based polling
with alarm based polling.
mac.c (sys_select): Redo sys_select to use alarm-based
polling instead of 1 sec timeouts (like solaris).
macterm.c (x_make_frame_visible): Comment in polling on
frame creation.
keyboard.c: Undef SIGIO on Carbon
atimer.c (alarm_signal_handler): Call alarm handlers after
scheduling.
eval.c (Feval): Remove quit_char test
process.c (wait_reading_process_input): Remove clearing
stdin for select call on process input
Diffstat (limited to 'src/mac.c')
-rw-r--r-- | src/mac.c | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/src/mac.c b/src/mac.c index 9f3455ab5dc..dfe5b01761e 100644 --- a/src/mac.c +++ b/src/mac.c @@ -2782,12 +2782,9 @@ sys_select (n, rfds, wfds, efds, timeout) SELECT_TYPE *efds; struct timeval *timeout; { - if (!inhibit_window_system && rfds && FD_ISSET (0, rfds)) - return 1; - else if (inhibit_window_system || noninteractive || - (timeout && (EMACS_SECS(*timeout)==0) && - (EMACS_USECS(*timeout)==0))) - return select(n, rfds, wfds, efds, timeout); + if (inhibit_window_system || noninteractive + || rfds == NULL || !FD_ISSET (0, rfds)) + return select(n, rfds, wfds, efds, timeout); else { EMACS_TIME end_time, now; @@ -2798,30 +2795,36 @@ sys_select (n, rfds, wfds, efds, timeout) do { + EMACS_TIME select_timeout + SELECT_TYPE orfds = *rfds; int r; - EMACS_TIME one_second; - SELECT_TYPE orfds; - - FD_ZERO (&orfds); - if (rfds) - { - orfds = *rfds; - } - - EMACS_SET_SECS (one_second, 1); - EMACS_SET_USECS (one_second, 0); - - if (timeout && EMACS_TIME_LT(*timeout, one_second)) - one_second = *timeout; - - if ((r = select (n, &orfds, wfds, efds, &one_second)) > 0) + OSErr err; + + EMACS_SET_SECS (select_timeout, 0); + EMACS_SET_USECS (select_timeout, 100); + + if (timeout && EMACS_TIME_LT (*timeout, select_timeout)) + select_timeout = *timeout; + + r = select (n, &orfds, wfds, efds, &select_timeout); + err = ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, NULL); + if (r > 0) + { + *rfds = orfds; + if (err == noErr) + { + FD_SET (0, rfds); + r++; + } + return r; + } + else if (err == noErr) { - *rfds = orfds; - return r; + FD_ZERO (rfds); + FD_SET (0, rfds); + return 1; } - - mac_check_for_quit_char(); - + EMACS_GET_TIME (now); EMACS_SUB_TIME (now, end_time, now); } |