aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu.c
diff options
context:
space:
mode:
authorJoakim Verona2010-08-27 10:58:44 +0200
committerJoakim Verona2010-08-27 10:58:44 +0200
commit362120833bcbbaea94976b6701633e2ed75f6051 (patch)
tree632690a24a934bb51a32303add5172d63b6b9e00 /src/menu.c
parent1800c4865b15a9e1154bf1f03d87d1aaf750a527 (diff)
parent1a868076f51b5d6f1cf78117463e6f9c614551ec (diff)
downloademacs-362120833bcbbaea94976b6701633e2ed75f6051.tar.gz
emacs-362120833bcbbaea94976b6701633e2ed75f6051.zip
merge from trunk, fix conflicts
Diffstat (limited to 'src/menu.c')
-rw-r--r--src/menu.c95
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. */
66extern unsigned long last_event_timestamp;
67
68extern Lisp_Object QCtoggle, QCradio;
69
70Lisp_Object menu_items; 64Lisp_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;
87static int menu_items_submenu_depth; 81static int menu_items_submenu_depth;
88 82
89void 83void
90init_menu_items () 84init_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
109void 103void
110finish_menu_items () 104finish_menu_items (void)
111{ 105{
112} 106}
113 107
114Lisp_Object 108Lisp_Object
115unuse_menu_items (dummy) 109unuse_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
124void 117void
125discard_menu_items () 118discard_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
137static Lisp_Object 131static Lisp_Object
138cleanup_popup_menu (Lisp_Object arg) 132cleanup_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
147static Lisp_Object 142static Lisp_Object
148restore_menu_items (saved) 143restore_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
166void 160void
167save_menu_items () 161save_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
181static void 175static void
182grow_menu_items () 176grow_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
190static void 184static void
191push_submenu_start () 185push_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
202static void 196static void
203push_submenu_end () 197push_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
214static void 208static void
215push_left_right_boundary () 209push_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
226static void 220static void
227push_menu_pane (name, prefix_vec) 221push_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
248static void 241static void
249push_menu_item (name, enable, key, def, equiv, type, selected, help) 242push_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
275static void single_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object, 267static 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
334static void 326static void
335single_menu_item (key, item, dummy, skp_v) 327single_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
458static void 448static void
459keymap_panes (keymaps, nmaps) 449keymap_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. */
479static void 467static void
480list_of_items (pane) 468list_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. */
507void 494void
508list_of_panes (menu) 495list_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. */
533int 519int
534parse_single_submenu (item_key, item_name, maps) 520parse_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
585widget_value * 570widget_value *
586xmalloc_widget_value () 571xmalloc_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
602void 587void
603free_menubar_widget_value_tree (wv) 588free_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
629widget_value * 613widget_value *
630digest_single_submenu (start, end, top_level_items) 614digest_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. */
858void 841void
859update_submenu_strings (first_wv) 842update_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
893void 875void
894find_and_call_menu_selection (f, menu_bar_items_used, vector, client_data) 876find_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
1083event (indicating that the user invoked the menu with the mouse) then 1061event (indicating that the user invoked the menu with the mouse) then
1084no quit occurs and `x-popup-menu' returns nil. */) 1062no 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
1370void 1347void
1371syms_of_menu () 1348syms_of_menu (void)
1372{ 1349{
1373 staticpro (&menu_items); 1350 staticpro (&menu_items);
1374 menu_items = Qnil; 1351 menu_items = Qnil;