diff options
| author | Dmitry Antipov | 2014-06-04 08:58:31 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-06-04 08:58:31 +0400 |
| commit | cfd794af4214ae0e5587ab8b1f4e5fcb355a0f12 (patch) | |
| tree | c45be02b5b568e7534eb91e03ba46899dc42dff5 /src/menu.c | |
| parent | 39ec03147e88bb7a12d2e42edfa0206f6b7d546b (diff) | |
| download | emacs-cfd794af4214ae0e5587ab8b1f4e5fcb355a0f12.tar.gz emacs-cfd794af4214ae0e5587ab8b1f4e5fcb355a0f12.zip | |
Use terminal-specific hooks to display menus.
* termhooks.h (struct terminal): New field menu_show_hook.
* menu.h (<anonymous enum>): Bit flags for menu hooks.
(x_menu_show, w32_menu_show, ns_menu_show, tty_menu_show):
Adjust prototypes.
* menu.c (Fx_popup_menu): Use bit flags and menu_show_hook.
* nsmenu.m (ns_menu_show):
* w32menu.c (w32_menu_show):
* xmenu.c (x_menu_show):
* term.c (tty_menu_show): Adjust to use bit flags.
(set_tty_hooks): Set menu_show_hook.
* xterm.c (x_create_terminal):
* nsterm.m (ns_create_terminal):
* msdos.c (initialize_msdos_display):
* w32term.c (w32_create_terminal): Likewise.
Diffstat (limited to 'src/menu.c')
| -rw-r--r-- | src/menu.c | 53 |
1 files changed, 10 insertions, 43 deletions
diff --git a/src/menu.c b/src/menu.c index 0cd886f55d1..b65401c6f4f 100644 --- a/src/menu.c +++ b/src/menu.c | |||
| @@ -1161,9 +1161,7 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1161 | Lisp_Object selection = Qnil; | 1161 | Lisp_Object selection = Qnil; |
| 1162 | struct frame *f = NULL; | 1162 | struct frame *f = NULL; |
| 1163 | Lisp_Object x, y, window; | 1163 | Lisp_Object x, y, window; |
| 1164 | bool keymaps = 0; | 1164 | int menuflags = 0; |
| 1165 | bool for_click = 0; | ||
| 1166 | bool kbd_menu_navigation = 0; | ||
| 1167 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); | 1165 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); |
| 1168 | struct gcpro gcpro1; | 1166 | struct gcpro gcpro1; |
| 1169 | 1167 | ||
| @@ -1193,12 +1191,12 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1193 | } | 1191 | } |
| 1194 | else | 1192 | else |
| 1195 | { | 1193 | { |
| 1196 | for_click = 1; | 1194 | menuflags |= MENU_FOR_CLICK; |
| 1197 | tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ | 1195 | tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ |
| 1198 | window = Fcar (tem); /* POSN_WINDOW (tem) */ | 1196 | window = Fcar (tem); /* POSN_WINDOW (tem) */ |
| 1199 | tem2 = Fcar (Fcdr (tem)); /* POSN_POSN (tem) */ | 1197 | tem2 = Fcar (Fcdr (tem)); /* POSN_POSN (tem) */ |
| 1200 | /* The kbd_menu_navigation flag is set when the menu was | 1198 | /* The MENU_KBD_NAVIGATION field is set when the menu |
| 1201 | invoked by F10, which probably means they have no | 1199 | was invoked by F10, which probably means they have no |
| 1202 | mouse. In that case, we let them switch between | 1200 | mouse. In that case, we let them switch between |
| 1203 | top-level menu-bar menus by using C-f/C-b and | 1201 | top-level menu-bar menus by using C-f/C-b and |
| 1204 | horizontal arrow keys, since they cannot click the | 1202 | horizontal arrow keys, since they cannot click the |
| @@ -1211,7 +1209,7 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1211 | if (!EQ (POSN_POSN (last_nonmenu_event), | 1209 | if (!EQ (POSN_POSN (last_nonmenu_event), |
| 1212 | POSN_POSN (position)) | 1210 | POSN_POSN (position)) |
| 1213 | && CONSP (tem2) && EQ (Fcar (tem2), Qmenu_bar)) | 1211 | && CONSP (tem2) && EQ (Fcar (tem2), Qmenu_bar)) |
| 1214 | kbd_menu_navigation = 1; | 1212 | menuflags |= MENU_KBD_NAVIGATION; |
| 1215 | tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */ | 1213 | tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */ |
| 1216 | x = Fcar (tem); | 1214 | x = Fcar (tem); |
| 1217 | y = Fcdr (tem); | 1215 | y = Fcdr (tem); |
| @@ -1340,7 +1338,7 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1340 | if (!NILP (prompt) && menu_items_n_panes >= 0) | 1338 | if (!NILP (prompt) && menu_items_n_panes >= 0) |
| 1341 | ASET (menu_items, MENU_ITEMS_PANE_NAME, prompt); | 1339 | ASET (menu_items, MENU_ITEMS_PANE_NAME, prompt); |
| 1342 | 1340 | ||
| 1343 | keymaps = 1; | 1341 | menuflags |= MENU_KEYMAPS; |
| 1344 | } | 1342 | } |
| 1345 | else if (CONSP (menu) && KEYMAPP (XCAR (menu))) | 1343 | else if (CONSP (menu) && KEYMAPP (XCAR (menu))) |
| 1346 | { | 1344 | { |
| @@ -1373,7 +1371,7 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1373 | if (!NILP (title) && menu_items_n_panes >= 0) | 1371 | if (!NILP (title) && menu_items_n_panes >= 0) |
| 1374 | ASET (menu_items, MENU_ITEMS_PANE_NAME, title); | 1372 | ASET (menu_items, MENU_ITEMS_PANE_NAME, title); |
| 1375 | 1373 | ||
| 1376 | keymaps = 1; | 1374 | menuflags |= MENU_KEYMAPS; |
| 1377 | 1375 | ||
| 1378 | SAFE_FREE (); | 1376 | SAFE_FREE (); |
| 1379 | } | 1377 | } |
| @@ -1385,7 +1383,7 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1385 | 1383 | ||
| 1386 | list_of_panes (Fcdr (menu)); | 1384 | list_of_panes (Fcdr (menu)); |
| 1387 | 1385 | ||
| 1388 | keymaps = 0; | 1386 | menuflags &= ~MENU_KEYMAPS; |
| 1389 | } | 1387 | } |
| 1390 | 1388 | ||
| 1391 | unbind_to (specpdl_count, Qnil); | 1389 | unbind_to (specpdl_count, Qnil); |
| @@ -1416,39 +1414,8 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1416 | #endif | 1414 | #endif |
| 1417 | 1415 | ||
| 1418 | /* Display them in a menu. */ | 1416 | /* Display them in a menu. */ |
| 1419 | 1417 | selection = FRAME_TERMINAL (f)->menu_show_hook (f, xpos, ypos, menuflags, | |
| 1420 | /* FIXME: Use a terminal hook! */ | 1418 | title, &error_name); |
| 1421 | #if defined HAVE_NTGUI | ||
| 1422 | if (FRAME_W32_P (f)) | ||
| 1423 | selection = w32_menu_show (f, xpos, ypos, for_click, | ||
| 1424 | keymaps, title, &error_name); | ||
| 1425 | else | ||
| 1426 | #endif | ||
| 1427 | #if defined HAVE_NS | ||
| 1428 | if (FRAME_NS_P (f)) | ||
| 1429 | selection = ns_menu_show (f, xpos, ypos, for_click, | ||
| 1430 | keymaps, title, &error_name); | ||
| 1431 | else | ||
| 1432 | #endif | ||
| 1433 | #if (defined (HAVE_X_WINDOWS) || defined (MSDOS)) | ||
| 1434 | if (FRAME_X_P (f) || FRAME_MSDOS_P (f)) | ||
| 1435 | selection = xmenu_show (f, xpos, ypos, for_click, | ||
| 1436 | keymaps, title, &error_name); | ||
| 1437 | else | ||
| 1438 | #endif | ||
| 1439 | #ifndef MSDOS | ||
| 1440 | if (FRAME_TERMCAP_P (f)) | ||
| 1441 | { | ||
| 1442 | ptrdiff_t count1 = SPECPDL_INDEX (); | ||
| 1443 | |||
| 1444 | /* Avoid crashes if, e.g., another client will connect while we | ||
| 1445 | are in a menu. */ | ||
| 1446 | temporarily_switch_to_single_kboard (f); | ||
| 1447 | selection = tty_menu_show (f, xpos, ypos, for_click, keymaps, title, | ||
| 1448 | kbd_menu_navigation, &error_name); | ||
| 1449 | unbind_to (count1, Qnil); | ||
| 1450 | } | ||
| 1451 | #endif | ||
| 1452 | 1419 | ||
| 1453 | #ifdef HAVE_NS | 1420 | #ifdef HAVE_NS |
| 1454 | unbind_to (specpdl_count, Qnil); | 1421 | unbind_to (specpdl_count, Qnil); |