From xemacs-m  Thu Jun  5 04:06:56 1997
Received: from jagor.srce.hr (hniksic@jagor.srce.hr [161.53.2.130])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id EAA00505
	for <xemacs-beta@xemacs.org>; Thu, 5 Jun 1997 04:06:54 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id LAA19817; Thu, 5 Jun 1997 11:06:50 +0200 (MET DST)
To: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: [patch] Incorrectly initialized `function-key-map'
X-Attribution: Hrv
X-Face: Mie8:rOV<\c/~z{s.X4A{!?vY7{drJ([U]0O=W/<W*SMo/Mv:58:*_y~ki>xDi&N7XG
        KV^$k0m3Oe/)'e%3=$PCR&3ITUXH,cK>]bci&<qQ>Ff%x_>1`T(+M2Gg/fgndU%k*ft
        [(7._6e0n-V%|%'[c|q:;}td$#INd+;?!-V=c8Pqf}3J
From: Hrvoje Niksic <hniksic@srce.hr>
Date: 05 Jun 1997 11:06:49 +0200
Message-ID: <kigsoyx5sgm.fsf@jagor.srce.hr>
Lines: 79
X-Mailer: Gnus v5.4.52/XEmacs 20.3(beta3)

Note to Gary: this is the bug I was hinting at.  You are free to
proceed with less mundane matters. :-)

I notice that `function-key-map' is incorrectly on any TTY console
other than the startup one.  This is because `init-tty-device'


I have traced this to the code in frame-tty.c that says:

static void
tty_after_init_frame (struct frame *f, int first_on_device,
                      int first_on_console)
{
  if (first_on_console)
    call1 (Qinit_post_tty_win, FRAME_CONSOLE (f));
}


This code is always called with 0 for `first_on_console', because the
checking code in frame.c looked strange (to say the least):

  /* If this is the first frame on the device, make it the selected one. */
  if (NILP (DEVICE_SELECTED_FRAME (d)))
    {
      first_frame_on_device = 1;
      set_device_selected_frame (d, frame);
    }

Wrong value for `first_frame_on_device' implied, of course, wrong
value for `first_frame_on_console'.

Now why should the fact that no device is selected make it the first
frame on device?  Note that all this is called *after* all the frame
initialization stuff.  In fact, Kyle's patch may even fix this before
mine.  Still, to be safe, I've implemented a more sane check for
`first_frame_on_device', by pushing the check before frame
initialization and checking for NILness of the device frame list.  It
fixes things to work right.

--- src/frame.c.orig	Thu Jun  5 10:38:52 1997
+++ src/frame.c	Thu Jun  5 10:42:24 1997
@@ -456,6 +456,12 @@
       reset_face_cachels (XWINDOW (f->root_window));
     }
 
+  /* If no frames on this device formerly existed, say this is the
+     first frame.  It kind of assumes that frameless devices don't
+     exist, but it shouldn't be too harmful.  */
+  if (NILP (DEVICE_FRAME_LIST (d)))
+    first_frame_on_device = 1;
+
   /* This *must* go before the init_*() methods.  Those functions
      call Lisp code, and if any of them causes a warning to be displayed
      and the *Warnings* buffer to be created, it won't get added to
@@ -504,11 +510,8 @@
   f->init_finished = 1;
 
   /* If this is the first frame on the device, make it the selected one. */
-  if (NILP (DEVICE_SELECTED_FRAME (d)))
-    {
-      first_frame_on_device = 1;
-      set_device_selected_frame (d, frame);
-    }
+  if (first_frame_on_device && NILP (DEVICE_SELECTED_FRAME (d)))
+    set_device_selected_frame (d, frame);
 
   /* If at startup or if the current console is a stream console
      (usually also at startup), make this console the selected one



After applying this, all the TTY initialization gets loaded correctly, 
upon each new console startup.

-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Contrary to popular belief, Unix is user friendly.  
It just happens to be selective about who it makes friends with.

