aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xmenu.c60
1 files changed, 39 insertions, 21 deletions
diff --git a/src/xmenu.c b/src/xmenu.c
index fffcdc4626e..267491ebf95 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -57,9 +57,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
57#include "dispextern.h" 57#include "dispextern.h"
58 58
59#ifdef HAVE_X_WINDOWS 59#ifdef HAVE_X_WINDOWS
60#include "../oldXMenu/XMenu.h"
61#endif
62
63#ifdef USE_X_TOOLKIT 60#ifdef USE_X_TOOLKIT
64#include <X11/Xlib.h> 61#include <X11/Xlib.h>
65#include <X11/IntrinsicP.h> 62#include <X11/IntrinsicP.h>
@@ -67,7 +64,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
67#include <X11/StringDefs.h> 64#include <X11/StringDefs.h>
68#include <X11/Shell.h> 65#include <X11/Shell.h>
69#include "../lwlib/lwlib.h" 66#include "../lwlib/lwlib.h"
70#endif /* USE_X_TOOLKIT */ 67#else /* not USE_X_TOOLKIT */
68#include "../oldXMenu/XMenu.h"
69#endif /* not USE_X_TOOLKIT */
70#endif /* HAVE_X_WINDOWS */
71 71
72#define min(x,y) (((x) < (y)) ? (x) : (y)) 72#define min(x,y) (((x) < (y)) ? (x) : (y))
73#define max(x,y) (((x) > (y)) ? (x) : (y)) 73#define max(x,y) (((x) > (y)) ? (x) : (y))
@@ -102,9 +102,9 @@ static void list_of_items ();
102 102
103 Each pane is described by 3 elements in the vector: 103 Each pane is described by 3 elements in the vector:
104 t, the pane name, the pane's prefix key. 104 t, the pane name, the pane's prefix key.
105 Then follow the pane's items, with 4 elements per item: 105 Then follow the pane's items, with 5 elements per item:
106 the item string, the enable flag, the item's value, 106 the item string, the enable flag, the item's value,
107 and the equivalent keyboard key's description string. 107 the definition, and the equivalent keyboard key's description string.
108 108
109 In some cases, multiple levels of menus may be described. 109 In some cases, multiple levels of menus may be described.
110 A single vector slot containing nil indicates the start of a submenu. 110 A single vector slot containing nil indicates the start of a submenu.
@@ -125,7 +125,8 @@ static void list_of_items ();
125#define MENU_ITEMS_ITEM_ENABLE 1 125#define MENU_ITEMS_ITEM_ENABLE 1
126#define MENU_ITEMS_ITEM_VALUE 2 126#define MENU_ITEMS_ITEM_VALUE 2
127#define MENU_ITEMS_ITEM_EQUIV_KEY 3 127#define MENU_ITEMS_ITEM_EQUIV_KEY 3
128#define MENU_ITEMS_ITEM_LENGTH 4 128#define MENU_ITEMS_ITEM_DEFINITION 4
129#define MENU_ITEMS_ITEM_LENGTH 5
129 130
130static Lisp_Object menu_items; 131static Lisp_Object menu_items;
131 132
@@ -257,12 +258,14 @@ push_menu_pane (name, prefix_vec)
257/* Push one menu item into the current pane. 258/* Push one menu item into the current pane.
258 NAME is the string to display. ENABLE if non-nil means 259 NAME is the string to display. ENABLE if non-nil means
259 this item can be selected. KEY is the key generated by 260 this item can be selected. KEY is the key generated by
260 choosing this item. EQUIV is the textual description 261 choosing this item, or nil if this item doesn't really have a definition.
261 of the keyboard equivalent for this item (or nil if none). */ 262 DEF is the definition of this item.
263 EQUIV is the textual description of the keyboard equivalent for
264 this item (or nil if none). */
262 265
263static void 266static void
264push_menu_item (name, enable, key, equiv) 267push_menu_item (name, enable, key, def, equiv)
265 Lisp_Object name, enable, key, equiv; 268 Lisp_Object name, enable, key, def, equiv;
266{ 269{
267 if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated) 270 if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated)
268 grow_menu_items (); 271 grow_menu_items ();
@@ -271,6 +274,7 @@ push_menu_item (name, enable, key, equiv)
271 XVECTOR (menu_items)->contents[menu_items_used++] = enable; 274 XVECTOR (menu_items)->contents[menu_items_used++] = enable;
272 XVECTOR (menu_items)->contents[menu_items_used++] = key; 275 XVECTOR (menu_items)->contents[menu_items_used++] = key;
273 XVECTOR (menu_items)->contents[menu_items_used++] = equiv; 276 XVECTOR (menu_items)->contents[menu_items_used++] = equiv;
277 XVECTOR (menu_items)->contents[menu_items_used++] = def;
274} 278}
275 279
276/* Figure out the current keyboard equivalent of a menu item ITEM1. 280/* Figure out the current keyboard equivalent of a menu item ITEM1.
@@ -519,7 +523,9 @@ single_keymap_panes (keymap, pane_name, prefix, notreal)
519 item_string = concat2 (item_string, 523 item_string = concat2 (item_string,
520 build_string (" >")); 524 build_string (" >"));
521#endif 525#endif
522 push_menu_item (item_string, enabled, XCONS (item)->car, 526 /* If definition is nil, pass nil as the key. */
527 push_menu_item (item_string, enabled,
528 XCONS (item)->car, def,
523 descrip); 529 descrip);
524#ifdef USE_X_TOOLKIT 530#ifdef USE_X_TOOLKIT
525 /* Display a submenu using the toolkit. */ 531 /* Display a submenu using the toolkit. */
@@ -588,8 +594,9 @@ single_keymap_panes (keymap, pane_name, prefix, notreal)
588 item_string = concat2 (item_string, 594 item_string = concat2 (item_string,
589 build_string (" >")); 595 build_string (" >"));
590#endif 596#endif
597 /* If definition is nil, pass nil as the key. */
591 push_menu_item (item_string, enabled, character, 598 push_menu_item (item_string, enabled, character,
592 descrip); 599 def, descrip);
593#ifdef USE_X_TOOLKIT 600#ifdef USE_X_TOOLKIT
594 if (! NILP (submap)) 601 if (! NILP (submap))
595 { 602 {
@@ -660,7 +667,7 @@ list_of_items (pane)
660 { 667 {
661 item = Fcar (tail); 668 item = Fcar (tail);
662 if (STRINGP (item)) 669 if (STRINGP (item))
663 push_menu_item (item, Qnil, Qnil, Qnil); 670 push_menu_item (item, Qnil, Qnil, Qt, Qnil);
664 else if (NILP (item)) 671 else if (NILP (item))
665 push_left_right_boundary (); 672 push_left_right_boundary ();
666 else 673 else
@@ -668,7 +675,7 @@ list_of_items (pane)
668 CHECK_CONS (item, 0); 675 CHECK_CONS (item, 0);
669 item1 = Fcar (item); 676 item1 = Fcar (item);
670 CHECK_STRING (item1, 1); 677 CHECK_STRING (item1, 1);
671 push_menu_item (item1, Qt, Fcdr (item), Qnil); 678 push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil);
672 } 679 }
673 } 680 }
674} 681}
@@ -1283,11 +1290,12 @@ single_submenu (item_key, item_name, maps)
1283 else 1290 else
1284 { 1291 {
1285 /* Create a new item within current pane. */ 1292 /* Create a new item within current pane. */
1286 Lisp_Object item_name, enable, descrip; 1293 Lisp_Object item_name, enable, descrip, def;
1287 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; 1294 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME];
1288 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; 1295 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
1289 descrip 1296 descrip
1290 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; 1297 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
1298 def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION];
1291 1299
1292 wv = malloc_widget_value (); 1300 wv = malloc_widget_value ();
1293 if (prev_wv) 1301 if (prev_wv)
@@ -1298,7 +1306,7 @@ single_submenu (item_key, item_name, maps)
1298 if (!NILP (descrip)) 1306 if (!NILP (descrip))
1299 wv->key = (char *) XSTRING (descrip)->data; 1307 wv->key = (char *) XSTRING (descrip)->data;
1300 wv->value = 0; 1308 wv->value = 0;
1301 wv->call_data = (void *) i; 1309 wv->call_data = (!NILP (def) ? (void *) i : 0);
1302 wv->enabled = !NILP (enable); 1310 wv->enabled = !NILP (enable);
1303 prev_wv = wv; 1311 prev_wv = wv;
1304 1312
@@ -1545,8 +1553,7 @@ xmenu_show (f, x, y, menubarp, keymaps, title, error)
1545 FRAME_PTR f; 1553 FRAME_PTR f;
1546 int x; 1554 int x;
1547 int y; 1555 int y;
1548 int menubarp; /* Dummy parameter for Xt version of 1556 int menubarp; /* This arg is unused in Xt version. */
1549 xmenu_show() */
1550 int keymaps; 1557 int keymaps;
1551 Lisp_Object title; 1558 Lisp_Object title;
1552 char **error; 1559 char **error;
@@ -1665,11 +1672,12 @@ xmenu_show (f, x, y, menubarp, keymaps, title, error)
1665 else 1672 else
1666 { 1673 {
1667 /* Create a new item within current pane. */ 1674 /* Create a new item within current pane. */
1668 Lisp_Object item_name, enable, descrip; 1675 Lisp_Object item_name, enable, descrip, def;
1669 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; 1676 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME];
1670 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; 1677 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
1671 descrip 1678 descrip
1672 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; 1679 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
1680 def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION];
1673 1681
1674 wv = malloc_widget_value (); 1682 wv = malloc_widget_value ();
1675 if (prev_wv) 1683 if (prev_wv)
@@ -1680,7 +1688,11 @@ xmenu_show (f, x, y, menubarp, keymaps, title, error)
1680 if (!NILP (descrip)) 1688 if (!NILP (descrip))
1681 wv->key = (char *) XSTRING (descrip)->data; 1689 wv->key = (char *) XSTRING (descrip)->data;
1682 wv->value = 0; 1690 wv->value = 0;
1683 wv->call_data = (void *) &XVECTOR (menu_items)->contents[i]; 1691 /* If this item has a null value,
1692 make the call_data null so that it won't display a box
1693 when the mouse is on it. */
1694 wv->call_data
1695 = (!NILP (def) ? (void *) &XVECTOR (menu_items)->contents[i] : 0);
1684 wv->enabled = !NILP (enable); 1696 wv->enabled = !NILP (enable);
1685 prev_wv = wv; 1697 prev_wv = wv;
1686 1698
@@ -2263,6 +2275,12 @@ xmenu_show (f, x, y, menubarp, keymaps, title, error)
2263 2275
2264 status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx, 2276 status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx,
2265 x, y, ButtonReleaseMask, &datap); 2277 x, y, ButtonReleaseMask, &datap);
2278
2279
2280 /* Assume the mouse has moved out of the X window.
2281 If it has actually moved in, we will get an EnterNotify. */
2282 x_mouse_leave ();
2283
2266 switch (status) 2284 switch (status)
2267 { 2285 {
2268 case XM_SUCCESS: 2286 case XM_SUCCESS: