summaryrefslogtreecommitdiff
path: root/src/term.c
diff options
context:
space:
mode:
authorDmitry Antipov <dmantipov@yandex.ru>2014-06-04 08:58:31 +0400
committerDmitry Antipov <dmantipov@yandex.ru>2014-06-04 08:58:31 +0400
commitcfd794af4214ae0e5587ab8b1f4e5fcb355a0f12 (patch)
treec45be02b5b568e7534eb91e03ba46899dc42dff5 /src/term.c
parent39ec03147e88bb7a12d2e42edfa0206f6b7d546b (diff)
downloademacs-cfd794af4214ae0e5587ab8b1f4e5fcb355a0f12.tar.gz
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/term.c')
-rw-r--r--src/term.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/term.c b/src/term.c
index 379c94e54a1..aa0be9871c8 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3583,8 +3583,8 @@ tty_menu_new_item_coords (struct frame *f, int which, int *x, int *y)
}
Lisp_Object
-tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
- Lisp_Object title, bool kbd_navigation, const char **error_name)
+tty_menu_show (struct frame *f, int x, int y, int menuflags,
+ Lisp_Object title, const char **error_name)
{
tty_menu *menu;
int pane, selidx, lpane, status;
@@ -3621,6 +3621,10 @@ tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
menu functions pointers to the contents of strings. */
specpdl_count = inhibit_garbage_collection ();
+ /* Avoid crashes if, e.g., another client will connect while we
+ are in a menu. */
+ temporarily_switch_to_single_kboard (f);
+
/* Adjust coordinates to be root-window-relative. */
item_x = x += f->left_pos;
item_y = y += f->top_pos;
@@ -3642,7 +3646,7 @@ tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
pane_string = (NILP (pane_name)
? "" : SSDATA (pane_name));
- if (keymaps && !NILP (prefix))
+ if ((menuflags & MENU_KEYMAPS) && !NILP (prefix))
pane_string++;
lpane = tty_menu_add_pane (menu, pane_string);
@@ -3782,7 +3786,8 @@ tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
specbind (Qoverriding_terminal_local_map,
Fsymbol_value (Qtty_menu_navigation_map));
status = tty_menu_activate (menu, &pane, &selidx, x, y, &datap,
- tty_menu_help_callback, kbd_navigation);
+ tty_menu_help_callback,
+ menuflags & MENU_KBD_NAVIGATION);
entry = pane_prefix = Qnil;
switch (status)
@@ -3808,7 +3813,7 @@ tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
{
entry
= AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
- if (keymaps != 0)
+ if (menuflags & MENU_KEYMAPS)
{
entry = Fcons (entry, Qnil);
if (!NILP (pane_prefix))
@@ -3841,7 +3846,7 @@ tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
Ftop_level ();
/* Make "Cancel" equivalent to C-g unless FOR_CLICK (which means
the menu was invoked with a mouse event as POSITION). */
- if (! for_click)
+ if (!(menuflags & MENU_FOR_CLICK))
Fsignal (Qquit, Qnil);
break;
}
@@ -3922,6 +3927,7 @@ clear_tty_hooks (struct terminal *terminal)
terminal->frame_rehighlight_hook = 0;
terminal->frame_raise_lower_hook = 0;
terminal->fullscreen_hook = 0;
+ terminal->menu_show_hook = 0;
terminal->set_vertical_scroll_bar_hook = 0;
terminal->condemn_scroll_bars_hook = 0;
terminal->redeem_scroll_bar_hook = 0;
@@ -3953,6 +3959,7 @@ set_tty_hooks (struct terminal *terminal)
terminal->reset_terminal_modes_hook = &tty_reset_terminal_modes;
terminal->set_terminal_modes_hook = &tty_set_terminal_modes;
terminal->update_end_hook = &tty_update_end;
+ terminal->menu_show_hook = &tty_menu_show;
terminal->set_terminal_window_hook = &tty_set_terminal_window;
terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */
terminal->delete_frame_hook = &tty_free_frame_resources;