From xemacs-m  Thu Jun 12 23:49:14 1997
Received: from crystal.WonderWorks.COM (crystal.WonderWorks.com [192.203.206.1])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id XAA26335
	for <xemacs-beta@xemacs.org>; Thu, 12 Jun 1997 23:49:12 -0500 (CDT)
Received: by crystal.WonderWorks.COM 
	id QQctsd05056; Fri, 13 Jun 1997 00:49:14 -0400 (EDT)
Date: Fri, 13 Jun 1997 00:49:14 -0400 (EDT)
Message-Id: <QQctsd05056.199706130449@crystal.WonderWorks.COM>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
From: Kyle Jones <kyle_jones@wonderworks.com>
To: xemacs-beta@xemacs.org
Subject: [PATCH] 20.3-b6: resume-console/suspend-console fixes for ttys
X-Mailer: VM 6.33 under 20.3 "Moscow" XEmacs Lucid (beta6)
X-Face: /cA45WHG7jWq>(O3&Z57Y<"WsX5ddc,4c#w0F*zrV#=M
        0@~@,s;b,aMtR5Sqs"+nU.z^CSFQ9t`z2>W,S,]:[+2^
        Nbf6v4g>!&,7R4Ot4Wg{&tm=WX7P["9%a)_da48-^tGy
        ,qz]Z,Zz\{E.,]'EO+F)@$KtF&V

Two problems.  (1) XEmacs keeps reading from a tty console after
the console (e.g. gnuclient -nw) is suspended.  (2) suspending a
console makes all its frames invisible and resuming it makes them
all visible.

Here's a patch.  To fix (1), input is disabled when the console
is suspended and reenable when it is resumed.  There is already
code to do this, it just wasn't being called.  To fix (2), all
`unhidden' frames on the device were made `hidden' at suspend
time and the device selected frame is raised at resume time.

And by Dog, gnuclient -nw is actually usable for me now.

Not applicable to 19.15.

Fri Jun 13 00:38:29 1997  Kyle Jones  <kyle_jones@wonderworks.com>

	* src/console.c (Fsuspend_console):
	  Disable input on ttys.  Hide unhidden frames.

	* src/console.c (Fresume_console):
	  Enable input on ttys.  Raise the device selected frame.

--- 1.1	1997/06/13 02:00:25
+++ src/console.c	1997/06/13 04:42:55
@@ -914,34 +914,35 @@
 */
        (console))
 {
-  Lisp_Object devcons;
-  Lisp_Object framecons;
   struct console *c;
-  struct gcpro gcpro1;
 
 #ifdef HAVE_TTY
-  if (NILP (console))
-      console=Fselected_console();
-
-  GCPRO1 (console);
-
-  c = decode_console(console);
+  c = decode_console (console);
 
   if (CONSOLE_TTY_P (c)) 
   {
-    CONSOLE_DEVICE_LOOP (devcons, c)
+    /*
+     * hide all the unhidden frames so the display code won't update
+     * them while the console is suspended.
+     */
+    Lisp_Object device = CONSOLE_SELECTED_DEVICE (c);
+    if (!NILP (device))
       {
-	struct device *d = XDEVICE (XCAR (devcons)); 
-	DEVICE_FRAME_LOOP (framecons, d)
+	struct device *d = XDEVICE (device);
+	Lisp_Object frame_list = DEVICE_FRAME_LIST (d);
+	while (CONSP (frame_list))
 	  {
-	    Fmake_frame_invisible(XCAR(framecons), Qt);
+	    struct frame *f = XFRAME (XCAR (frame_list));
+	    if (FRAME_REPAINT_P (f))
+	      f->visible = -1;
+	    frame_list = XCDR (frame_list);
 	  }
       }
-    reset_one_console(c);
+    reset_one_console (c);
+    event_stream_unselect_console (c);
     sys_suspend_process(XINT(Fconsole_tty_controlling_process(console)));
   }
 
-  UNGCPRO;
 #endif
   return Qnil;
 }
@@ -952,27 +953,28 @@
 */
        (console))
 {
-  Lisp_Object devcons;
-  Lisp_Object framecons;
   struct console *c;
-  struct gcpro gcpro1, gcpro2, gcpro3;
 
 #ifdef HAVE_TTY
-  GCPRO2 (console, devcons);
+  c = decode_console (console);
 
-  c = decode_console(console);
-
-  if (CONSOLE_TTY_P(c)) 
+  if (CONSOLE_TTY_P (c)) 
   {
-    CONSOLE_DEVICE_LOOP (devcons, c)
+    /* raise the selected frame */
+    Lisp_Object device = CONSOLE_SELECTED_DEVICE (c);
+    if (!NILP (device))
       {
-	struct device *d = XDEVICE (XCAR (devcons)); 
-	DEVICE_FRAME_LOOP (framecons, d)
+	struct device *d = XDEVICE (device);
+	Lisp_Object frame = DEVICE_SELECTED_FRAME (d);
+	if (!NILP (frame))
 	  {
-	    Fmake_frame_visible(XCAR(framecons));
+	    /* force the frame to be cleared */
+	    SET_FRAME_CLEAR (XFRAME (frame));
+	    Fraise_frame (frame);
 	  }
       }
-    init_one_console(c);
+    init_one_console (c);
+    event_stream_select_console (c);
 #ifdef SIGWINCH
     /* The same as in Fsuspend_emacs: it is possible that a size
        change occurred while we were suspended.  Assume one did just
@@ -981,7 +983,6 @@
 #endif
   }
 
-  UNGCPRO;
 #endif
   return Qnil;
 }

