From xemacs-m  Wed Jan 15 01:13:59 1997
Received: from venus.Sun.COM (venus.Sun.COM [192.9.25.5])
          by xemacs.org (8.8.4/8.8.4) with SMTP
	  id BAA19851 for <xemacs-beta@xemacs.org>; Wed, 15 Jan 1997 01:13:58 -0600 (CST)
Received: from Eng.Sun.COM ([129.146.1.25]) by venus.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id XAA13173; Tue, 14 Jan 1997 23:13:28 -0800
Received: from kindra.eng.sun.com by Eng.Sun.COM (SMI-8.6/SMI-5.3)
	id XAA14389; Tue, 14 Jan 1997 23:13:26 -0800
Received: from xemacs.eng.sun.com by kindra.eng.sun.com (SMI-8.6/SMI-SVR4)
	id XAA19838; Tue, 14 Jan 1997 23:13:24 -0800
Received: by xemacs.eng.sun.com (SMI-8.6/SMI-SVR4)
	id XAA28262; Tue, 14 Jan 1997 23:13:24 -0800
Date: Tue, 14 Jan 1997 23:13:24 -0800
Message-Id: <199701150713.XAA28262@xemacs.eng.sun.com>
From: Martin Buchholz <mrb@Eng.Sun.COM>
To: Raymond Toy <toy@rtp.ericsson.se>
Cc: XEmacs Mailing List <xemacs-beta@xemacs.org>
Subject: 20.0-b90: some bugs
In-Reply-To: <18358.853186100@rtp.ericsson.se>
References: <18358.853186100@rtp.ericsson.se>
Reply-To: Martin Buchholz <mrb@Eng.Sun.COM>
Mime-Version: 1.0 (generated by tm-edit 7.100)
Content-Type: text/plain; charset=US-ASCII

>>>>> "Ray" == Raymond Toy <toy@rtp.ericsson.se> writes:

Ray> A couple of bugs I've come across:

Ray> 1.  M-$ says "ispell did not output version".  This does not happen
Ray>     with 19.14.  Don't have 20.0-b34 anymore.  If I try again, M-$
Ray>     succeeds.  This being the case, can the error be changed to a
Ray>     warning or message instead?  BTW, ispell -v says it's ispell
Ray>     version 3.1.18.  

I fixed a bug (accept-process-output) in 19.14 that had the exact same
symptoms.  I checked the versions of accept-process-output between my
personal workspace and Steven's (there is some slight divergence) and
noticed that accept-process-output is different.  Perhaps the code in
the following diff is responsible.  Where did this code come from???
Would undoing this change fix the problem?

Mystified,

Martin

(mrb@xemacs) ~/x $ gnudiff -U3 {w,s}/editor/src/event-stream.c
--- w/editor/src/event-stream.c	Fri Jan 10 00:28:27 1997
+++ s/editor/src/event-stream.c	Mon Jan 13 01:42:39 1997
@@ -78,6 +78,9 @@
 /* Hook run when XEmacs is about to be idle. */
 Lisp_Object Qpre_idle_hook, Vpre_idle_hook;
 
+/* Control gratuitous keyboard focus throwing. */
+int focus_follows_mouse;
+
 #ifdef ILL_CONCEIVED_HOOK
 /* Hook run after a command if there's no more input soon.  */
 Lisp_Object Qpost_command_idle_hook, Vpost_command_idle_hook;
@@ -1202,6 +1205,34 @@
     }
 }
 
+int
+event_stream_wakeup_pending_p (int id, int async_p)
+{
+  struct timeout *timeout;
+  Lisp_Object rest = Qnil;
+  Lisp_Object timeout_list;
+  int found = 0;
+
+
+  if (async_p)
+    timeout_list = pending_async_timeout_list;
+  else
+    timeout_list = pending_timeout_list;
+
+  /* Find the element on the list of pending ones, if it's still there. */
+  LIST_LOOP (rest, timeout_list)
+    {
+      timeout = (struct timeout *) XOPAQUE_DATA (XCAR (rest));
+      if (timeout->id == id)
+	{
+	  found = 1;
+	  break;
+	}
+    }
+
+  return found;
+}
+
 
 /**** Asynch. timeout functions (see also signal.c) ****/
 
@@ -1638,6 +1669,7 @@
 	 in emacs_handle_focus_change_final() is based on the _FOR_HOOKS
 	 value, we need to do so too. */
       if (!NILP (sel_frame) &&
+	  !focus_follows_mouse &&
 	  !EQ (DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d), sel_frame) &&
 	  !NILP (DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d)) &&
 	  !EQ (DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d), sel_frame))
@@ -2396,6 +2428,13 @@
 	    and really need the processes to be handled. */
 	 || (!EQ (result, Qt) && event_stream_event_pending_p (0)))
     {
+      /* If our timeout has arrived, we move along. */
+      if (!event_stream_wakeup_pending_p (timeout_id, 0))
+	{
+	  timeout_enabled = 0;
+	  process = Qnil;	/* We're  done. */
+	}
+
       QUIT;	/* next_event_internal() does not QUIT, so check for ^G
 		   before reading output from the process - this makes it
 		   less likely that the filter will actually be aborted.
@@ -2422,17 +2461,8 @@
 	    break;
 	  }
 	case timeout_event:
-	  {
-	    if (timeout_enabled &&
-                XEVENT (event)->event.timeout.id_number == timeout_id)
-	      {
-                timeout_enabled = 0;
-		process = Qnil; /* we're done */
-	      }
-	    else	/* a timeout that's not the one we're waiting for */
-              goto EXECUTE_INTERNAL;
-	    break;
-	  }
+	  /* We execute the event even if it's ours, and notice that it's
+	     happened above. */
 	case pointer_motion_event:
 	case magic_event:
           {
@@ -2476,6 +2506,10 @@
   event = Fmake_event ();
   while (1)
     {
+      /* If our timeout has arrived, we move along. */
+      if (!event_stream_wakeup_pending_p (id, 0))
+	goto DONE_LABEL;
+
       QUIT;	/* next_event_internal() does not QUIT, so check for ^G
 		   before reading output from the process - this makes it
 		   less likely that the filter will actually be aborted.
@@ -2489,12 +2523,8 @@
       switch (XEVENT_TYPE (event))
 	{
 	case timeout_event:
-	  {
-	    if (XEVENT (event)->event.timeout.id_number == id)
-	      goto DONE_LABEL;
-            else
-              goto EXECUTE_INTERNAL;
-	  }
+	  /* We execute the event even if it's ours, and notice that it's
+	     happened above. */
 	case pointer_motion_event:
 	case process_event:
 	case magic_event:
@@ -2578,8 +2608,8 @@
 	  redisplay ();
 	}
 
-      /* If we're no longer waiting for a timeout, bug out. */
-      if (! id)
+      /* If our timeout has arrived, we move along. */
+      if (!event_stream_wakeup_pending_p (id, 0))
 	{
 	  result = Qt;
 	  goto DONE_LABEL;
@@ -2610,15 +2640,9 @@
 	    break;
 	  }
 	case timeout_event:
-	  {
-	    if (XEVENT (event)->event.timeout.id_number != id)
-	      /* a timeout that wasn't the one we're waiting for */
-	      goto EXECUTE_INTERNAL;
-	    id = 0;	/* assert that we are no longer waiting for it. */
-	    result = Qt;
-	    goto DONE_LABEL;
-	  }
-      default:
+	  /* We execute the event even if it's ours, and notice that it's
+	     happened above. */
+	default:
 	  {
 	  EXECUTE_INTERNAL:
 	    execute_internal_event (event);
@@ -2629,7 +2653,7 @@
 
  DONE_LABEL:
   /* If our timeout has not been signalled yet, disable it. */
-  if (id)
+  if (NILP (result))
     event_stream_disable_wakeup (id, 0);
 
   /* Put back the event (if any) that made Fsit_for() exit before the
@@ -4162,6 +4186,13 @@
 Errors running the hook are caught and ignored.
 */ );
   Vpre_idle_hook = Qnil;
+
+  DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse /*
+Variable to control XEmacs behavior with respect to focus changing.
+If this variable is set to t, then XEmacs will not gratuitously change
+the keyboard focus.
+*/ );
+  focus_follows_mouse = 0;
 
 #ifdef ILL_CONCEIVED_HOOK
   /* Ill-conceived because it's not run in all sorts of cases


