Index: src/console-tty.h =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/console-tty.h,v retrieving revision 1.8.2.1 diff -u -r1.8.2.1 console-tty.h --- src/console-tty.h 1998/12/05 16:55:25 1.8.2.1 +++ src/console-tty.h 1999/02/17 04:17:02 @@ -293,5 +293,6 @@ Error_behavior errb); Lisp_Object tty_canonicalize_device_connection (Lisp_Object connection, Error_behavior errb); +struct console * tty_find_console_from_fd (int fd); #endif /* _XEMACS_CONSOLE_TTY_H_ */ Index: src/event-msw.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/event-msw.c,v retrieving revision 1.38.2.9 diff -u -r1.38.2.9 event-msw.c --- src/event-msw.c 1999/01/01 19:12:31 1.38.2.9 +++ src/event-msw.c 1999/02/17 04:17:17 @@ -65,6 +65,7 @@ #include "events-mod.h" #ifdef HAVE_MSG_SELECT #include "sysfile.h" +#include "console-tty.h" #elif defined(__CYGWIN32__) typedef unsigned int SOCKET; #endif @@ -121,10 +122,10 @@ /* The number of things we can wait on */ #define MAX_WAITABLE (MAXIMUM_WAIT_OBJECTS - 1) +#ifndef HAVE_MSG_SELECT /* List of mswindows waitable handles. */ static HANDLE mswindows_waitable_handles[MAX_WAITABLE]; -#ifndef HAVE_MSG_SELECT /* Number of wait handles */ static int mswindows_waitable_count=0; #endif /* HAVE_MSG_SELECT */ @@ -1322,28 +1323,6 @@ pointer_to_this = &select_time_to_block; } - /* select() is slow and buggy so if we don't have any processes - just wait as normal */ - if (memcmp (&process_only_mask, &zero_mask, sizeof(SELECT_TYPE))==0) - { - /* Now try getting a message or process event */ - active = MsgWaitForMultipleObjects (0, mswindows_waitable_handles, - FALSE, badly_p ? INFINITE : 0, - QS_ALLINPUT); - - if (active == WAIT_TIMEOUT) - { - /* No luck trying - just return what we've already got */ - return; - } - else if (active == WAIT_OBJECT_0) - { - /* Got your message, thanks */ - mswindows_drain_windows_queue (); - continue; - } - } - active = select (MAXDESC, &temp_mask, 0, 0, pointer_to_this); if (active == 0) @@ -1356,7 +1335,28 @@ { mswindows_drain_windows_queue (); } - +#ifdef HAVE_TTY + /* Look for a TTY event */ + for (i = 0; i < MAXDESC-1; i++) + { + /* To avoid race conditions (among other things, an infinite + loop when called from Fdiscard_input()), we must return + user events ahead of process events. */ + if (FD_ISSET (i, &temp_mask) && FD_ISSET (i, &tty_only_mask)) + { + struct console *c = tty_find_console_from_fd (i); + Lisp_Object emacs_event = Fmake_event (Qnil, Qnil); + struct Lisp_Event* event = XEVENT (emacs_event); + + assert (c); + if (read_event_from_tty_or_stream_desc (event, c, i)) + { + mswindows_enqueue_dispatch_event (emacs_event); + return; + } + } + } +#endif /* Look for a process event */ for (i = 0; i < MAXDESC-1; i++) { @@ -1369,11 +1369,6 @@ mswindows_enqueue_process_event (p); } - else if (FD_ISSET (i, &tty_only_mask)) - { - /* do we care about tty events? Do we - ever get tty events? */ - } else { /* We might get here when a fake event came @@ -2674,11 +2669,23 @@ static void emacs_mswindows_select_console (struct console *con) { +#ifdef HAVE_MSG_SELECT + if (CONSOLE_MSWINDOWS_P (con)) + return; /* mswindows consoles are automatically selected */ + + event_stream_unixoid_select_console (con); +#endif } static void emacs_mswindows_unselect_console (struct console *con) { +#ifdef HAVE_MSG_SELECT + if (CONSOLE_MSWINDOWS_P (con)) + return; /* mswindows consoles are automatically selected */ + + event_stream_unixoid_unselect_console (con); +#endif } static void Index: src/event-tty.c =================================================================== RCS file: /usr/CVSroot/XEmacs/xemacs/src/event-tty.c,v retrieving revision 1.4.2.1 diff -u -r1.4.2.1 event-tty.c --- src/event-tty.c 1998/12/14 13:54:30 1.4.2.1 +++ src/event-tty.c 1999/02/17 04:17:17 @@ -94,8 +94,8 @@ non_fake_input_wait_mask); } -static struct console * -find_console_from_fd (int fd) +struct console * +tty_find_console_from_fd (int fd) { Lisp_Object concons; @@ -142,7 +142,7 @@ user events ahead of process events. */ if (FD_ISSET (i, &temp_mask) && FD_ISSET (i, &tty_only_mask)) { - struct console *c = find_console_from_fd (i); + struct console *c = tty_find_console_from_fd (i); assert (c); if (read_event_from_tty_or_stream_desc (emacs_event, c, i))