diff options
| author | Joakim Verona | 2010-08-27 10:58:44 +0200 |
|---|---|---|
| committer | Joakim Verona | 2010-08-27 10:58:44 +0200 |
| commit | 362120833bcbbaea94976b6701633e2ed75f6051 (patch) | |
| tree | 632690a24a934bb51a32303add5172d63b6b9e00 /src/menu.c | |
| parent | 1800c4865b15a9e1154bf1f03d87d1aaf750a527 (diff) | |
| parent | 1a868076f51b5d6f1cf78117463e6f9c614551ec (diff) | |
| download | emacs-362120833bcbbaea94976b6701633e2ed75f6051.tar.gz emacs-362120833bcbbaea94976b6701633e2ed75f6051.zip | |
merge from trunk, fix conflicts
Diffstat (limited to 'src/menu.c')
| -rw-r--r-- | src/menu.c | 95 |
1 files changed, 36 insertions, 59 deletions
diff --git a/src/menu.c b/src/menu.c index ca00c06a98b..05a296e45fc 100644 --- a/src/menu.c +++ b/src/menu.c | |||
| @@ -61,12 +61,6 @@ extern HMENU current_popup_menu; | |||
| 61 | #define HAVE_BOXES 1 | 61 | #define HAVE_BOXES 1 |
| 62 | #endif | 62 | #endif |
| 63 | 63 | ||
| 64 | /* The timestamp of the last input event Emacs received from the X server. */ | ||
| 65 | /* Defined in keyboard.c. */ | ||
| 66 | extern unsigned long last_event_timestamp; | ||
| 67 | |||
| 68 | extern Lisp_Object QCtoggle, QCradio; | ||
| 69 | |||
| 70 | Lisp_Object menu_items; | 64 | Lisp_Object menu_items; |
| 71 | 65 | ||
| 72 | /* If non-nil, means that the global vars defined here are already in use. | 66 | /* If non-nil, means that the global vars defined here are already in use. |
| @@ -87,7 +81,7 @@ int menu_items_n_panes; | |||
| 87 | static int menu_items_submenu_depth; | 81 | static int menu_items_submenu_depth; |
| 88 | 82 | ||
| 89 | void | 83 | void |
| 90 | init_menu_items () | 84 | init_menu_items (void) |
| 91 | { | 85 | { |
| 92 | if (!NILP (menu_items_inuse)) | 86 | if (!NILP (menu_items_inuse)) |
| 93 | error ("Trying to use a menu from within a menu-entry"); | 87 | error ("Trying to use a menu from within a menu-entry"); |
| @@ -107,13 +101,12 @@ init_menu_items () | |||
| 107 | /* Call at the end of generating the data in menu_items. */ | 101 | /* Call at the end of generating the data in menu_items. */ |
| 108 | 102 | ||
| 109 | void | 103 | void |
| 110 | finish_menu_items () | 104 | finish_menu_items (void) |
| 111 | { | 105 | { |
| 112 | } | 106 | } |
| 113 | 107 | ||
| 114 | Lisp_Object | 108 | Lisp_Object |
| 115 | unuse_menu_items (dummy) | 109 | unuse_menu_items (Lisp_Object dummy) |
| 116 | Lisp_Object dummy; | ||
| 117 | { | 110 | { |
| 118 | return menu_items_inuse = Qnil; | 111 | return menu_items_inuse = Qnil; |
| 119 | } | 112 | } |
| @@ -122,7 +115,7 @@ unuse_menu_items (dummy) | |||
| 122 | in menu_items. */ | 115 | in menu_items. */ |
| 123 | 116 | ||
| 124 | void | 117 | void |
| 125 | discard_menu_items () | 118 | discard_menu_items (void) |
| 126 | { | 119 | { |
| 127 | /* Free the structure if it is especially large. | 120 | /* Free the structure if it is especially large. |
| 128 | Otherwise, hold on to it, to save time. */ | 121 | Otherwise, hold on to it, to save time. */ |
| @@ -134,19 +127,20 @@ discard_menu_items () | |||
| 134 | xassert (NILP (menu_items_inuse)); | 127 | xassert (NILP (menu_items_inuse)); |
| 135 | } | 128 | } |
| 136 | 129 | ||
| 130 | #ifdef HAVE_NS | ||
| 137 | static Lisp_Object | 131 | static Lisp_Object |
| 138 | cleanup_popup_menu (Lisp_Object arg) | 132 | cleanup_popup_menu (Lisp_Object arg) |
| 139 | { | 133 | { |
| 140 | discard_menu_items (); | 134 | discard_menu_items (); |
| 141 | return Qnil; | 135 | return Qnil; |
| 142 | } | 136 | } |
| 137 | #endif | ||
| 143 | 138 | ||
| 144 | /* This undoes save_menu_items, and it is called by the specpdl unwind | 139 | /* This undoes save_menu_items, and it is called by the specpdl unwind |
| 145 | mechanism. */ | 140 | mechanism. */ |
| 146 | 141 | ||
| 147 | static Lisp_Object | 142 | static Lisp_Object |
| 148 | restore_menu_items (saved) | 143 | restore_menu_items (Lisp_Object saved) |
| 149 | Lisp_Object saved; | ||
| 150 | { | 144 | { |
| 151 | menu_items = XCAR (saved); | 145 | menu_items = XCAR (saved); |
| 152 | menu_items_inuse = (! NILP (menu_items) ? Qt : Qnil); | 146 | menu_items_inuse = (! NILP (menu_items) ? Qt : Qnil); |
| @@ -164,7 +158,7 @@ restore_menu_items (saved) | |||
| 164 | It will be restored when the specpdl is unwound. */ | 158 | It will be restored when the specpdl is unwound. */ |
| 165 | 159 | ||
| 166 | void | 160 | void |
| 167 | save_menu_items () | 161 | save_menu_items (void) |
| 168 | { | 162 | { |
| 169 | Lisp_Object saved = list4 (!NILP (menu_items_inuse) ? menu_items : Qnil, | 163 | Lisp_Object saved = list4 (!NILP (menu_items_inuse) ? menu_items : Qnil, |
| 170 | make_number (menu_items_used), | 164 | make_number (menu_items_used), |
| @@ -179,7 +173,7 @@ save_menu_items () | |||
| 179 | /* Make the menu_items vector twice as large. */ | 173 | /* Make the menu_items vector twice as large. */ |
| 180 | 174 | ||
| 181 | static void | 175 | static void |
| 182 | grow_menu_items () | 176 | grow_menu_items (void) |
| 183 | { | 177 | { |
| 184 | menu_items_allocated *= 2; | 178 | menu_items_allocated *= 2; |
| 185 | menu_items = larger_vector (menu_items, menu_items_allocated, Qnil); | 179 | menu_items = larger_vector (menu_items, menu_items_allocated, Qnil); |
| @@ -188,7 +182,7 @@ grow_menu_items () | |||
| 188 | /* Begin a submenu. */ | 182 | /* Begin a submenu. */ |
| 189 | 183 | ||
| 190 | static void | 184 | static void |
| 191 | push_submenu_start () | 185 | push_submenu_start (void) |
| 192 | { | 186 | { |
| 193 | if (menu_items_used + 1 > menu_items_allocated) | 187 | if (menu_items_used + 1 > menu_items_allocated) |
| 194 | grow_menu_items (); | 188 | grow_menu_items (); |
| @@ -200,7 +194,7 @@ push_submenu_start () | |||
| 200 | /* End a submenu. */ | 194 | /* End a submenu. */ |
| 201 | 195 | ||
| 202 | static void | 196 | static void |
| 203 | push_submenu_end () | 197 | push_submenu_end (void) |
| 204 | { | 198 | { |
| 205 | if (menu_items_used + 1 > menu_items_allocated) | 199 | if (menu_items_used + 1 > menu_items_allocated) |
| 206 | grow_menu_items (); | 200 | grow_menu_items (); |
| @@ -212,7 +206,7 @@ push_submenu_end () | |||
| 212 | /* Indicate boundary between left and right. */ | 206 | /* Indicate boundary between left and right. */ |
| 213 | 207 | ||
| 214 | static void | 208 | static void |
| 215 | push_left_right_boundary () | 209 | push_left_right_boundary (void) |
| 216 | { | 210 | { |
| 217 | if (menu_items_used + 1 > menu_items_allocated) | 211 | if (menu_items_used + 1 > menu_items_allocated) |
| 218 | grow_menu_items (); | 212 | grow_menu_items (); |
| @@ -224,8 +218,7 @@ push_left_right_boundary () | |||
| 224 | NAME is the pane name. PREFIX_VEC is a prefix key for this pane. */ | 218 | NAME is the pane name. PREFIX_VEC is a prefix key for this pane. */ |
| 225 | 219 | ||
| 226 | static void | 220 | static void |
| 227 | push_menu_pane (name, prefix_vec) | 221 | push_menu_pane (Lisp_Object name, Lisp_Object prefix_vec) |
| 228 | Lisp_Object name, prefix_vec; | ||
| 229 | { | 222 | { |
| 230 | if (menu_items_used + MENU_ITEMS_PANE_LENGTH > menu_items_allocated) | 223 | if (menu_items_used + MENU_ITEMS_PANE_LENGTH > menu_items_allocated) |
| 231 | grow_menu_items (); | 224 | grow_menu_items (); |
| @@ -246,8 +239,7 @@ push_menu_pane (name, prefix_vec) | |||
| 246 | item, one of nil, `toggle' or `radio'. */ | 239 | item, one of nil, `toggle' or `radio'. */ |
| 247 | 240 | ||
| 248 | static void | 241 | static void |
| 249 | push_menu_item (name, enable, key, def, equiv, type, selected, help) | 242 | push_menu_item (Lisp_Object name, Lisp_Object enable, Lisp_Object key, Lisp_Object def, Lisp_Object equiv, Lisp_Object type, Lisp_Object selected, Lisp_Object help) |
| 250 | Lisp_Object name, enable, key, def, equiv, type, selected, help; | ||
| 251 | { | 243 | { |
| 252 | if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated) | 244 | if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated) |
| 253 | grow_menu_items (); | 245 | grow_menu_items (); |
| @@ -272,8 +264,8 @@ struct skp | |||
| 272 | int notbuttons; | 264 | int notbuttons; |
| 273 | }; | 265 | }; |
| 274 | 266 | ||
| 275 | static void single_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, | 267 | static void single_menu_item (Lisp_Object, Lisp_Object, Lisp_Object, |
| 276 | void *)); | 268 | void *); |
| 277 | 269 | ||
| 278 | /* This is a recursive subroutine of keymap_panes. | 270 | /* This is a recursive subroutine of keymap_panes. |
| 279 | It handles one keymap, KEYMAP. | 271 | It handles one keymap, KEYMAP. |
| @@ -332,9 +324,7 @@ single_keymap_panes (Lisp_Object keymap, Lisp_Object pane_name, | |||
| 332 | If we encounter submenus deeper than SKP->MAXDEPTH levels, ignore them. */ | 324 | If we encounter submenus deeper than SKP->MAXDEPTH levels, ignore them. */ |
| 333 | 325 | ||
| 334 | static void | 326 | static void |
| 335 | single_menu_item (key, item, dummy, skp_v) | 327 | single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *skp_v) |
| 336 | Lisp_Object key, item, dummy; | ||
| 337 | void *skp_v; | ||
| 338 | { | 328 | { |
| 339 | Lisp_Object map, item_string, enabled; | 329 | Lisp_Object map, item_string, enabled; |
| 340 | struct gcpro gcpro1, gcpro2; | 330 | struct gcpro gcpro1, gcpro2; |
| @@ -456,9 +446,7 @@ single_menu_item (key, item, dummy, skp_v) | |||
| 456 | and generate menu panes for them in menu_items. */ | 446 | and generate menu panes for them in menu_items. */ |
| 457 | 447 | ||
| 458 | static void | 448 | static void |
| 459 | keymap_panes (keymaps, nmaps) | 449 | keymap_panes (Lisp_Object *keymaps, int nmaps) |
| 460 | Lisp_Object *keymaps; | ||
| 461 | int nmaps; | ||
| 462 | { | 450 | { |
| 463 | int mapno; | 451 | int mapno; |
| 464 | 452 | ||
| @@ -477,8 +465,7 @@ keymap_panes (keymaps, nmaps) | |||
| 477 | 465 | ||
| 478 | /* Push the items in a single pane defined by the alist PANE. */ | 466 | /* Push the items in a single pane defined by the alist PANE. */ |
| 479 | static void | 467 | static void |
| 480 | list_of_items (pane) | 468 | list_of_items (Lisp_Object pane) |
| 481 | Lisp_Object pane; | ||
| 482 | { | 469 | { |
| 483 | Lisp_Object tail, item, item1; | 470 | Lisp_Object tail, item, item1; |
| 484 | 471 | ||
| @@ -505,8 +492,7 @@ list_of_items (pane) | |||
| 505 | alist-of-alists MENU. | 492 | alist-of-alists MENU. |
| 506 | This handles old-fashioned calls to x-popup-menu. */ | 493 | This handles old-fashioned calls to x-popup-menu. */ |
| 507 | void | 494 | void |
| 508 | list_of_panes (menu) | 495 | list_of_panes (Lisp_Object menu) |
| 509 | Lisp_Object menu; | ||
| 510 | { | 496 | { |
| 511 | Lisp_Object tail; | 497 | Lisp_Object tail; |
| 512 | 498 | ||
| @@ -531,8 +517,7 @@ list_of_panes (menu) | |||
| 531 | whose event type is ITEM_KEY (with string ITEM_NAME) | 517 | whose event type is ITEM_KEY (with string ITEM_NAME) |
| 532 | and whose contents come from the list of keymaps MAPS. */ | 518 | and whose contents come from the list of keymaps MAPS. */ |
| 533 | int | 519 | int |
| 534 | parse_single_submenu (item_key, item_name, maps) | 520 | parse_single_submenu (Lisp_Object item_key, Lisp_Object item_name, Lisp_Object maps) |
| 535 | Lisp_Object item_key, item_name, maps; | ||
| 536 | { | 521 | { |
| 537 | Lisp_Object length; | 522 | Lisp_Object length; |
| 538 | int len; | 523 | int len; |
| @@ -583,7 +568,7 @@ parse_single_submenu (item_key, item_name, maps) | |||
| 583 | /* Allocate a widget_value, blocking input. */ | 568 | /* Allocate a widget_value, blocking input. */ |
| 584 | 569 | ||
| 585 | widget_value * | 570 | widget_value * |
| 586 | xmalloc_widget_value () | 571 | xmalloc_widget_value (void) |
| 587 | { | 572 | { |
| 588 | widget_value *value; | 573 | widget_value *value; |
| 589 | 574 | ||
| @@ -600,8 +585,7 @@ xmalloc_widget_value () | |||
| 600 | must be left alone. */ | 585 | must be left alone. */ |
| 601 | 586 | ||
| 602 | void | 587 | void |
| 603 | free_menubar_widget_value_tree (wv) | 588 | free_menubar_widget_value_tree (widget_value *wv) |
| 604 | widget_value *wv; | ||
| 605 | { | 589 | { |
| 606 | if (! wv) return; | 590 | if (! wv) return; |
| 607 | 591 | ||
| @@ -627,8 +611,7 @@ free_menubar_widget_value_tree (wv) | |||
| 627 | in menu_items starting at index START, up to index END. */ | 611 | in menu_items starting at index START, up to index END. */ |
| 628 | 612 | ||
| 629 | widget_value * | 613 | widget_value * |
| 630 | digest_single_submenu (start, end, top_level_items) | 614 | digest_single_submenu (int start, int end, int top_level_items) |
| 631 | int start, end, top_level_items; | ||
| 632 | { | 615 | { |
| 633 | widget_value *wv, *prev_wv, *save_wv, *first_wv; | 616 | widget_value *wv, *prev_wv, *save_wv, *first_wv; |
| 634 | int i; | 617 | int i; |
| @@ -679,7 +662,7 @@ digest_single_submenu (start, end, top_level_items) | |||
| 679 | { | 662 | { |
| 680 | /* Create a new pane. */ | 663 | /* Create a new pane. */ |
| 681 | Lisp_Object pane_name, prefix; | 664 | Lisp_Object pane_name, prefix; |
| 682 | char *pane_string; | 665 | const char *pane_string; |
| 683 | 666 | ||
| 684 | panes_seen++; | 667 | panes_seen++; |
| 685 | 668 | ||
| @@ -856,8 +839,7 @@ digest_single_submenu (start, end, top_level_items) | |||
| 856 | tree is constructed, and small strings are relocated. So we must wait | 839 | tree is constructed, and small strings are relocated. So we must wait |
| 857 | until no GC can happen before storing pointers into lisp values. */ | 840 | until no GC can happen before storing pointers into lisp values. */ |
| 858 | void | 841 | void |
| 859 | update_submenu_strings (first_wv) | 842 | update_submenu_strings (widget_value *first_wv) |
| 860 | widget_value *first_wv; | ||
| 861 | { | 843 | { |
| 862 | widget_value *wv; | 844 | widget_value *wv; |
| 863 | 845 | ||
| @@ -891,11 +873,7 @@ update_submenu_strings (first_wv) | |||
| 891 | VECTOR is an array of menu events for the whole menu. */ | 873 | VECTOR is an array of menu events for the whole menu. */ |
| 892 | 874 | ||
| 893 | void | 875 | void |
| 894 | find_and_call_menu_selection (f, menu_bar_items_used, vector, client_data) | 876 | find_and_call_menu_selection (FRAME_PTR f, int menu_bar_items_used, Lisp_Object vector, void *client_data) |
| 895 | FRAME_PTR f; | ||
| 896 | int menu_bar_items_used; | ||
| 897 | Lisp_Object vector; | ||
| 898 | void *client_data; | ||
| 899 | { | 877 | { |
| 900 | Lisp_Object prefix, entry; | 878 | Lisp_Object prefix, entry; |
| 901 | Lisp_Object *subprefix_stack; | 879 | Lisp_Object *subprefix_stack; |
| @@ -1082,13 +1060,12 @@ keyboard input, then this normally results in a quit and | |||
| 1082 | `x-popup-menu' does not return. But if POSITION is a mouse button | 1060 | `x-popup-menu' does not return. But if POSITION is a mouse button |
| 1083 | event (indicating that the user invoked the menu with the mouse) then | 1061 | event (indicating that the user invoked the menu with the mouse) then |
| 1084 | no quit occurs and `x-popup-menu' returns nil. */) | 1062 | no quit occurs and `x-popup-menu' returns nil. */) |
| 1085 | (position, menu) | 1063 | (Lisp_Object position, Lisp_Object menu) |
| 1086 | Lisp_Object position, menu; | ||
| 1087 | { | 1064 | { |
| 1088 | Lisp_Object keymap, tem; | 1065 | Lisp_Object keymap, tem; |
| 1089 | int xpos = 0, ypos = 0; | 1066 | int xpos = 0, ypos = 0; |
| 1090 | Lisp_Object title; | 1067 | Lisp_Object title; |
| 1091 | char *error_name = NULL; | 1068 | const char *error_name = NULL; |
| 1092 | Lisp_Object selection = Qnil; | 1069 | Lisp_Object selection = Qnil; |
| 1093 | FRAME_PTR f = NULL; | 1070 | FRAME_PTR f = NULL; |
| 1094 | Lisp_Object x, y, window; | 1071 | Lisp_Object x, y, window; |
| @@ -1164,12 +1141,12 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1164 | Lisp_Object bar_window; | 1141 | Lisp_Object bar_window; |
| 1165 | enum scroll_bar_part part; | 1142 | enum scroll_bar_part part; |
| 1166 | unsigned long time; | 1143 | unsigned long time; |
| 1167 | void (*mouse_position_hook) P_ ((struct frame **, int, | 1144 | void (*mouse_position_hook) (struct frame **, int, |
| 1168 | Lisp_Object *, | 1145 | Lisp_Object *, |
| 1169 | enum scroll_bar_part *, | 1146 | enum scroll_bar_part *, |
| 1170 | Lisp_Object *, | 1147 | Lisp_Object *, |
| 1171 | Lisp_Object *, | 1148 | Lisp_Object *, |
| 1172 | unsigned long *)) = | 1149 | unsigned long *) = |
| 1173 | FRAME_TERMINAL (new_f)->mouse_position_hook; | 1150 | FRAME_TERMINAL (new_f)->mouse_position_hook; |
| 1174 | 1151 | ||
| 1175 | if (mouse_position_hook) | 1152 | if (mouse_position_hook) |
| @@ -1368,7 +1345,7 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1368 | } | 1345 | } |
| 1369 | 1346 | ||
| 1370 | void | 1347 | void |
| 1371 | syms_of_menu () | 1348 | syms_of_menu (void) |
| 1372 | { | 1349 | { |
| 1373 | staticpro (&menu_items); | 1350 | staticpro (&menu_items); |
| 1374 | menu_items = Qnil; | 1351 | menu_items = Qnil; |