changeset 12657:05b7a5d25df6

(next_noop_dpyinfo): New variable. (XTread_socket): Use that to cycle through all displays for XNoOp. (XTread_socket) [USE_X_TOOLKIT]: For ButtonPress in menu bar, save the event--don't pass to Xt yet. Make a menu_bar_activate_event. (temp_index, temp_buffer): Now static.
author Richard M. Stallman <rms@gnu.org>
date Tue, 25 Jul 1995 20:13:23 +0000
parents 5beb1d2be5c1
children dd26c4fb9999
files src/xterm.c
diffstat 1 files changed, 42 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/xterm.c	Tue Jul 25 20:10:03 1995 +0000
+++ b/src/xterm.c	Tue Jul 25 20:13:23 1995 +0000
@@ -86,6 +86,7 @@
 #ifdef USE_X_TOOLKIT
 extern void free_frame_menubar ();
 extern void _XEditResCheckMessages ();
+extern FRAME_PTR x_menubar_window_to_frame ();
 #endif /* USE_X_TOOLKIT */
 
 #ifndef USE_X_TOOLKIT
@@ -3218,13 +3219,19 @@
 
 /* Record the last 100 characters stored
    to help debug the loss-of-chars-during-GC problem.  */
-int temp_index;
-short temp_buffer[100];
+static int temp_index;
+static short temp_buffer[100];
 
 /* Set this to nonzero to fake an "X I/O error"
    on a particular display.  */
 struct x_display_info *XTread_socket_fake_io_error;
 
+/* When we find no input here, we occasionally do a no-op command
+   to verify that the X server is still running and we can still talk with it.
+   We try all the open displays, one by one.
+   This variable is used for cycling thru the displays.  */
+static struct x_display_info *next_noop_dpyinfo;
+
 /* Read events coming from the X server.
    This routine is called by the SIGIO handler.
    We return as soon as there are no more events to be read.
@@ -3965,7 +3972,7 @@
 		    && FRAME_LIVE_P (last_mouse_frame))
 		  f = last_mouse_frame;
 		else
-		  f = x_window_to_frame (dpyinfo, event.xmotion.window);
+		  f = x_window_to_frame (dpyinfo, event.xbutton.window);
 
 		if (f)
 		  {
@@ -3979,18 +3986,6 @@
 
 		    if (bar)
 		      x_scroll_bar_handle_click (bar, &event, &emacs_event);
-#if 0 /* It doesn't make sense to do this.
-	 Menu bar clicks are handled within the toolkit itself.  */
-#ifdef USE_X_TOOLKIT
-		    else
-		      {
-			/* Assume we have a menubar button press. A bad
-			   assumption should behave benignly. */
-			popup_get_selection (&event, dpyinfo);
-			break;
-		      }
-#endif /* USE_X_TOOLKIT */
-#endif
 		  }
 
 		if (event.type == ButtonPress)
@@ -4012,7 +4007,30 @@
 		  }
 
 #ifdef USE_X_TOOLKIT
-		goto OTHER;
+		f = x_menubar_window_to_frame (dpyinfo, event.xbutton.window);
+		/* For a down-event in the menu bar,
+		   don't pass it to Xt right now.
+		   Instead, save it away
+		   and we will pass it to Xt from kbd_buffer_get_event.
+		   That way, we can run some Lisp code first.  */
+		if (f && event.type == ButtonPress)
+		  {
+		    if (f->display.x->saved_button_event == 0)
+		      f->display.x->saved_button_event
+			= (XButtonEvent *) xmalloc (sizeof (XButtonEvent)); 
+		    bcopy (&event, f->display.x->saved_button_event,
+			   sizeof (XButtonEvent));
+		    if (numchars >= 1)
+		      {
+			bufp->kind = menu_bar_activate_event;
+			XSETFRAME (bufp->frame_or_window, f);
+			bufp++;
+			count++;
+			numchars--;
+		      }
+		  }
+		else
+		  goto OTHER;
 #endif /* USE_X_TOOLKIT */
 	      }
 	      break;
@@ -4061,8 +4079,14 @@
       if (x_noop_count >= 100)
 	{
 	  x_noop_count=0;
-	  /* Use the first display in the list.  Why not?  */
-	  XNoOp (x_display_list->display);
+
+	  if (next_noop_dpyinfo == 0)
+	    next_noop_dpyinfo = x_display_list;
+
+	  XNoOp (next_noop_dpyinfo->display);
+
+	  /* Each time we get here, cycle through the displays now open.  */
+	  next_noop_dpyinfo = next_noop_dpyinfo->next;
 	}
     }