aboutsummaryrefslogtreecommitdiffstats
path: root/src/macmenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/macmenu.c')
-rw-r--r--src/macmenu.c72
1 files changed, 44 insertions, 28 deletions
diff --git a/src/macmenu.c b/src/macmenu.c
index e7d69d5657c..1a1525eafb7 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -64,7 +64,8 @@ Boston, MA 02110-1301, USA. */
64 64
65enum mac_menu_kind { /* Menu ID range */ 65enum mac_menu_kind { /* Menu ID range */
66 MAC_MENU_APPLE, /* 0 (Reserved by Apple) */ 66 MAC_MENU_APPLE, /* 0 (Reserved by Apple) */
67 MAC_MENU_MENU_BAR, /* 1 .. 234 */ 67 MAC_MENU_MENU_BAR, /* 1 .. 233 */
68 MAC_MENU_M_APPLE, /* 234 (== M_APPLE) */
68 MAC_MENU_POPUP, /* 235 */ 69 MAC_MENU_POPUP, /* 235 */
69 MAC_MENU_DRIVER, /* 236 .. 255 (Reserved) */ 70 MAC_MENU_DRIVER, /* 236 .. 255 (Reserved) */
70 MAC_MENU_MENU_BAR_SUB, /* 256 .. 16383 */ 71 MAC_MENU_MENU_BAR_SUB, /* 256 .. 16383 */
@@ -72,7 +73,7 @@ enum mac_menu_kind { /* Menu ID range */
72 MAC_MENU_END /* 32768 */ 73 MAC_MENU_END /* 32768 */
73}; 74};
74 75
75static const int min_menu_id[] = {0, 1, 235, 236, 256, 16384, 32768}; 76static const int min_menu_id[] = {0, 1, 234, 235, 236, 256, 16384, 32768};
76 77
77#define DIALOG_WINDOW_RESOURCE 130 78#define DIALOG_WINDOW_RESOURCE 130
78 79
@@ -158,10 +159,10 @@ typedef struct _widget_value
158#define FALSE 0 159#define FALSE 0
159#endif /* no TRUE */ 160#endif /* no TRUE */
160 161
161Lisp_Object Vmenu_updating_frame;
162
163Lisp_Object Qdebug_on_next_call; 162Lisp_Object Qdebug_on_next_call;
164 163
164extern Lisp_Object Vmenu_updating_frame;
165
165extern Lisp_Object Qmenu_bar, Qmac_apple_event; 166extern Lisp_Object Qmenu_bar, Qmac_apple_event;
166 167
167extern Lisp_Object QCtoggle, QCradio; 168extern Lisp_Object QCtoggle, QCradio;
@@ -196,6 +197,8 @@ static void single_keymap_panes P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
196static void list_of_panes P_ ((Lisp_Object)); 197static void list_of_panes P_ ((Lisp_Object));
197static void list_of_items P_ ((Lisp_Object)); 198static void list_of_items P_ ((Lisp_Object));
198 199
200static void find_and_call_menu_selection P_ ((FRAME_PTR, int, Lisp_Object,
201 void *));
199static int fill_menu P_ ((MenuHandle, widget_value *, enum mac_menu_kind, int)); 202static int fill_menu P_ ((MenuHandle, widget_value *, enum mac_menu_kind, int));
200static void fill_menubar P_ ((widget_value *, int)); 203static void fill_menubar P_ ((widget_value *, int));
201static void dispose_menus P_ ((enum mac_menu_kind, int)); 204static void dispose_menus P_ ((enum mac_menu_kind, int));
@@ -1015,39 +1018,63 @@ x_activate_menubar (f)
1015 FRAME_PTR f; 1018 FRAME_PTR f;
1016{ 1019{
1017 SInt32 menu_choice; 1020 SInt32 menu_choice;
1021 SInt16 menu_id, menu_item;
1018 extern Point saved_menu_event_location; 1022 extern Point saved_menu_event_location;
1019 1023
1020 set_frame_menubar (f, 0, 1); 1024 set_frame_menubar (f, 0, 1);
1021 BLOCK_INPUT; 1025 BLOCK_INPUT;
1022 1026
1023 menu_choice = MenuSelect (saved_menu_event_location); 1027 menu_choice = MenuSelect (saved_menu_event_location);
1024 do_menu_choice (menu_choice); 1028 menu_id = HiWord (menu_choice);
1029 menu_item = LoWord (menu_choice);
1030
1031#if !TARGET_API_MAC_CARBON
1032 if (menu_id == min_menu_id[MAC_MENU_M_APPLE])
1033 do_apple_menu (menu_item);
1034 else
1035#endif
1036 if (menu_id)
1037 {
1038 MenuHandle menu = GetMenuHandle (menu_id);
1039
1040 if (menu)
1041 {
1042 UInt32 refcon;
1043
1044 GetMenuItemRefCon (menu, menu_item, &refcon);
1045 find_and_call_menu_selection (f, f->menu_bar_items_used,
1046 f->menu_bar_vector, (void *) refcon);
1047 }
1048 }
1049
1050 HiliteMenu (0);
1025 1051
1026 UNBLOCK_INPUT; 1052 UNBLOCK_INPUT;
1027} 1053}
1028 1054
1029/* This callback is called from the menu bar pulldown menu 1055/* Find the menu selection and store it in the keyboard buffer.
1030 when the user makes a selection. 1056 F is the frame the menu is on.
1031 Figure out what the user chose 1057 MENU_BAR_ITEMS_USED is the length of VECTOR.
1032 and put the appropriate events into the keyboard buffer. */ 1058 VECTOR is an array of menu events for the whole menu. */
1033 1059
1034void 1060static void
1035menubar_selection_callback (FRAME_PTR f, int client_data) 1061find_and_call_menu_selection (f, menu_bar_items_used, vector, client_data)
1062 FRAME_PTR f;
1063 int menu_bar_items_used;
1064 Lisp_Object vector;
1065 void *client_data;
1036{ 1066{
1037 Lisp_Object prefix, entry; 1067 Lisp_Object prefix, entry;
1038 Lisp_Object vector;
1039 Lisp_Object *subprefix_stack; 1068 Lisp_Object *subprefix_stack;
1040 int submenu_depth = 0; 1069 int submenu_depth = 0;
1041 int i; 1070 int i;
1042 1071
1043 if (!f)
1044 return;
1045 entry = Qnil; 1072 entry = Qnil;
1046 subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object)); 1073 subprefix_stack = (Lisp_Object *) alloca (menu_bar_items_used * sizeof (Lisp_Object));
1047 vector = f->menu_bar_vector;
1048 prefix = Qnil; 1074 prefix = Qnil;
1049 i = 0; 1075 i = 0;
1050 while (i < f->menu_bar_items_used) 1076
1077 while (i < menu_bar_items_used)
1051 { 1078 {
1052 if (EQ (XVECTOR (vector)->contents[i], Qnil)) 1079 if (EQ (XVECTOR (vector)->contents[i], Qnil))
1053 { 1080 {
@@ -1105,13 +1132,11 @@ menubar_selection_callback (FRAME_PTR f, int client_data)
1105 buf.arg = entry; 1132 buf.arg = entry;
1106 kbd_buffer_store_event (&buf); 1133 kbd_buffer_store_event (&buf);
1107 1134
1108 f->output_data.mac->menubar_active = 0;
1109 return; 1135 return;
1110 } 1136 }
1111 i += MENU_ITEMS_ITEM_LENGTH; 1137 i += MENU_ITEMS_ITEM_LENGTH;
1112 } 1138 }
1113 } 1139 }
1114 f->output_data.mac->menubar_active = 0;
1115} 1140}
1116 1141
1117/* Allocate a widget_value, blocking input. */ 1142/* Allocate a widget_value, blocking input. */
@@ -1508,10 +1533,6 @@ set_frame_menubar (f, first_time, deep_p)
1508 int *submenu_start, *submenu_end; 1533 int *submenu_start, *submenu_end;
1509 int *submenu_top_level_items, *submenu_n_panes; 1534 int *submenu_top_level_items, *submenu_n_panes;
1510 1535
1511 /* We must not change the menubar when actually in use. */
1512 if (f->output_data.mac->menubar_active)
1513 return;
1514
1515 XSETFRAME (Vmenu_updating_frame, f); 1536 XSETFRAME (Vmenu_updating_frame, f);
1516 1537
1517 if (! menubar_widget) 1538 if (! menubar_widget)
@@ -2630,11 +2651,6 @@ syms_of_macmenu ()
2630 Qdebug_on_next_call = intern ("debug-on-next-call"); 2651 Qdebug_on_next_call = intern ("debug-on-next-call");
2631 staticpro (&Qdebug_on_next_call); 2652 staticpro (&Qdebug_on_next_call);
2632 2653
2633 DEFVAR_LISP ("menu-updating-frame", &Vmenu_updating_frame,
2634 doc: /* Frame for which we are updating a menu.
2635The enable predicate for a menu command should check this variable. */);
2636 Vmenu_updating_frame = Qnil;
2637
2638 defsubr (&Sx_popup_menu); 2654 defsubr (&Sx_popup_menu);
2639#ifdef HAVE_MENUS 2655#ifdef HAVE_MENUS
2640 defsubr (&Sx_popup_dialog); 2656 defsubr (&Sx_popup_dialog);