From e082ac9deb976fa9ea3e09d639191bee9e9d5315 Mon Sep 17 00:00:00 2001 From: Steven Tamm Date: Mon, 19 Jul 2004 04:42:43 +0000 Subject: [PATCH] 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 --- src/ChangeLog | 18 ++++++++++++++++ src/atimer.c | 6 ++++++ src/eval.c | 3 --- src/keyboard.c | 2 +- src/mac.c | 57 ++++++++++++++++++++++++++------------------------ src/macterm.c | 4 ---- src/process.c | 7 ++++--- 7 files changed, 59 insertions(+), 38 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 7a236ada29a..bc59ae9e2d7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,21 @@ +2004-07-18 YAMAMOTO Mitsuharu + + * 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. + 2004-07-18 Luc Teirlinck * xdisp.c (syms_of_xdisp) : Correct diff --git a/src/atimer.c b/src/atimer.c index 7e78bdad9c0..9ec0238ff28 100644 --- a/src/atimer.c +++ b/src/atimer.c @@ -375,7 +375,9 @@ alarm_signal_handler (signo) t = atimers; atimers = atimers->next; +#ifndef MAC_OSX t->fn (t); +#endif if (t->type == ATIMER_CONTINUOUS) { @@ -387,6 +389,10 @@ alarm_signal_handler (signo) t->next = free_atimers; free_atimers = t; } +#ifdef MAC_OSX + /* Fix for Ctrl-G. Perhaps this should apply to all platforms. */ + t->fn (t); +#endif EMACS_GET_TIME (now); } diff --git a/src/eval.c b/src/eval.c index d7cfe959158..f28105ac987 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2145,9 +2145,6 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0, val = call_debugger (Fcons (Qexit, Fcons (val, Qnil))); backtrace_list = backtrace.next; -#ifdef HAVE_CARBON - mac_check_for_quit_char(); -#endif return val; } diff --git a/src/keyboard.c b/src/keyboard.c index de6356987b8..eb2ed608856 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -607,7 +607,7 @@ int flow_control; /* We are unable to use interrupts if FIONREAD is not available, so flush SIGIO so we won't try. */ -#ifndef FIONREAD +#if !defined (FIONREAD) || defined(HAVE_CARBON) #ifdef SIGIO #undef SIGIO #endif 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); } diff --git a/src/macterm.c b/src/macterm.c index 7d9c2bf7105..9e482a17c8e 100644 --- a/src/macterm.c +++ b/src/macterm.c @@ -5321,7 +5321,6 @@ x_make_frame_visible (f) XFlush (FRAME_MAC_DISPLAY (f)); -#if 0 /* MAC_TODO */ /* Synchronize to ensure Emacs knows the frame is visible before we do anything else. We do this loop with input not blocked so that incoming events are handled. */ @@ -5365,9 +5364,6 @@ x_make_frame_visible (f) FRAME_SAMPLE_VISIBILITY (f); } } -#else - UNBLOCK_INPUT; -#endif /* MAC_TODO */ } /* Change from mapped state to withdrawn state. */ diff --git a/src/process.c b/src/process.c index 4c47fc0e92a..aad36b904b5 100644 --- a/src/process.c +++ b/src/process.c @@ -4190,12 +4190,13 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) SELECT_TYPE Atemp, Ctemp; Atemp = input_wait_mask; -#ifdef MAC_OSX - /* On Mac OS X, the SELECT system call always says input is +#if 0 + /* On Mac OS X 10.0, the SELECT system call always says input is present (for reading) at stdin, even when none is. This causes the call to SELECT below to return 1 and status_notify not to be called. As a result output of - subprocesses are incorrectly discarded. */ + subprocesses are incorrectly discarded. + */ FD_CLR (0, &Atemp); #endif Ctemp = connect_wait_mask; -- 2.39.2