diff src/keyboard.c @ 53232:22aaf1e5fbe6

Full support for multiple terminal I/O (with some rough edges). lib-src/emacsclient.c (emacs_pid): New variable. (window_change): Forward the SIGWINCH signal to the Emacs process after copying the size parameters to the proxy terminal. (copy_from_to): New parameter (sigio), kill Emacs with SIGIO if it is nonzero. (main): Set emacs_pid. lisp/server.el (server-process-filter): Send the pid of Emacs to emacsclient. src/cm.c: Added tty parameters to all functions and all Wcm macro calls. src/cm.h: Added tty parameters to all macros. Updated function prototypes. (Wcm): Moved to struct tty_output. src/dispextern.h: Updated function prototypes. src/dispnew.c: Added tty parameters to all Wcm macro calls. (do_switch_frame): Make old frame obscured, not invisible, to solve problems with other-frame. (Wcm): Moved to struct tty_output. src/keyboard.c (read_avail_input): Select the frame corresponding to the tty that was read. Slight rearrangement of tty loop. src/lisp.h (tabs_safe_p): Removed duplicate prototype. src/sysdep.c (hft_init, hft_reset): Added tty_output parameter. (discard_tty_input): Discard input from all ttys on APOLLO, too. Whatever it is. (narrow_foreground_group, widen_foreground_group): Added tty parameter (not really useful, the functions only work on the controlling tty.) (tabs_safe_p): Added tty parameter. src/term.c Added tty parameters to all Wcm macro calls. Standardised updating_frame vs. selected frame and tty_output access. (term_init): Allocate Wcm. (syms_of_term): Provide the `multi-tty' feature. src/termchar.h (struct tty_output): Added Wcm. src/xdisp.c (try_window_id): Make sure we use the tty device corresponding to the current frame. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-8
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 27 Dec 2003 01:12:57 +0000
parents 33c3c7c16e13
children fe9b37bee5f7
line wrap: on
line diff
--- a/src/keyboard.c	Fri Dec 26 04:31:27 2003 +0000
+++ b/src/keyboard.c	Sat Dec 27 01:12:57 2003 +0000
@@ -6460,7 +6460,7 @@
   /* If input is being read as it arrives, and we have none, there is none.  */
   if (*addr > 0 || (interrupt_input && ! interrupts_deferred))
     return;
-
+  
   /* Try to read some input and see how much we get.  */
   gobble_input (0);
   *addr = (!NILP (Vquit_flag)
@@ -6579,7 +6579,7 @@
   struct input_event buf[KBD_BUFFER_SIZE];
   register int i;
   int nread;
-
+  
   for (i = 0; i < KBD_BUFFER_SIZE; i++)
     EVENT_INIT (buf[i]);
 
@@ -6611,8 +6611,8 @@
       nread = 0;
 
       /* Try to read from each available tty, until one succeeds. */
-      for (tty = tty_list; tty && !nread; tty = tty->next) {
-        
+      for (tty = tty_list; tty; tty = tty->next) {
+      
         /* Determine how many characters we should *try* to read.  */
 #ifdef FIONREAD
         /* Find out how much input is available.  */
@@ -6624,6 +6624,7 @@
             /* ??? Is it really right to send the signal just to this process
                rather than to the whole process group?
                Perhaps on systems with FIONREAD Emacs is alone in its group.  */
+            /* It appears to be the case, see narrow_foreground_group. */
             if (! noninteractive)
               {
                 if (! tty_list->next)
@@ -6706,15 +6707,20 @@
 #endif /* USG or DGUX or CYGWIN */
 #endif /* no FIONREAD */
 
+        if (nread > 0)
+          break;
       } /* for each tty */
       
-      if (! nread)
+      if (nread <= 0)
         return 0;
       
 #endif /* not MSDOS */
 #endif /* not WINDOWSNT */
 
-      /* XXX Select frame corresponding to the tty. */
+      /* Select frame corresponding to the active tty.  Note that the
+         value of selected_frame is not reliable here, redisplay tends
+         to temporarily change it.  But tty should always be non-NULL. */
+      Lisp_Object frame = (tty ? tty->top_frame : selected_frame);
       
       for (i = 0; i < nread; i++)
 	{
@@ -6725,8 +6731,8 @@
 	  if (meta_key != 2)
 	    cbuf[i] &= ~0x80;
 
-	  buf[i].code = cbuf[i];
-	  buf[i].frame_or_window = selected_frame;
+          buf[i].code = cbuf[i];
+	  buf[i].frame_or_window = frame;
 	  buf[i].arg = Qnil;
 	}
     }