Changeset 1709
- Timestamp:
- 02/17/98 01:45:20 (11 years ago)
- Files:
-
- branches/GNU/src/x-list-font.c (added)
- branches/GNU/src/xmenu.c (modified) (73 diffs)
- branches/GNU/src/xselect.c (modified) (83 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/GNU/src/xmenu.c
r1693 r1709 1 1 /* 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. 4 3 5 4 This file is part of GNU Emacs. … … 32 31 /* Rewritten for clarity and GC protection by rms in Feb 94. */ 33 32 34 #include <config.h>35 36 33 /* On 4.3 this loses if it comes after xterm.h. */ 37 34 #include <signal.h> 35 #include <config.h> 38 36 39 37 #include <stdio.h> 40 38 #include "lisp.h" 41 39 #include "termhooks.h" 42 #include "keyboard.h"43 40 #include "frame.h" 44 41 #include "window.h" 42 #include "keyboard.h" 45 43 #include "blockinput.h" 46 44 #include "buffer.h" … … 67 65 #undef HAVE_MULTILINGUAL_MENU 68 66 #ifdef USE_X_TOOLKIT 69 #include "widget.h"70 67 #include <X11/Xlib.h> 71 68 #include <X11/IntrinsicP.h> … … 115 112 #endif 116 113 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)); 114 static Lisp_Object xmenu_show (); 115 static void keymap_panes (); 116 static void single_keymap_panes (); 117 static void single_menu_item (); 118 static void list_of_panes (); 119 static void list_of_items (); 137 120 138 121 /* This holds a Lisp vector that holds the results of decoding … … 162 145 #define MENU_ITEMS_PANE_LENGTH 3 163 146 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 176 153 177 154 static Lisp_Object menu_items; … … 192 169 /* Flag which when set indicates a dialog or menu has been posted by 193 170 Xt on behalf of one of the widget sets. */ 194 int popup_activated_flag;171 static int popup_activated_flag; 195 172 196 173 static int next_menubar_widget_id; … … 216 193 FRAME_PTR f; 217 194 218 for (tail = Vframe_list; GC_CONSP (tail); tail = XC DR (tail))219 { 220 frame = XC AR (tail);195 for (tail = Vframe_list; GC_CONSP (tail); tail = XCONS (tail)->cdr) 196 { 197 frame = XCONS (tail)->car; 221 198 if (!GC_FRAMEP (frame)) 222 199 continue; 223 200 f = XFRAME (frame); 224 if ( !FRAME_WINDOW_P (f))201 if (f->output_data.nothing == 1) 225 202 continue; 226 203 if (f->output_data.x->id == id) … … 339 316 } 340 317 341 /* Push one menu item into the current pane. NAME is the string to342 display. ENABLE if non-nil means this item can be selected. KEY343 is the key generated by choosing this item, or nil if this item344 doesn't really have a definition. DEF is the definition of this345 item. EQUIV is the textual description of the keyboard equivalent346 for this item (or nil if none). TYPE is the type of this menu347 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). */ 348 325 349 326 static void 350 push_menu_item (name, enable, key, def, equiv , type, selected, help)351 Lisp_Object name, enable, key, def, equiv , type, selected, help;327 push_menu_item (name, enable, key, def, equiv) 328 Lisp_Object name, enable, key, def, equiv; 352 329 { 353 330 if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated) … … 359 336 XVECTOR (menu_items)->contents[menu_items_used++] = equiv; 360 337 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;364 338 } 365 339 … … 383 357 P is the number of panes we have made so far. */ 384 358 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); 387 360 388 361 finish_menu_items (); … … 424 397 #endif 425 398 426 for (tail = keymap; CONSP (tail); tail = XC DR (tail))399 for (tail = keymap; CONSP (tail); tail = XCONS (tail)->cdr) 427 400 { 428 401 GCPRO2 (keymap, pending_maps); 429 402 /* Look at each key binding, and if it is a menu item add it 430 403 to this menu. */ 431 item = XC AR (tail);404 item = XCONS (tail)->car; 432 405 if (CONSP (item)) 433 single_menu_item (XC AR (item), XCDR (item),406 single_menu_item (XCONS (item)->car, XCONS (item)->cdr, 434 407 &pending_maps, notreal, maxdepth, ¬buttons); 435 408 else if (VECTORP (item)) … … 454 427 Lisp_Object elt, eltcdr, string; 455 428 elt = Fcar (pending_maps); 456 eltcdr = XC DR (elt);457 string = XC AR (eltcdr);429 eltcdr = XCONS (elt)->cdr; 430 string = XCONS (eltcdr)->car; 458 431 /* We no longer discard the @ from the beginning of the string here. 459 432 Instead, we do this in xmenu_show. */ 460 433 single_keymap_panes (Fcar (elt), string, 461 XC DR (eltcdr), notreal, maxdepth - 1);434 XCONS (eltcdr)->cdr, notreal, maxdepth - 1); 462 435 pending_maps = Fcdr (pending_maps); 463 436 } … … 484 457 int *notbuttons_ptr; 485 458 { 486 Lisp_Object map, item_string, enabled;459 Lisp_Object def, map, item_string, enabled; 487 460 struct gcpro gcpro1, gcpro2; 488 461 int res; … … 589 562 push_menu_item (item_string, enabled, key, 590 563 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]); 595 565 596 566 #ifdef USE_X_TOOLKIT … … 644 614 item = Fcar (tail); 645 615 if (STRINGP (item)) 646 push_menu_item (item, Qnil, Qnil, Qt, Qnil , Qnil, Qnil, Qnil);616 push_menu_item (item, Qnil, Qnil, Qt, Qnil); 647 617 else if (NILP (item)) 648 618 push_left_right_boundary (); … … 652 622 item1 = Fcar (item); 653 623 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); 655 625 } 656 626 } … … 693 663 Lisp_Object position, menu; 694 664 { 665 int number_of_panes, panes; 695 666 Lisp_Object keymap, tem; 696 int xpos = 0, ypos = 0;667 int xpos, ypos; 697 668 Lisp_Object title; 698 669 char *error_name; 699 670 Lisp_Object selection; 700 struct frame *f = NULL; 671 int i, j; 672 FRAME_PTR f; 701 673 Lisp_Object x, y, window; 702 674 int keymaps = 0; … … 711 683 /* Decode the first argument: find the window and the coordinates. */ 712 684 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))) 715 686 { 716 687 /* Use the mouse's current position. */ 717 FRAME_PTR new_f = SELECTED_FRAME ();688 FRAME_PTR new_f = selected_frame; 718 689 Lisp_Object bar_window; 719 690 enum scroll_bar_part part; … … 791 762 /* Decode the menu items from what was specified. */ 792 763 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)) 795 769 { 796 770 /* We were given a keymap. Extract menu info from the keymap. */ 797 771 Lisp_Object prompt; 772 keymap = get_keymap (menu); 798 773 799 774 /* Extract the detailed info to make one pane. */ … … 812 787 keymaps = 1; 813 788 } 814 else if ( CONSP (menu) && KEYMAPP (XCAR (menu)))789 else if (!NILP (tem)) 815 790 { 816 791 /* We were given a list of keymaps. */ … … 828 803 Lisp_Object prompt; 829 804 830 maps[i++] = keymap = get_keymap (Fcar (tem) , 1, 0);805 maps[i++] = keymap = get_keymap (Fcar (tem)); 831 806 832 807 prompt = map_prompt (keymap); … … 899 874 Lisp_Object position, contents; 900 875 { 901 struct frame * f = NULL;876 FRAME_PTR f; 902 877 Lisp_Object window; 903 878 … … 906 881 /* Decode the first argument: find the window or frame to use. */ 907 882 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))) 910 884 { 911 885 #if 0 /* Using the frame the mouse is on may not be right. */ 912 886 /* Use the mouse's current position. */ 913 FRAME_PTR new_f = SELECTED_FRAME ();887 FRAME_PTR new_f = selected_frame; 914 888 Lisp_Object bar_window; 915 889 int part; … … 1080 1054 || x_non_menubar_window_to_frame (dpyinfo, event.xany.window))) 1081 1055 { 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 } 1086 1064 } 1087 1065 else … … 1099 1077 XPutBackEvent (queue_tmp->event.xany.display, &queue_tmp->event); 1100 1078 queue = queue_tmp->next; 1101 xfree ((char *)queue_tmp);1079 free ((char *)queue_tmp); 1102 1080 /* Cause these events to get read as soon as we UNBLOCK_INPUT. */ 1103 1081 interrupt_input_pending = 1; … … 1147 1125 } 1148 1126 1127 1149 1128 /* This callback is invoked when the user selects a menubar cascade 1150 1129 pushbutton, but before the pulldown menu is posted. */ … … 1157 1136 { 1158 1137 popup_activated_flag = 1; 1159 }1160 1161 /* This callback is invoked when a dialog or menu is finished being1162 used and has been unposted. */1163 1164 static void1165 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/unhighlighted1174 while moving the mouse over them. WIDGET is the menu bar or menu1175 popup widget. ID is its LWLIB_ID. CALL_DATA contains a pointer to1176 the widget_value structure for the menu item, or null in case of1177 unhighlighting. */1178 1179 void1180 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 else1199 {1200 /* WIDGET is the popup menu. It's parent is the frame's1201 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 }1216 1138 } 1217 1139 … … 1236 1158 if (!f) 1237 1159 return; 1238 entry = Qnil;1239 1160 subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object)); 1240 1161 vector = f->menu_bar_vector; … … 1271 1192 1272 1193 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)); 1276 1196 kbd_buffer_store_event (&buf); 1277 1197 … … 1279 1199 if (!NILP (subprefix_stack[j])) 1280 1200 { 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]); 1284 1203 kbd_buffer_store_event (&buf); 1285 1204 } … … 1287 1206 if (!NILP (prefix)) 1288 1207 { 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); 1292 1210 kbd_buffer_store_event (&buf); 1293 1211 } 1294 1212 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); 1298 1215 kbd_buffer_store_event (&buf); 1299 1216 … … 1303 1220 } 1304 1221 } 1222 } 1223 1224 /* This callback is invoked when a dialog or menu is finished being 1225 used and has been unposted. */ 1226 1227 static void 1228 popup_deactivate_callback (widget, id, client_data) 1229 Widget widget; 1230 LWLIB_ID id; 1231 XtPointer client_data; 1232 { 1233 popup_activated_flag = 0; 1305 1234 } 1306 1235 … … 1362 1291 Lisp_Object *mapvec; 1363 1292 widget_value **submenu_stack; 1293 int mapno; 1364 1294 int previous_items = menu_items_used; 1365 1295 int top_level_items = 0; … … 1383 1313 { 1384 1314 if (SYMBOLP (mapvec[i]) 1385 || (CONSP (mapvec[i]) && !KEYMAPP (mapvec[i]))) 1315 || (CONSP (mapvec[i]) 1316 && NILP (Fkeymapp (mapvec[i])))) 1386 1317 { 1387 1318 /* Here we have a command at top level in the menu bar … … 1389 1320 top_level_items = 1; 1390 1321 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); 1393 1323 } 1394 1324 else … … 1405 1335 wv->value = 0; 1406 1336 wv->enabled = 1; 1407 wv->button_type = BUTTON_TYPE_NONE;1408 1337 first_wv = wv; 1409 1338 save_wv = 0; … … 1442 1371 Lisp_Object pane_name, prefix; 1443 1372 char *pane_string; 1444 1445 1373 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; 1446 1374 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; 1447 1448 1375 #ifndef HAVE_MULTILINGUAL_MENU 1449 1376 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); 1454 1378 #endif 1455 1379 pane_string = (NILP (pane_name) … … 1477 1401 wv->value = 0; 1478 1402 wv->enabled = 1; 1479 wv->button_type = BUTTON_TYPE_NONE;1480 1403 } 1481 1404 save_wv = wv; … … 1486 1409 { 1487 1410 /* 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]; 1499 1417 #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 1513 1423 wv = xmalloc_widget_value (); 1514 1424 if (prev_wv) … … 1525 1435 wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0); 1526 1436 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 else1535 abort ();1536 1537 wv->selected = !NILP (selected);1538 if (STRINGP (help))1539 wv->help = XSTRING (help)->data;1540 1541 1437 prev_wv = wv; 1542 1438 … … 1556 1452 return first_wv; 1557 1453 } 1558 1559 1560 1454 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 1455 extern void EmacsFrameSetCharSize (); 1456 1457 /* Recompute all the widgets of frame F, when the menu bar 1458 has been changed. */ 1459 1460 static void 1565 1461 update_frame_menubar (f) 1566 1462 FRAME_PTR f; … … 1568 1464 struct x_output *x = f->output_data.x; 1569 1465 int columns, rows; 1466 int menubar_changed; 1570 1467 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; 1573 1479 1574 1480 BLOCK_INPUT; 1575 /* Save the size of the frame because the pane widget doesn't accept 1576 toresize 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. */ 1577 1483 columns = f->width; 1578 1484 rows = f->height; 1579 1485 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." */ 1582 1488 lw_refigure_widget (x->column_widget, False); 1583 1489 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 */ 1587 1494 XtUnmanageChild (x->edit_widget); 1588 1495 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 } 1594 1505 1595 1506 /* Re-manage the text-area widget, and then thrash the sizes. */ … … 1599 1510 /* Force the pane widget to resize itself with the right values. */ 1600 1511 EmacsFrameSetCharSize (x->edit_widget, columns, rows); 1512 1601 1513 UNBLOCK_INPUT; 1602 return 1;1603 1514 } 1604 1515 … … 1614 1525 { 1615 1526 Widget menubar_widget = f->output_data.x->menubar_widget; 1616 Lisp_Object items;1527 Lisp_Object tail, items, frame; 1617 1528 widget_value *wv, *first_wv, *prev_wv = 0; 1618 1529 int i; … … 1641 1552 wv->value = 0; 1642 1553 wv->enabled = 1; 1643 wv->button_type = BUTTON_TYPE_NONE;1644 1554 first_wv = wv; 1645 1555 … … 1677 1587 1678 1588 /* Run the Lucid hook. */ 1679 safe_run_hooks (Qactivate_menubar_hook); 1680 1589 call1 (Vrun_hooks, Qactivate_menubar_hook); 1681 1590 /* If it has changed current-menubar from previous value, 1682 1591 really recompute the menubar from the value. */ … … 1715 1624 /* Don't set wv->name here; GC during the loop might relocate it. */ 1716 1625 wv->enabled = 1; 1717 wv->button_type = BUTTON_TYPE_NONE;1718 1626 prev_wv = wv; 1719 1627 } … … 1774 1682 wv->value = 0; 1775 1683 wv->enabled = 1; 1776 wv->button_type = BUTTON_TYPE_NONE;1777 1684 /* This prevents lwlib from assuming this 1778 1685 menu item is really supposed to be empty. */ … … 1817 1724 popup_activate_callback, 1818 1725 menubar_selection_callback, 1819 popup_deactivate_callback, 1820 menu_highlight_callback); 1726 popup_deactivate_callback); 1821 1727 f->output_data.x->menubar_widget = menubar_widget; 1822 1728 } … … 1846 1752 1847 1753 free_menubar_widget_value_tree (first_wv); 1754 1848 1755 update_frame_menubar (f); 1849 1756 … … 1866 1773 } 1867 1774 1868 1869 1775 /* Get rid of the menu bar of frame F, and free its storage. 1870 1776 This is used when deleting a frame, and when turning off the menu bar. */ … … 1875 1781 { 1876 1782 Widget menubar_widget; 1783 int id; 1877 1784 1878 1785 menubar_widget = f->output_data.x->menubar_widget; … … 1882 1789 if (menubar_widget) 1883 1790 { 1884 #ifdef USE_MOTIF1885 /* Removing the menu bar magically changes the shell widget's x1886 and y position of (0, 0) which, when the menu bar is turned1887 on again, leads to pull-down menuss appearing in strange1888 positions near the upper-left corner of the display. This1889 happens only with some window managers like twm and ctwm,1890 but not with other like Motif's mwm or kwm, because the1891 latter generate ConfigureNotify events when the menu bar1892 is switched off, which fixes the shell position. */1893 Position x0, y0, x1, y1;1894 #endif1895 1896 1791 BLOCK_INPUT; 1897 1898 #ifdef USE_MOTIF1899 if (f->output_data.x->widget)1900 XtVaGetValues (f->output_data.x->widget, XtNx, &x0, XtNy, &y0, NULL);1901 #endif1902 1903 1792 lw_destroy_all_widgets ((LWLIB_ID) f->output_data.x->id); 1904 f->output_data.x->menubar_widget = NULL;1905 1906 #ifdef USE_MOTIF1907 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 #endif1914 1915 1793 UNBLOCK_INPUT; 1916 1794 } … … 1947 1825 LWLIB_ID widget_id_tick; 1948 1826 1827 #ifdef __STDC__ 1949 1828 static Lisp_Object *volatile menu_item_selection; 1829 #else 1830 static Lisp_Object *menu_item_selection; 1831 #endif 1950 1832 1951 1833 static void … … 1982 1864 1983 1865 int first_pane; 1866 int next_release_must_exit = 0; 1984 1867 1985 1868 *error = NULL; … … 1997 1880 wv->value = 0; 1998 1881 wv->enabled = 1; 1999 wv->button_type = BUTTON_TYPE_NONE;2000 1882 first_wv = wv; 2001 1883 first_pane = 1; … … 2032 1914 Lisp_Object pane_name, prefix; 2033 1915 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]; 2038 1918 #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); 2044 1921 #endif 2045 1922 pane_string = (NILP (pane_name) … … 2065 1942 wv->value = 0; 2066 1943 wv->enabled = 1; 2067 wv->button_type = BUTTON_TYPE_NONE;2068 1944 save_wv = wv; 2069 1945 prev_wv = 0; … … 2080 1956 { 2081 1957 /* 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]; 2091 1964 #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 2105 1971 wv = xmalloc_widget_value (); 2106 1972 if (prev_wv) … … 2118 1984 = (!NILP (def) ? (void *) &XVECTOR (menu_items)->contents[i] : 0); 2119 1985 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 else2128 abort ();2129 2130 wv->selected = !NILP (selected);2131 if (STRINGP (help))2132 wv->help = XSTRING (help)->data;2133 2134 1986 prev_wv = wv; 2135 1987 … … 2155 2007 title = string_make_unibyte (title); 2156 2008 #endif 2157 2158 2009 wv_title->name = (char *) XSTRING (title)->data; 2159 2010 wv_title->enabled = True; 2160 wv_title->button_type = BUTTON_TYPE_NONE;2161 2011 wv_title->next = wv_sep1; 2162 2012 first_wv->contents = wv_title; … … 2168 2018 f->output_data.x->widget, 1, 0, 2169 2019 popup_selection_callback, 2170 popup_deactivate_callback, 2171 menu_highlight_callback); 2020 popup_deactivate_callback); 2172 2021 2173 2022 /* Adjust coordinates to relative to the outer (window manager) window. */ … … 2231 2080 2232 2081 /* Display the menu. */ 2233 lw_popup_menu (menu, (XEvent *)&dummy);2082 lw_popup_menu (menu, &dummy); 2234 2083 popup_activated_flag = 1; 2235 2084 … … 2249 2098 Lisp_Object prefix, entry; 2250 2099 2251 prefix = entry =Qnil;2100 prefix = Qnil; 2252 2101 i = 0; 2253 2102 while (i < menu_items_used) … … 2333 2182 char dialog_name[6]; 2334 2183 2335 widget_value *wv, * first_wv = 0, *prev_wv = 0;2184 widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; 2336 2185 2337 2186 /* Number of elements seen so far, before boundary. */ … … 2442 2291 menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv, 2443 2292 f->output_data.x->widget, 1, 0, 2444 dialog_selection_callback, 0 , 0);2293 dialog_selection_callback, 0); 2445 2294 lw_modify_all_widgets (dialog_id, first_wv->contents, True); 2446 2295 /* Free the widget_value objects we used to specify the contents. */ … … 2476 2325 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; 2477 2326 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 and2482 right-side elts. */2483 ++i;2484 2327 } 2485 2328 else … … 2504 2347 return Qnil; 2505 2348 } 2506 2507 2349 #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 in2518 the menu (currently not used).2519 2520 This cannot be done with generating a HELP_EVENT because2521 XMenuActivate contains a loop that doesn't let Emacs process2522 keyboard events. */2523 2524 static void2525 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 else2541 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 2551 2350 2552 2351 static Lisp_Object … … 2681 2480 { 2682 2481 /* Create a new item within current pane. */ 2683 Lisp_Object item_name, enable, descrip , help;2482 Lisp_Object item_name, enable, descrip; 2684 2483 unsigned char *item_data; 2685 char *help_string;2686 2484 2687 2485 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; … … 2689 2487 descrip 2690 2488 = 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 2694 2489 if (!NILP (descrip)) 2695 2490 { … … 2721 2516 if (XMenuAddSelection (FRAME_X_DISPLAY (f), 2722 2517 menu, lpane, 0, item_data, 2723  
