aboutsummaryrefslogtreecommitdiffstats
path: root/src/xmenu.c
diff options
context:
space:
mode:
authorDmitry Antipov2014-06-04 08:58:31 +0400
committerDmitry Antipov2014-06-04 08:58:31 +0400
commitcfd794af4214ae0e5587ab8b1f4e5fcb355a0f12 (patch)
treec45be02b5b568e7534eb91e03ba46899dc42dff5 /src/xmenu.c
parent39ec03147e88bb7a12d2e42edfa0206f6b7d546b (diff)
downloademacs-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/xmenu.c')
-rw-r--r--src/xmenu.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/xmenu.c b/src/xmenu.c
index c167eaa8159..18793457dad 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -179,7 +179,7 @@ mouse_position_for_popup (struct frame *f, int *x, int *y)
179 179
180 unblock_input (); 180 unblock_input ();
181 181
182 /* xmenu_show expects window coordinates, not root window 182 /* x_menu_show expects window coordinates, not root window
183 coordinates. Translate. */ 183 coordinates. Translate. */
184 *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f); 184 *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
185 *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f); 185 *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
@@ -1158,16 +1158,17 @@ free_frame_menubar (struct frame *f)
1158 1158
1159#endif /* USE_X_TOOLKIT || USE_GTK */ 1159#endif /* USE_X_TOOLKIT || USE_GTK */
1160 1160
1161/* xmenu_show actually displays a menu using the panes and items in menu_items 1161/* x_menu_show actually displays a menu using the panes and items in menu_items
1162 and returns the value selected from it. 1162 and returns the value selected from it.
1163 There are two versions of xmenu_show, one for Xt and one for Xlib. 1163 There are two versions of x_menu_show, one for Xt and one for Xlib.
1164 Both assume input is blocked by the caller. */ 1164 Both assume input is blocked by the caller. */
1165 1165
1166/* F is the frame the menu is for. 1166/* F is the frame the menu is for.
1167 X and Y are the frame-relative specified position, 1167 X and Y are the frame-relative specified position,
1168 relative to the inside upper left corner of the frame F. 1168 relative to the inside upper left corner of the frame F.
1169 FOR_CLICK is true if this menu was invoked for a mouse click. 1169 Bitfield MENUFLAGS bits are:
1170 KEYMAPS is true if this menu was specified with keymaps; 1170 MENU_FOR_CLICK is set if this menu was invoked for a mouse click.
1171 MENU_KEYMAPS is set if this menu was specified with keymaps;
1171 in that case, we return a list containing the chosen item's value 1172 in that case, we return a list containing the chosen item's value
1172 and perhaps also the pane's prefix. 1173 and perhaps also the pane's prefix.
1173 TITLE is the specified menu title. 1174 TITLE is the specified menu title.
@@ -1433,8 +1434,8 @@ cleanup_widget_value_tree (void *arg)
1433} 1434}
1434 1435
1435Lisp_Object 1436Lisp_Object
1436xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, 1437x_menu_show (struct frame *f, int x, int y, int menuflags,
1437 Lisp_Object title, const char **error_name) 1438 Lisp_Object title, const char **error_name)
1438{ 1439{
1439 int i; 1440 int i;
1440 widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; 1441 widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0;
@@ -1519,14 +1520,14 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
1519 /* If the pane has a meaningful name, 1520 /* If the pane has a meaningful name,
1520 make the pane a top-level menu item 1521 make the pane a top-level menu item
1521 with its items as a submenu beneath it. */ 1522 with its items as a submenu beneath it. */
1522 if (!keymaps && strcmp (pane_string, "")) 1523 if (!(menuflags & MENU_KEYMAPS) && strcmp (pane_string, ""))
1523 { 1524 {
1524 wv = make_widget_value (pane_string, NULL, true, Qnil); 1525 wv = make_widget_value (pane_string, NULL, true, Qnil);
1525 if (save_wv) 1526 if (save_wv)
1526 save_wv->next = wv; 1527 save_wv->next = wv;
1527 else 1528 else
1528 first_wv->contents = wv; 1529 first_wv->contents = wv;
1529 if (keymaps && !NILP (prefix)) 1530 if ((menuflags & MENU_KEYMAPS) && !NILP (prefix))
1530 wv->name++; 1531 wv->name++;
1531 wv->button_type = BUTTON_TYPE_NONE; 1532 wv->button_type = BUTTON_TYPE_NONE;
1532 save_wv = wv; 1533 save_wv = wv;
@@ -1625,7 +1626,8 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
1625 record_unwind_protect_ptr (cleanup_widget_value_tree, first_wv); 1626 record_unwind_protect_ptr (cleanup_widget_value_tree, first_wv);
1626 1627
1627 /* Actually create and show the menu until popped down. */ 1628 /* Actually create and show the menu until popped down. */
1628 create_and_show_popup_menu (f, first_wv, x, y, for_click); 1629 create_and_show_popup_menu (f, first_wv, x, y,
1630 menuflags & MENU_FOR_CLICK);
1629 1631
1630 unbind_to (specpdl_count, Qnil); 1632 unbind_to (specpdl_count, Qnil);
1631 1633
@@ -1666,7 +1668,7 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
1666 = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE); 1668 = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
1667 if (menu_item_selection == aref_addr (menu_items, i)) 1669 if (menu_item_selection == aref_addr (menu_items, i))
1668 { 1670 {
1669 if (keymaps) 1671 if (menuflags & MENU_KEYMAPS)
1670 { 1672 {
1671 int j; 1673 int j;
1672 1674
@@ -1684,7 +1686,7 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
1684 } 1686 }
1685 } 1687 }
1686 } 1688 }
1687 else if (!for_click) 1689 else if (!(menuflags & MENU_FOR_CLICK))
1688 { 1690 {
1689 unblock_input (); 1691 unblock_input ();
1690 /* Make "Cancel" equivalent to C-g. */ 1692 /* Make "Cancel" equivalent to C-g. */
@@ -2022,7 +2024,7 @@ menu_help_callback (char const *help_string, int pane, int item)
2022 if (EQ (first_item[0], Qt)) 2024 if (EQ (first_item[0], Qt))
2023 pane_name = first_item[MENU_ITEMS_PANE_NAME]; 2025 pane_name = first_item[MENU_ITEMS_PANE_NAME];
2024 else if (EQ (first_item[0], Qquote)) 2026 else if (EQ (first_item[0], Qquote))
2025 /* This shouldn't happen, see xmenu_show. */ 2027 /* This shouldn't happen, see x_menu_show. */
2026 pane_name = empty_unibyte_string; 2028 pane_name = empty_unibyte_string;
2027 else 2029 else
2028 pane_name = first_item[MENU_ITEMS_ITEM_NAME]; 2030 pane_name = first_item[MENU_ITEMS_ITEM_NAME];
@@ -2064,8 +2066,8 @@ pop_down_menu (Lisp_Object arg)
2064 2066
2065 2067
2066Lisp_Object 2068Lisp_Object
2067xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, 2069x_menu_show (struct frame *f, int x, int y, int menuflags,
2068 Lisp_Object title, const char **error_name) 2070 Lisp_Object title, const char **error_name)
2069{ 2071{
2070 Window root; 2072 Window root;
2071 XMenu *menu; 2073 XMenu *menu;
@@ -2140,7 +2142,7 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
2140 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); 2142 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
2141 pane_string = (NILP (pane_name) 2143 pane_string = (NILP (pane_name)
2142 ? "" : SSDATA (pane_name)); 2144 ? "" : SSDATA (pane_name));
2143 if (keymaps && !NILP (prefix)) 2145 if ((menuflags & MENU_KEYMAPS) && !NILP (prefix))
2144 pane_string++; 2146 pane_string++;
2145 2147
2146 lpane = XMenuAddPane (FRAME_X_DISPLAY (f), menu, pane_string, TRUE); 2148 lpane = XMenuAddPane (FRAME_X_DISPLAY (f), menu, pane_string, TRUE);
@@ -2263,7 +2265,7 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
2263 if (ulx < 0) x -= ulx; 2265 if (ulx < 0) x -= ulx;
2264 if (uly < 0) y -= uly; 2266 if (uly < 0) y -= uly;
2265 2267
2266 if (! for_click) 2268 if (!(menuflags & MENU_FOR_CLICK))
2267 { 2269 {
2268 /* If position was not given by a mouse click, adjust so upper left 2270 /* If position was not given by a mouse click, adjust so upper left
2269 corner of the menu as a whole ends up at given coordinates. This 2271 corner of the menu as a whole ends up at given coordinates. This
@@ -2317,7 +2319,7 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
2317 { 2319 {
2318 entry 2320 entry
2319 = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE); 2321 = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
2320 if (keymaps) 2322 if (menuflags & MENU_KEYMAPS)
2321 { 2323 {
2322 entry = list1 (entry); 2324 entry = list1 (entry);
2323 if (!NILP (pane_prefix)) 2325 if (!NILP (pane_prefix))
@@ -2339,7 +2341,7 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
2339 case XM_NO_SELECT: 2341 case XM_NO_SELECT:
2340 /* Make "Cancel" equivalent to C-g unless FOR_CLICK (which means 2342 /* Make "Cancel" equivalent to C-g unless FOR_CLICK (which means
2341 the menu was invoked with a mouse event as POSITION). */ 2343 the menu was invoked with a mouse event as POSITION). */
2342 if (! for_click) 2344 if (!(menuflags & MENU_FOR_CLICK))
2343 { 2345 {
2344 unblock_input (); 2346 unblock_input ();
2345 Fsignal (Qquit, Qnil); 2347 Fsignal (Qquit, Qnil);