changeset 10167:358d48409854

Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT. (push_menu_item): New arg DEF. (single_keymap_panes, list_of_items): Pass new arg. (MENU_ITEMS_ITEM_DEFINITION): New macro. (MENU_ITEMS_ITEM_LENGTH): Now 5. [USE_X_TOOLKIT] (xmenu_show): Store 0 in call_data if item def is 0. (single_submenu): Likewise. (xmenu_show): Call x_mouse_leave.
author Richard M. Stallman <rms@gnu.org>
date Thu, 15 Dec 1994 12:16:00 +0000
parents 2cc7d710cf56
children 64163654c255
files src/xmenu.c
diffstat 1 files changed, 39 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/xmenu.c	Thu Dec 15 02:06:45 1994 +0000
+++ b/src/xmenu.c	Thu Dec 15 12:16:00 1994 +0000
@@ -57,9 +57,6 @@
 #include "dispextern.h"
 
 #ifdef HAVE_X_WINDOWS
-#include "../oldXMenu/XMenu.h"
-#endif
-
 #ifdef USE_X_TOOLKIT
 #include <X11/Xlib.h>
 #include <X11/IntrinsicP.h>
@@ -67,7 +64,10 @@
 #include <X11/StringDefs.h>
 #include <X11/Shell.h>
 #include "../lwlib/lwlib.h"
-#endif /* USE_X_TOOLKIT */
+#else /* not USE_X_TOOLKIT */
+#include "../oldXMenu/XMenu.h"
+#endif /* not USE_X_TOOLKIT */
+#endif /* HAVE_X_WINDOWS */
 
 #define min(x,y) (((x) < (y)) ? (x) : (y))
 #define max(x,y) (((x) > (y)) ? (x) : (y))
@@ -102,9 +102,9 @@
 
    Each pane is described by 3 elements in the vector:
    t, the pane name, the pane's prefix key.
-   Then follow the pane's items, with 4 elements per item:
+   Then follow the pane's items, with 5 elements per item:
    the item string, the enable flag, the item's value,
-   and the equivalent keyboard key's description string.
+   the definition, and the equivalent keyboard key's description string.
 
    In some cases, multiple levels of menus may be described.
    A single vector slot containing nil indicates the start of a submenu.
@@ -125,7 +125,8 @@
 #define MENU_ITEMS_ITEM_ENABLE 1
 #define MENU_ITEMS_ITEM_VALUE 2
 #define MENU_ITEMS_ITEM_EQUIV_KEY 3
-#define MENU_ITEMS_ITEM_LENGTH 4
+#define MENU_ITEMS_ITEM_DEFINITION 4
+#define MENU_ITEMS_ITEM_LENGTH 5
 
 static Lisp_Object menu_items;
 
@@ -257,12 +258,14 @@
 /* Push one menu item into the current pane.
    NAME is the string to display.  ENABLE if non-nil means
    this item can be selected.  KEY is the key generated by
-   choosing this item.  EQUIV is the textual description
-   of the keyboard equivalent for this item (or nil if none).  */
+   choosing this item, or nil if this item doesn't really have a definition.
+   DEF is the definition of this item.
+   EQUIV is the textual description of the keyboard equivalent for
+   this item (or nil if none).  */
 
 static void
-push_menu_item (name, enable, key, equiv)
-     Lisp_Object name, enable, key, equiv;
+push_menu_item (name, enable, key, def, equiv)
+     Lisp_Object name, enable, key, def, equiv;
 {
   if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated)
     grow_menu_items ();
@@ -271,6 +274,7 @@
   XVECTOR (menu_items)->contents[menu_items_used++] = enable;
   XVECTOR (menu_items)->contents[menu_items_used++] = key;
   XVECTOR (menu_items)->contents[menu_items_used++] = equiv;
+  XVECTOR (menu_items)->contents[menu_items_used++] = def;
 }
 
 /* Figure out the current keyboard equivalent of a menu item ITEM1.
@@ -519,7 +523,9 @@
 			item_string = concat2 (item_string,
 					       build_string (" >"));
 #endif
-		      push_menu_item (item_string, enabled, XCONS (item)->car,
+		      /* If definition is nil, pass nil as the key.  */
+		      push_menu_item (item_string, enabled,
+				      XCONS (item)->car, def,
 				      descrip);
 #ifdef USE_X_TOOLKIT
 		      /* Display a submenu using the toolkit.  */
@@ -588,8 +594,9 @@
 			    item_string = concat2 (item_string,
 						   build_string (" >"));
 #endif
+			  /* If definition is nil, pass nil as the key.  */
 			  push_menu_item (item_string, enabled, character,
-					  descrip);
+					  def, descrip);
 #ifdef USE_X_TOOLKIT
 			  if (! NILP (submap))
 			    {
@@ -660,7 +667,7 @@
     {
       item = Fcar (tail);
       if (STRINGP (item))
-	push_menu_item (item, Qnil, Qnil, Qnil);
+	push_menu_item (item, Qnil, Qnil, Qt, Qnil);
       else if (NILP (item))
 	push_left_right_boundary ();
       else
@@ -668,7 +675,7 @@
 	  CHECK_CONS (item, 0);
 	  item1 = Fcar (item);
 	  CHECK_STRING (item1, 1);
-	  push_menu_item (item1, Qt, Fcdr (item), Qnil);
+	  push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil);
 	}
     }
 }
@@ -1283,11 +1290,12 @@
       else
 	{
 	  /* Create a new item within current pane.  */
-	  Lisp_Object item_name, enable, descrip;
+	  Lisp_Object item_name, enable, descrip, def;
 	  item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME];
 	  enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
 	  descrip
 	    = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
+	  def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION];
 
 	  wv = malloc_widget_value ();
 	  if (prev_wv) 
@@ -1298,7 +1306,7 @@
 	  if (!NILP (descrip))
 	    wv->key = (char *) XSTRING (descrip)->data;
 	  wv->value = 0;
-	  wv->call_data = (void *) i;
+	  wv->call_data = (!NILP (def) ? (void *) i : 0);
 	  wv->enabled = !NILP (enable);
 	  prev_wv = wv;
 
@@ -1545,8 +1553,7 @@
      FRAME_PTR f;
      int x;
      int y;
-     int menubarp;		/* Dummy parameter for Xt version of
-				   xmenu_show() */
+     int menubarp;		/* This arg is unused in Xt version.  */
      int keymaps;
      Lisp_Object title;
      char **error;
@@ -1665,11 +1672,12 @@
       else
 	{
 	  /* Create a new item within current pane.  */
-	  Lisp_Object item_name, enable, descrip;
+	  Lisp_Object item_name, enable, descrip, def;
 	  item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME];
 	  enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
 	  descrip
 	    = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
+	  def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION];
 
 	  wv = malloc_widget_value ();
 	  if (prev_wv) 
@@ -1680,7 +1688,11 @@
 	  if (!NILP (descrip))
 	    wv->key = (char *) XSTRING (descrip)->data;
 	  wv->value = 0;
-	  wv->call_data = (void *) &XVECTOR (menu_items)->contents[i];
+	  /* If this item has a null value,
+	     make the call_data null so that it won't display a box
+	     when the mouse is on it.  */
+	  wv->call_data
+	    = (!NILP (def) ? (void *) &XVECTOR (menu_items)->contents[i] : 0);
 	  wv->enabled = !NILP (enable);
 	  prev_wv = wv;
 
@@ -2263,6 +2275,12 @@
   
   status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx,
 			  x, y, ButtonReleaseMask, &datap);
+
+
+  /* Assume the mouse has moved out of the X window.
+     If it has actually moved in, we will get an EnterNotify.  */
+  x_mouse_leave ();
+
   switch (status)
     {
     case XM_SUCCESS: