Changeset 1709

Show
Ignore:
Timestamp:
02/17/98 01:45:20 (11 years ago)
Author:
himi
Message:

Emacs 20.3.5 FSF import

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/GNU/src/xmenu.c

    r1693 r1709  
    11/* X Communication module for terminals which understand the X protocol. 
    2    Copyright (C) 1986, 88, 93, 94, 96, 99, 2000, 2001 
    3    Free Software Foundation, Inc. 
     2   Copyright (C) 1986, 1988, 1993, 1994, 1996 Free Software Foundation, Inc. 
    43 
    54This file is part of GNU Emacs. 
     
    3231/* Rewritten for clarity and GC protection by rms in Feb 94.  */ 
    3332 
    34 #include <config.h> 
    35  
    3633/* On 4.3 this loses if it comes after xterm.h.  */ 
    3734#include <signal.h> 
     35#include <config.h> 
    3836 
    3937#include <stdio.h> 
    4038#include "lisp.h" 
    4139#include "termhooks.h" 
    42 #include "keyboard.h" 
    4340#include "frame.h" 
    4441#include "window.h" 
     42#include "keyboard.h" 
    4543#include "blockinput.h" 
    4644#include "buffer.h" 
     
    6765#undef HAVE_MULTILINGUAL_MENU 
    6866#ifdef USE_X_TOOLKIT 
    69 #include "widget.h" 
    7067#include <X11/Xlib.h> 
    7168#include <X11/IntrinsicP.h> 
     
    115112#endif 
    116113 
    117 #ifdef USE_X_TOOLKIT 
    118  
    119 /* Define HAVE_BOXES if meus can handle radio and toggle buttons.  */ 
    120  
    121 #define HAVE_BOXES 1 
    122 #endif 
    123  
    124 static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, 
    125                                 Lisp_Object, Lisp_Object, Lisp_Object, 
    126                                 Lisp_Object, Lisp_Object)); 
    127 static int update_frame_menubar P_ ((struct frame *)); 
    128 static Lisp_Object xmenu_show P_ ((struct frame *, int, int, int, int, 
    129                                    Lisp_Object, char **)); 
    130 static void keymap_panes P_ ((Lisp_Object *, int, int)); 
    131 static void single_keymap_panes P_ ((Lisp_Object, Lisp_Object, Lisp_Object, 
    132                                      int, int)); 
    133 static void single_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object *, 
    134                                   int, int, int *)); 
    135 static void list_of_panes P_ ((Lisp_Object)); 
    136 static void list_of_items P_ ((Lisp_Object)); 
     114static Lisp_Object xmenu_show (); 
     115static void keymap_panes (); 
     116static void single_keymap_panes (); 
     117static void single_menu_item (); 
     118static void list_of_panes (); 
     119static void list_of_items (); 
    137120  
    138121/* This holds a Lisp vector that holds the results of decoding 
     
    162145#define MENU_ITEMS_PANE_LENGTH 3 
    163146 
    164 enum menu_item_idx 
    165 
    166   MENU_ITEMS_ITEM_NAME = 0, 
    167   MENU_ITEMS_ITEM_ENABLE, 
    168   MENU_ITEMS_ITEM_VALUE, 
    169   MENU_ITEMS_ITEM_EQUIV_KEY, 
    170   MENU_ITEMS_ITEM_DEFINITION, 
    171   MENU_ITEMS_ITEM_TYPE, 
    172   MENU_ITEMS_ITEM_SELECTED, 
    173   MENU_ITEMS_ITEM_HELP, 
    174   MENU_ITEMS_ITEM_LENGTH 
    175 }; 
     147#define MENU_ITEMS_ITEM_NAME 0 
     148#define MENU_ITEMS_ITEM_ENABLE 1 
     149#define MENU_ITEMS_ITEM_VALUE 2 
     150#define MENU_ITEMS_ITEM_EQUIV_KEY 3 
     151#define MENU_ITEMS_ITEM_DEFINITION 4 
     152#define MENU_ITEMS_ITEM_LENGTH 5 
    176153 
    177154static Lisp_Object menu_items; 
     
    192169/* Flag which when set indicates a dialog or menu has been posted by 
    193170   Xt on behalf of one of the widget sets.  */ 
    194 int popup_activated_flag; 
     171static int popup_activated_flag; 
    195172 
    196173static int next_menubar_widget_id; 
     
    216193  FRAME_PTR f; 
    217194 
    218   for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail)
    219     { 
    220       frame = XCAR (tail)
     195  for (tail = Vframe_list; GC_CONSP (tail); tail = XCONS (tail)->cdr
     196    { 
     197      frame = XCONS (tail)->car
    221198      if (!GC_FRAMEP (frame)) 
    222199        continue; 
    223200      f = XFRAME (frame); 
    224       if (!FRAME_WINDOW_P (f)
     201      if (f->output_data.nothing == 1
    225202        continue; 
    226203      if (f->output_data.x->id == id) 
     
    339316} 
    340317 
    341 /* Push one menu item into the current pane.  NAME is the string to 
    342    display.  ENABLE if non-nil means this item can be selected.  KEY 
    343    is the key generated by choosing this item, or nil if this item 
    344    doesn't really have a definition.  DEF is the definition of this 
    345    item.  EQUIV is the textual description of the keyboard equivalent 
    346    for this item (or nil if none).  TYPE is the type of this menu 
    347    item, one of nil, `toggle' or `radio'. */ 
     318/* Push one menu item into the current pane. 
     319   NAME is the string to display.  ENABLE if non-nil means 
     320   this item can be selected.  KEY is the key generated by 
     321   choosing this item, or nil if this item doesn't really have a definition. 
     322   DEF is the definition of this item. 
     323   EQUIV is the textual description of the keyboard equivalent for 
     324   this item (or nil if none). */ 
    348325 
    349326static void 
    350 push_menu_item (name, enable, key, def, equiv, type, selected, help
    351      Lisp_Object name, enable, key, def, equiv, type, selected, help
     327push_menu_item (name, enable, key, def, equiv
     328     Lisp_Object name, enable, key, def, equiv
    352329{ 
    353330  if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated) 
     
    359336  XVECTOR (menu_items)->contents[menu_items_used++] = equiv; 
    360337  XVECTOR (menu_items)->contents[menu_items_used++] = def; 
    361   XVECTOR (menu_items)->contents[menu_items_used++] = type; 
    362   XVECTOR (menu_items)->contents[menu_items_used++] = selected; 
    363   XVECTOR (menu_items)->contents[menu_items_used++] = help; 
    364338} 
    365339  
     
    383357     P is the number of panes we have made so far.  */ 
    384358  for (mapno = 0; mapno < nmaps; mapno++) 
    385     single_keymap_panes (keymaps[mapno], 
    386                          map_prompt (keymaps[mapno]), Qnil, notreal, 10); 
     359    single_keymap_panes (keymaps[mapno], Qnil, Qnil, notreal, 10); 
    387360 
    388361  finish_menu_items (); 
     
    424397#endif 
    425398 
    426   for (tail = keymap; CONSP (tail); tail = XCDR (tail)
     399  for (tail = keymap; CONSP (tail); tail = XCONS (tail)->cdr
    427400    { 
    428401      GCPRO2 (keymap, pending_maps); 
    429402      /* Look at each key binding, and if it is a menu item add it 
    430403         to this menu.  */ 
    431       item = XCAR (tail)
     404      item = XCONS (tail)->car
    432405      if (CONSP (item)) 
    433         single_menu_item (XCAR (item), XCDR (item)
     406        single_menu_item (XCONS (item)->car, XCONS (item)->cdr
    434407                          &pending_maps, notreal, maxdepth, &notbuttons); 
    435408      else if (VECTORP (item)) 
     
    454427      Lisp_Object elt, eltcdr, string; 
    455428      elt = Fcar (pending_maps); 
    456       eltcdr = XCDR (elt)
    457       string = XCAR (eltcdr)
     429      eltcdr = XCONS (elt)->cdr
     430      string = XCONS (eltcdr)->car
    458431      /* We no longer discard the @ from the beginning of the string here. 
    459432         Instead, we do this in xmenu_show.  */ 
    460433      single_keymap_panes (Fcar (elt), string, 
    461                            XCDR (eltcdr), notreal, maxdepth - 1); 
     434                           XCONS (eltcdr)->cdr, notreal, maxdepth - 1); 
    462435      pending_maps = Fcdr (pending_maps); 
    463436    } 
     
    484457     int *notbuttons_ptr; 
    485458{ 
    486   Lisp_Object map, item_string, enabled; 
     459  Lisp_Object def, map, item_string, enabled; 
    487460  struct gcpro gcpro1, gcpro2; 
    488461  int res; 
     
    589562  push_menu_item (item_string, enabled, key, 
    590563                  XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF], 
    591                   XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ], 
    592                   XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE], 
    593                   XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED], 
    594                   XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]); 
     564                  XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ]); 
    595565 
    596566#ifdef USE_X_TOOLKIT 
     
    644614      item = Fcar (tail); 
    645615      if (STRINGP (item)) 
    646         push_menu_item (item, Qnil, Qnil, Qt, Qnil, Qnil, Qnil, Qnil); 
     616        push_menu_item (item, Qnil, Qnil, Qt, Qnil); 
    647617      else if (NILP (item)) 
    648618        push_left_right_boundary (); 
     
    652622          item1 = Fcar (item); 
    653623          CHECK_STRING (item1, 1); 
    654           push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil, Qnil, Qnil, Qnil); 
     624          push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil); 
    655625        } 
    656626    } 
     
    693663     Lisp_Object position, menu; 
    694664{ 
     665  int number_of_panes, panes; 
    695666  Lisp_Object keymap, tem; 
    696   int xpos = 0, ypos = 0
     667  int xpos, ypos
    697668  Lisp_Object title; 
    698669  char *error_name; 
    699670  Lisp_Object selection; 
    700   struct frame *f = NULL; 
     671  int i, j; 
     672  FRAME_PTR f; 
    701673  Lisp_Object x, y, window; 
    702674  int keymaps = 0; 
     
    711683      /* Decode the first argument: find the window and the coordinates.  */ 
    712684      if (EQ (position, Qt) 
    713           || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar) 
    714                                    || EQ (XCAR (position), Qtool_bar)))) 
     685          || (CONSP (position) && EQ (XCONS (position)->car, Qmenu_bar))) 
    715686        { 
    716687          /* Use the mouse's current position.  */ 
    717           FRAME_PTR new_f = SELECTED_FRAME ()
     688          FRAME_PTR new_f = selected_frame
    718689          Lisp_Object bar_window; 
    719690          enum scroll_bar_part part; 
     
    791762  /* Decode the menu items from what was specified.  */ 
    792763 
    793   keymap = get_keymap (menu, 0, 0); 
    794   if (CONSP (keymap)) 
     764  keymap = Fkeymapp (menu); 
     765  tem = Qnil; 
     766  if (CONSP (menu)) 
     767    tem = Fkeymapp (Fcar (menu)); 
     768  if (!NILP (keymap)) 
    795769    { 
    796770      /* We were given a keymap.  Extract menu info from the keymap.  */ 
    797771      Lisp_Object prompt; 
     772      keymap = get_keymap (menu); 
    798773 
    799774      /* Extract the detailed info to make one pane.  */ 
     
    812787      keymaps = 1; 
    813788    } 
    814   else if (CONSP (menu) && KEYMAPP (XCAR (menu))) 
     789  else if (!NILP (tem)) 
    815790    { 
    816791      /* We were given a list of keymaps.  */ 
     
    828803          Lisp_Object prompt; 
    829804 
    830           maps[i++] = keymap = get_keymap (Fcar (tem), 1, 0); 
     805          maps[i++] = keymap = get_keymap (Fcar (tem)); 
    831806 
    832807          prompt = map_prompt (keymap); 
     
    899874     Lisp_Object position, contents; 
    900875{ 
    901   struct frame * f = NULL
     876  FRAME_PTR f
    902877  Lisp_Object window; 
    903878 
     
    906881  /* Decode the first argument: find the window or frame to use.  */ 
    907882  if (EQ (position, Qt) 
    908       || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar) 
    909                                || EQ (XCAR (position), Qtool_bar)))) 
     883      || (CONSP (position) && EQ (XCONS (position)->car, Qmenu_bar))) 
    910884    { 
    911885#if 0 /* Using the frame the mouse is on may not be right.  */ 
    912886      /* Use the mouse's current position.  */ 
    913       FRAME_PTR new_f = SELECTED_FRAME ()
     887      FRAME_PTR new_f = selected_frame
    914888      Lisp_Object bar_window; 
    915889      int part; 
     
    10801054              || x_non_menubar_window_to_frame (dpyinfo, event.xany.window))) 
    10811055        { 
    1082           queue_tmp = (struct event_queue *) xmalloc (sizeof *queue_tmp); 
    1083           queue_tmp->event = event; 
    1084           queue_tmp->next = queue; 
    1085           queue = queue_tmp; 
     1056          queue_tmp = (struct event_queue *) malloc (sizeof (struct event_queue)); 
     1057 
     1058          if (queue_tmp != NULL)  
     1059            { 
     1060              queue_tmp->event = event; 
     1061              queue_tmp->next = queue; 
     1062              queue = queue_tmp; 
     1063            } 
    10861064        } 
    10871065      else 
     
    10991077      XPutBackEvent (queue_tmp->event.xany.display, &queue_tmp->event); 
    11001078      queue = queue_tmp->next; 
    1101       xfree ((char *)queue_tmp); 
     1079      free ((char *)queue_tmp); 
    11021080      /* Cause these events to get read as soon as we UNBLOCK_INPUT.  */ 
    11031081      interrupt_input_pending = 1; 
     
    11471125} 
    11481126 
     1127 
    11491128/* This callback is invoked when the user selects a menubar cascade 
    11501129   pushbutton, but before the pulldown menu is posted.  */ 
     
    11571136{ 
    11581137  popup_activated_flag = 1; 
    1159 } 
    1160  
    1161 /* This callback is invoked when a dialog or menu is finished being 
    1162    used and has been unposted.  */ 
    1163  
    1164 static void 
    1165 popup_deactivate_callback (widget, id, client_data) 
    1166      Widget widget; 
    1167      LWLIB_ID id; 
    1168      XtPointer client_data; 
    1169 { 
    1170   popup_activated_flag = 0; 
    1171 } 
    1172  
    1173 /* Lwlib callback called when menu items are highlighted/unhighlighted 
    1174    while moving the mouse over them.  WIDGET is the menu bar or menu 
    1175    popup widget.  ID is its LWLIB_ID.  CALL_DATA contains a pointer to 
    1176    the widget_value structure for the menu item, or null in case of 
    1177    unhighlighting.  */ 
    1178  
    1179 void 
    1180 menu_highlight_callback (widget, id, call_data) 
    1181      Widget widget; 
    1182      LWLIB_ID id; 
    1183      void *call_data; 
    1184 { 
    1185   widget_value *wv = (widget_value *) call_data; 
    1186   struct frame *f; 
    1187   Lisp_Object frame, help; 
    1188  
    1189   help = wv && wv->help ? build_string (wv->help) : Qnil; 
    1190    
    1191   /* Determine the frame for the help event.  */ 
    1192   f = menubar_id_to_frame (id); 
    1193   if (f) 
    1194     { 
    1195       XSETFRAME (frame, f); 
    1196       kbd_buffer_store_help_event (frame, help); 
    1197     } 
    1198   else 
    1199     { 
    1200       /* WIDGET is the popup menu.  It's parent is the frame's  
    1201          widget.  See which frame that is.  */ 
    1202       Widget frame_widget = XtParent (widget); 
    1203       Lisp_Object tail; 
    1204  
    1205       for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail)) 
    1206         { 
    1207           frame = XCAR (tail); 
    1208           if (GC_FRAMEP (frame) 
    1209               && (f = XFRAME (frame), 
    1210                   FRAME_X_P (f) && f->output_data.x->widget == frame_widget)) 
    1211             break; 
    1212         } 
    1213  
    1214       show_help_echo (help, Qnil, Qnil, Qnil, 1); 
    1215     } 
    12161138} 
    12171139 
     
    12361158  if (!f) 
    12371159    return; 
    1238   entry = Qnil; 
    12391160  subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object)); 
    12401161  vector = f->menu_bar_vector; 
     
    12711192 
    12721193              XSETFRAME (frame, f); 
    1273               buf.kind = MENU_BAR_EVENT; 
    1274               buf.frame_or_window = frame; 
    1275               buf.arg = frame; 
     1194              buf.kind = menu_bar_event; 
     1195              buf.frame_or_window = Fcons (frame, Fcons (Qmenu_bar, Qnil)); 
    12761196              kbd_buffer_store_event (&buf); 
    12771197 
     
    12791199                if (!NILP (subprefix_stack[j])) 
    12801200                  { 
    1281                     buf.kind = MENU_BAR_EVENT; 
    1282                     buf.frame_or_window = frame; 
    1283                     buf.arg = subprefix_stack[j]; 
     1201                    buf.kind = menu_bar_event; 
     1202                    buf.frame_or_window = Fcons (frame, subprefix_stack[j]); 
    12841203                    kbd_buffer_store_event (&buf); 
    12851204                  } 
     
    12871206              if (!NILP (prefix)) 
    12881207                { 
    1289                   buf.kind = MENU_BAR_EVENT; 
    1290                   buf.frame_or_window = frame; 
    1291                   buf.arg = prefix; 
     1208                  buf.kind = menu_bar_event; 
     1209                  buf.frame_or_window = Fcons (frame, prefix); 
    12921210                  kbd_buffer_store_event (&buf); 
    12931211                } 
    12941212 
    1295               buf.kind = MENU_BAR_EVENT; 
    1296               buf.frame_or_window = frame; 
    1297               buf.arg = entry; 
     1213              buf.kind = menu_bar_event; 
     1214              buf.frame_or_window = Fcons (frame, entry); 
    12981215              kbd_buffer_store_event (&buf); 
    12991216 
     
    13031220        } 
    13041221    } 
     1222} 
     1223 
     1224/* This callback is invoked when a dialog or menu is finished being 
     1225   used and has been unposted.  */ 
     1226 
     1227static void 
     1228popup_deactivate_callback (widget, id, client_data) 
     1229     Widget widget; 
     1230     LWLIB_ID id; 
     1231     XtPointer client_data; 
     1232{ 
     1233  popup_activated_flag = 0; 
    13051234} 
    13061235 
     
    13621291  Lisp_Object *mapvec; 
    13631292  widget_value **submenu_stack; 
     1293  int mapno; 
    13641294  int previous_items = menu_items_used; 
    13651295  int top_level_items = 0; 
     
    13831313    { 
    13841314      if (SYMBOLP (mapvec[i]) 
    1385           || (CONSP (mapvec[i]) && !KEYMAPP (mapvec[i]))) 
     1315          || (CONSP (mapvec[i]) 
     1316              && NILP (Fkeymapp (mapvec[i])))) 
    13861317        { 
    13871318          /* Here we have a command at top level in the menu bar 
     
    13891320          top_level_items = 1; 
    13901321          push_menu_pane (Qnil, Qnil); 
    1391           push_menu_item (item_name, Qt, item_key, mapvec[i], 
    1392                           Qnil, Qnil, Qnil, Qnil); 
     1322          push_menu_item (item_name, Qt, item_key, mapvec[i], Qnil); 
    13931323        } 
    13941324      else 
     
    14051335  wv->value = 0; 
    14061336  wv->enabled = 1; 
    1407   wv->button_type = BUTTON_TYPE_NONE; 
    14081337  first_wv = wv; 
    14091338  save_wv = 0; 
     
    14421371          Lisp_Object pane_name, prefix; 
    14431372          char *pane_string; 
    1444            
    14451373          pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; 
    14461374          prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; 
    1447            
    14481375#ifndef HAVE_MULTILINGUAL_MENU 
    14491376          if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name)) 
    1450             { 
    1451               pane_name = string_make_unibyte (pane_name); 
    1452               AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name; 
    1453             } 
     1377            pane_name = string_make_unibyte (pane_name); 
    14541378#endif 
    14551379          pane_string = (NILP (pane_name) 
     
    14771401              wv->value = 0; 
    14781402              wv->enabled = 1; 
    1479               wv->button_type = BUTTON_TYPE_NONE; 
    14801403            } 
    14811404          save_wv = wv; 
     
    14861409        { 
    14871410          /* Create a new item within current pane.  */ 
    1488           Lisp_Object item_name, enable, descrip, def, type, selected; 
    1489           Lisp_Object help; 
    1490            
    1491           item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); 
    1492           enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE); 
    1493           descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY); 
    1494           def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION); 
    1495           type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE); 
    1496           selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED); 
    1497           help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP); 
    1498  
     1411          Lisp_Object item_name, enable, descrip, def; 
     1412          item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; 
     1413          enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; 
     1414          descrip 
     1415            = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; 
     1416          def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION]; 
    14991417#ifndef HAVE_MULTILINGUAL_MENU 
    1500           if (STRING_MULTIBYTE (item_name)) 
    1501             { 
    1502               item_name = string_make_unibyte (item_name); 
    1503               AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name; 
    1504             } 
    1505            
    1506           if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) 
    1507             { 
    1508               descrip = string_make_unibyte (descrip); 
    1509               AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip; 
    1510             } 
    1511 #endif /* not HAVE_MULTILINGUAL_MENU */ 
    1512  
     1418          if (STRING_MULTIBYTE (item_name)) 
     1419            item_name = string_make_unibyte (item_name); 
     1420          if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) 
     1421            descrip = string_make_unibyte (descrip); 
     1422#endif 
    15131423          wv = xmalloc_widget_value (); 
    15141424          if (prev_wv)  
     
    15251435          wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0); 
    15261436          wv->enabled = !NILP (enable); 
    1527            
    1528           if (NILP (type)) 
    1529             wv->button_type = BUTTON_TYPE_NONE; 
    1530           else if (EQ (type, QCradio)) 
    1531             wv->button_type = BUTTON_TYPE_RADIO; 
    1532           else if (EQ (type, QCtoggle)) 
    1533             wv->button_type = BUTTON_TYPE_TOGGLE; 
    1534           else 
    1535             abort (); 
    1536  
    1537           wv->selected = !NILP (selected); 
    1538           if (STRINGP (help)) 
    1539             wv->help = XSTRING (help)->data; 
    1540                     
    15411437          prev_wv = wv; 
    15421438 
     
    15561452  return first_wv; 
    15571453} 
    1558  
    1559  
    15601454  
    1561 /* Recompute all the widgets of frame F, when the menu bar has been 
    1562    changed.  Value is non-zero if widgets were updated.  */ 
    1563  
    1564 static int 
     1455extern void EmacsFrameSetCharSize (); 
     1456 
     1457/* Recompute all the widgets of frame F, when the menu bar 
     1458   has been changed.  */ 
     1459 
     1460static void 
    15651461update_frame_menubar (f) 
    15661462     FRAME_PTR f; 
     
    15681464  struct x_output *x = f->output_data.x; 
    15691465  int columns, rows; 
     1466  int menubar_changed; 
    15701467   
    1571   if (!x->menubar_widget || XtIsManaged (x->menubar_widget)) 
    1572     return 0; 
     1468  Dimension shell_height; 
     1469 
     1470  /* We assume the menubar contents has changed if the global flag is set, 
     1471     or if the current buffer has changed, or if the menubar has never 
     1472     been updated before. 
     1473   */ 
     1474  menubar_changed = (x->menubar_widget 
     1475                     && !XtIsManaged (x->menubar_widget)); 
     1476 
     1477  if (! (menubar_changed)) 
     1478    return; 
    15731479 
    15741480  BLOCK_INPUT; 
    1575   /* Save the size of the frame because the pane widget doesn't accept 
    1576      to resize itself. So force it.  */ 
     1481  /* Save the size of the frame because the pane widget doesn't accept to 
     1482     resize itself. So force it.  */ 
    15771483  columns = f->width; 
    15781484  rows = f->height; 
    15791485 
    1580   /* Do the voodoo which means "I'm changing lots of things, don't try 
    1581      to refigure sizes until I'm done." */ 
     1486  /* Do the voodoo which means "I'm changing lots of things, don't try to 
     1487     refigure sizes until I'm done." */ 
    15821488  lw_refigure_widget (x->column_widget, False); 
    15831489 
    1584   /* The order in which children are managed is the top to bottom 
    1585      order in which they are displayed in the paned window.  First, 
    1586      remove the text-area widget.  */ 
     1490  /* the order in which children are managed is the top to 
     1491     bottom order in which they are displayed in the paned window. 
     1492     First, remove the text-area widget. 
     1493   */ 
    15871494  XtUnmanageChild (x->edit_widget); 
    15881495 
    1589   /* Remove the menubar that is there now, and put up the menubar that 
    1590      should be there.  */ 
    1591   XtManageChild (x->menubar_widget); 
    1592   XtMapWidget (x->menubar_widget); 
    1593   XtVaSetValues (x->menubar_widget, XtNmappedWhenManaged, 1, NULL); 
     1496  /* remove the menubar that is there now, and put up the menubar that 
     1497     should be there. 
     1498   */ 
     1499  if (menubar_changed) 
     1500    { 
     1501      XtManageChild (x->menubar_widget); 
     1502      XtMapWidget (x->menubar_widget); 
     1503      XtVaSetValues (x->menubar_widget, XtNmappedWhenManaged, 1, 0); 
     1504    } 
    15941505 
    15951506  /* Re-manage the text-area widget, and then thrash the sizes.  */ 
     
    15991510  /* Force the pane widget to resize itself with the right values.  */ 
    16001511  EmacsFrameSetCharSize (x->edit_widget, columns, rows); 
     1512 
    16011513  UNBLOCK_INPUT; 
    1602   return 1; 
    16031514} 
    16041515 
     
    16141525{ 
    16151526  Widget menubar_widget = f->output_data.x->menubar_widget; 
    1616   Lisp_Object items
     1527  Lisp_Object tail, items, frame
    16171528  widget_value *wv, *first_wv, *prev_wv = 0; 
    16181529  int i; 
     
    16411552  wv->value = 0; 
    16421553  wv->enabled = 1; 
    1643   wv->button_type = BUTTON_TYPE_NONE; 
    16441554  first_wv = wv; 
    16451555 
     
    16771587 
    16781588      /* Run the Lucid hook.  */ 
    1679       safe_run_hooks (Qactivate_menubar_hook); 
    1680        
     1589      call1 (Vrun_hooks, Qactivate_menubar_hook); 
    16811590      /* If it has changed current-menubar from previous value, 
    16821591         really recompute the menubar from the value.  */ 
     
    17151624          /* Don't set wv->name here; GC during the loop might relocate it.  */ 
    17161625          wv->enabled = 1; 
    1717           wv->button_type = BUTTON_TYPE_NONE; 
    17181626          prev_wv = wv; 
    17191627        } 
     
    17741682          wv->value = 0; 
    17751683          wv->enabled = 1; 
    1776           wv->button_type = BUTTON_TYPE_NONE; 
    17771684          /* This prevents lwlib from assuming this 
    17781685             menu item is really supposed to be empty.  */ 
     
    18171724                                         popup_activate_callback, 
    18181725                                         menubar_selection_callback, 
    1819                                          popup_deactivate_callback, 
    1820                                          menu_highlight_callback); 
     1726                                         popup_deactivate_callback); 
    18211727      f->output_data.x->menubar_widget = menubar_widget; 
    18221728    } 
     
    18461752   
    18471753  free_menubar_widget_value_tree (first_wv); 
     1754 
    18481755  update_frame_menubar (f); 
    18491756 
     
    18661773} 
    18671774 
    1868  
    18691775/* Get rid of the menu bar of frame F, and free its storage. 
    18701776   This is used when deleting a frame, and when turning off the menu bar.  */ 
     
    18751781{ 
    18761782  Widget menubar_widget; 
     1783  int id; 
    18771784 
    18781785  menubar_widget = f->output_data.x->menubar_widget; 
     
    18821789  if (menubar_widget) 
    18831790    { 
    1884 #ifdef USE_MOTIF 
    1885       /* Removing the menu bar magically changes the shell widget's x 
    1886          and y position of (0, 0) which, when the menu bar is turned 
    1887          on again, leads to pull-down menuss appearing in strange 
    1888          positions near the upper-left corner of the display.  This 
    1889          happens only with some window managers like twm and ctwm, 
    1890          but not with other like Motif's mwm or kwm, because the 
    1891          latter generate ConfigureNotify events when the menu bar 
    1892          is switched off, which fixes the shell position.  */ 
    1893       Position x0, y0, x1, y1; 
    1894 #endif 
    1895        
    18961791      BLOCK_INPUT; 
    1897  
    1898 #ifdef USE_MOTIF 
    1899       if (f->output_data.x->widget) 
    1900         XtVaGetValues (f->output_data.x->widget, XtNx, &x0, XtNy, &y0, NULL); 
    1901 #endif 
    1902        
    19031792      lw_destroy_all_widgets ((LWLIB_ID) f->output_data.x->id); 
    1904       f->output_data.x->menubar_widget = NULL; 
    1905  
    1906 #ifdef USE_MOTIF 
    1907       if (f->output_data.x->widget) 
    1908         { 
    1909           XtVaGetValues (f->output_data.x->widget, XtNx, &x1, XtNy, &y1, NULL); 
    1910           if (x1 == 0 && y1 == 0) 
    1911             XtVaSetValues (f->output_data.x->widget, XtNx, x0, XtNy, y0, NULL); 
    1912         } 
    1913 #endif 
    1914        
    19151793      UNBLOCK_INPUT; 
    19161794    } 
     
    19471825LWLIB_ID widget_id_tick; 
    19481826 
     1827#ifdef __STDC__ 
    19491828static Lisp_Object *volatile menu_item_selection; 
     1829#else 
     1830static Lisp_Object *menu_item_selection; 
     1831#endif 
    19501832 
    19511833static void 
     
    19821864 
    19831865  int first_pane; 
     1866  int next_release_must_exit = 0; 
    19841867 
    19851868  *error = NULL; 
     
    19971880  wv->value = 0; 
    19981881  wv->enabled = 1; 
    1999   wv->button_type = BUTTON_TYPE_NONE; 
    20001882  first_wv = wv; 
    20011883  first_pane = 1; 
     
    20321914          Lisp_Object pane_name, prefix; 
    20331915          char *pane_string; 
    2034            
    2035           pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); 
    2036           prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); 
    2037            
     1916          pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; 
     1917          prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; 
    20381918#ifndef HAVE_MULTILINGUAL_MENU 
    2039           if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name)) 
    2040             { 
    2041               pane_name = string_make_unibyte (pane_name); 
    2042               AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name; 
    2043             } 
     1919          if (!NILP (pane_name) && STRING_MULTIBYTE (pane_name)) 
     1920            pane_name = string_make_unibyte (pane_name); 
    20441921#endif 
    20451922          pane_string = (NILP (pane_name) 
     
    20651942              wv->value = 0; 
    20661943              wv->enabled = 1; 
    2067               wv->button_type = BUTTON_TYPE_NONE; 
    20681944              save_wv = wv; 
    20691945              prev_wv = 0; 
     
    20801956        { 
    20811957          /* Create a new item within current pane.  */ 
    2082           Lisp_Object item_name, enable, descrip, def, type, selected, help; 
    2083           item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); 
    2084           enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE); 
    2085           descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY); 
    2086           def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION); 
    2087           type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE); 
    2088           selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED); 
    2089           help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP); 
    2090  
     1958          Lisp_Object item_name, enable, descrip, def; 
     1959          item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; 
     1960          enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; 
     1961          descrip 
     1962            = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; 
     1963          def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION]; 
    20911964#ifndef HAVE_MULTILINGUAL_MENU 
    2092           if (STRINGP (item_name) && STRING_MULTIBYTE (item_name)) 
    2093             { 
    2094               item_name = string_make_unibyte (item_name); 
    2095               AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name; 
    2096             } 
    2097            
    2098           if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) 
    2099             { 
    2100               descrip = string_make_unibyte (descrip); 
    2101               AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip; 
    2102             } 
    2103 #endif /* not HAVE_MULTILINGUAL_MENU */ 
    2104   
     1965          if (STRINGP (item_name) && STRING_MULTIBYTE (item_name)) 
     1966            item_name = string_make_unibyte (item_name); 
     1967          if (STRINGP (descrip) && STRING_MULTIBYTE (descrip)) 
     1968            item_name = string_make_unibyte (descrip); 
     1969#endif 
     1970 
    21051971          wv = xmalloc_widget_value (); 
    21061972          if (prev_wv)  
     
    21181984            = (!NILP (def) ? (void *) &XVECTOR (menu_items)->contents[i] : 0); 
    21191985          wv->enabled = !NILP (enable); 
    2120  
    2121           if (NILP (type)) 
    2122             wv->button_type = BUTTON_TYPE_NONE; 
    2123           else if (EQ (type, QCtoggle)) 
    2124             wv->button_type = BUTTON_TYPE_TOGGLE; 
    2125           else if (EQ (type, QCradio)) 
    2126             wv->button_type = BUTTON_TYPE_RADIO; 
    2127           else 
    2128             abort (); 
    2129  
    2130           wv->selected = !NILP (selected); 
    2131           if (STRINGP (help)) 
    2132             wv->help = XSTRING (help)->data; 
    2133            
    21341986          prev_wv = wv; 
    21351987 
     
    21552007        title = string_make_unibyte (title); 
    21562008#endif 
    2157        
    21582009      wv_title->name = (char *) XSTRING (title)->data; 
    21592010      wv_title->enabled = True; 
    2160       wv_title->button_type = BUTTON_TYPE_NONE; 
    21612011      wv_title->next = wv_sep1; 
    21622012      first_wv->contents = wv_title; 
     
    21682018                           f->output_data.x->widget, 1, 0, 
    21692019                           popup_selection_callback, 
    2170                            popup_deactivate_callback, 
    2171                            menu_highlight_callback); 
     2020                           popup_deactivate_callback); 
    21722021 
    21732022  /* Adjust coordinates to relative to the outer (window manager) window.  */ 
     
    22312080 
    22322081  /* Display the menu.  */ 
    2233   lw_popup_menu (menu, (XEvent *) &dummy); 
     2082  lw_popup_menu (menu, &dummy); 
    22342083  popup_activated_flag = 1; 
    22352084 
     
    22492098      Lisp_Object prefix, entry; 
    22502099 
    2251       prefix = entry = Qnil; 
     2100      prefix = Qnil; 
    22522101      i = 0; 
    22532102      while (i < menu_items_used) 
     
    23332182  char dialog_name[6]; 
    23342183 
    2335   widget_value *wv, *first_wv = 0, *prev_wv = 0; 
     2184  widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; 
    23362185 
    23372186  /* Number of elements seen so far, before boundary.  */ 
     
    24422291  menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv, 
    24432292                           f->output_data.x->widget, 1, 0, 
    2444                            dialog_selection_callback, 0, 0); 
     2293                           dialog_selection_callback, 0); 
    24452294  lw_modify_all_widgets (dialog_id, first_wv->contents, True); 
    24462295  /* Free the widget_value objects we used to specify the contents.  */ 
     
    24762325                = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; 
    24772326              i += MENU_ITEMS_PANE_LENGTH; 
    2478             } 
    2479           else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) 
    2480             { 
    2481               /* This is the boundary between left-side elts and 
    2482                  right-side elts.  */ 
    2483               ++i; 
    24842327            } 
    24852328          else 
     
    25042347  return Qnil; 
    25052348} 
    2506  
    25072349#else /* not USE_X_TOOLKIT */ 
    2508  
    2509 /* The frame of the last activated non-toolkit menu bar. 
    2510    Used to generate menu help events.  */ 
    2511  
    2512 static struct frame *menu_help_frame; 
    2513  
    2514  
    2515 /* Show help HELP_STRING, or clear help if HELP_STRING is null. 
    2516  
    2517    PANE is the pane number, and ITEM is the menu item number in 
    2518    the menu (currently not used). 
    2519     
    2520    This cannot be done with generating a HELP_EVENT because 
    2521    XMenuActivate contains a loop that doesn't let Emacs process 
    2522    keyboard events.  */ 
    2523  
    2524 static void 
    2525 menu_help_callback (help_string, pane, item) 
    2526      char *help_string; 
    2527      int pane, item; 
    2528 { 
    2529   extern Lisp_Object Qmenu_item; 
    2530   Lisp_Object *first_item; 
    2531   Lisp_Object pane_name; 
    2532   Lisp_Object menu_object; 
    2533   
    2534   first_item = XVECTOR (menu_items)->contents; 
    2535   if (EQ (first_item[0], Qt)) 
    2536     pane_name = first_item[MENU_ITEMS_PANE_NAME]; 
    2537   else if (EQ (first_item[0], Qquote)) 
    2538     /* This shouldn't happen, see xmenu_show.  */ 
    2539     pane_name = build_string (""); 
    2540   else 
    2541     pane_name = first_item[MENU_ITEMS_ITEM_NAME]; 
    2542   
    2543   /* (menu-item MENU-NAME PANE-NUMBER)  */ 
    2544   menu_object = Fcons (Qmenu_item, 
    2545                        Fcons (pane_name, 
    2546                               Fcons (make_number (pane), Qnil))); 
    2547   show_help_echo (help_string ? build_string (help_string) : Qnil, 
    2548                   Qnil, menu_object, make_number (item), 1); 
    2549 } 
    2550    
    25512350 
    25522351static Lisp_Object 
     
    26812480        { 
    26822481          /* Create a new item within current pane.  */ 
    2683           Lisp_Object item_name, enable, descrip, help
     2482          Lisp_Object item_name, enable, descrip
    26842483          unsigned char *item_data; 
    2685           char *help_string; 
    26862484 
    26872485          item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; 
     
    26892487          descrip 
    26902488            = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; 
    2691           help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP]; 
    2692           help_string = STRINGP (help) ? XSTRING (help)->data : NULL; 
    2693            
    26942489          if (!NILP (descrip)) 
    26952490            { 
     
    27212516          if (XMenuAddSelection (FRAME_X_DISPLAY (f), 
    27222517                                 menu, lpane, 0, item_data, 
    2723