diff options
| author | Dmitry Antipov | 2014-07-15 13:59:05 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-07-15 13:59:05 +0400 |
| commit | 60c6e448ebdde76452283c60c2fb0f8b7cfccbe8 (patch) | |
| tree | b8ab0b81dd3345bb25e64efbbfd727c7b518459b /src/xmenu.c | |
| parent | fb32e9f8f3962c63a5edb0a36283ae543601b115 (diff) | |
| download | emacs-60c6e448ebdde76452283c60c2fb0f8b7cfccbe8.tar.gz emacs-60c6e448ebdde76452283c60c2fb0f8b7cfccbe8.zip | |
* lwlib/lwlib.h (toplevel): Use unsigned int for LWLIB_ID.
* src/xmenu.c (toplevel): Use LWLIB_ID for next_menubar_widget_id.
(pop_down_menu) [USE_X_TOOLKIT]: Accept integer arg.
(create_and_show_popup_menu, create_and_show_dialog) [USE_X_TOOLKIT]:
Use record_unwind_protect_int and avoid consing.
(syms_of_xmenu) [USE_X_TOOLKIT]: Declare WIDGET_ID_TICK_START.
Diffstat (limited to 'src/xmenu.c')
| -rw-r--r-- | src/xmenu.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/xmenu.c b/src/xmenu.c index e04a801ef71..eb98125f6bb 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -117,7 +117,7 @@ static int popup_activated_flag; | |||
| 117 | 117 | ||
| 118 | #ifdef USE_X_TOOLKIT | 118 | #ifdef USE_X_TOOLKIT |
| 119 | 119 | ||
| 120 | static int next_menubar_widget_id; | 120 | static LWLIB_ID next_menubar_widget_id; |
| 121 | 121 | ||
| 122 | /* Return the frame whose ->output_data.x->id equals ID, or 0 if none. */ | 122 | /* Return the frame whose ->output_data.x->id equals ID, or 0 if none. */ |
| 123 | 123 | ||
| @@ -1273,8 +1273,8 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv, | |||
| 1273 | /* We need a unique id for each widget handled by the Lucid Widget | 1273 | /* We need a unique id for each widget handled by the Lucid Widget |
| 1274 | library. | 1274 | library. |
| 1275 | 1275 | ||
| 1276 | For the main windows, and popup menus, we use this counter, | 1276 | For the main windows, and popup menus, we use this counter, which we |
| 1277 | which we increment each time after use. This starts from 1<<16. | 1277 | increment each time after use. This starts from WIDGET_ID_TICK_START. |
| 1278 | 1278 | ||
| 1279 | For menu bars, we use numbers starting at 0, counted in | 1279 | For menu bars, we use numbers starting at 0, counted in |
| 1280 | next_menubar_widget_id. */ | 1280 | next_menubar_widget_id. */ |
| @@ -1286,17 +1286,13 @@ popup_selection_callback (Widget widget, LWLIB_ID id, XtPointer client_data) | |||
| 1286 | menu_item_selection = client_data; | 1286 | menu_item_selection = client_data; |
| 1287 | } | 1287 | } |
| 1288 | 1288 | ||
| 1289 | /* ARG is the LWLIB ID of the dialog box, represented | 1289 | /* ID is the LWLIB ID of the dialog box. */ |
| 1290 | as a Lisp object as (HIGHPART . LOWPART). */ | ||
| 1291 | 1290 | ||
| 1292 | static void | 1291 | static void |
| 1293 | pop_down_menu (Lisp_Object arg) | 1292 | pop_down_menu (int id) |
| 1294 | { | 1293 | { |
| 1295 | LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID) | ||
| 1296 | | XINT (XCDR (arg))); | ||
| 1297 | |||
| 1298 | block_input (); | 1294 | block_input (); |
| 1299 | lw_destroy_all_widgets (id); | 1295 | lw_destroy_all_widgets ((LWLIB_ID) id); |
| 1300 | unblock_input (); | 1296 | unblock_input (); |
| 1301 | popup_activated_flag = 0; | 1297 | popup_activated_flag = 0; |
| 1302 | } | 1298 | } |
| @@ -1362,11 +1358,9 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv, | |||
| 1362 | x_activate_timeout_atimer (); | 1358 | x_activate_timeout_atimer (); |
| 1363 | 1359 | ||
| 1364 | { | 1360 | { |
| 1365 | int fact = 4 * sizeof (LWLIB_ID); | ||
| 1366 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); | 1361 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); |
| 1367 | record_unwind_protect (pop_down_menu, | 1362 | |
| 1368 | Fcons (make_number (menu_id >> (fact)), | 1363 | record_unwind_protect_int (pop_down_menu, (int) menu_id); |
| 1369 | make_number (menu_id & ~(-1 << (fact))))); | ||
| 1370 | 1364 | ||
| 1371 | /* Process events that apply to the menu. */ | 1365 | /* Process events that apply to the menu. */ |
| 1372 | popup_get_selection (0, FRAME_DISPLAY_INFO (f), menu_id, 1); | 1366 | popup_get_selection (0, FRAME_DISPLAY_INFO (f), menu_id, 1); |
| @@ -1732,12 +1726,10 @@ create_and_show_dialog (struct frame *f, widget_value *first_wv) | |||
| 1732 | Also handle timers. */ | 1726 | Also handle timers. */ |
| 1733 | { | 1727 | { |
| 1734 | ptrdiff_t count = SPECPDL_INDEX (); | 1728 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1735 | int fact = 4 * sizeof (LWLIB_ID); | ||
| 1736 | 1729 | ||
| 1737 | /* xdialog_show_unwind is responsible for popping the dialog box down. */ | 1730 | /* xdialog_show_unwind is responsible for popping the dialog box down. */ |
| 1738 | record_unwind_protect (pop_down_menu, | 1731 | |
| 1739 | Fcons (make_number (dialog_id >> (fact)), | 1732 | record_unwind_protect_int (pop_down_menu, (int) dialog_id); |
| 1740 | make_number (dialog_id & ~(-1 << (fact))))); | ||
| 1741 | 1733 | ||
| 1742 | popup_get_selection (0, FRAME_DISPLAY_INFO (f), dialog_id, 1); | 1734 | popup_get_selection (0, FRAME_DISPLAY_INFO (f), dialog_id, 1); |
| 1743 | 1735 | ||
| @@ -2330,13 +2322,13 @@ DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_ | |||
| 2330 | void | 2322 | void |
| 2331 | syms_of_xmenu (void) | 2323 | syms_of_xmenu (void) |
| 2332 | { | 2324 | { |
| 2333 | DEFSYM (Qdebug_on_next_call, "debug-on-next-call"); | ||
| 2334 | |||
| 2335 | #ifdef USE_X_TOOLKIT | 2325 | #ifdef USE_X_TOOLKIT |
| 2336 | widget_id_tick = (1<<16); | 2326 | enum { WIDGET_ID_TICK_START = 1 << 16 }; |
| 2327 | widget_id_tick = WIDGET_ID_TICK_START; | ||
| 2337 | next_menubar_widget_id = 1; | 2328 | next_menubar_widget_id = 1; |
| 2338 | #endif | 2329 | #endif |
| 2339 | 2330 | ||
| 2331 | DEFSYM (Qdebug_on_next_call, "debug-on-next-call"); | ||
| 2340 | defsubr (&Smenu_or_popup_active_p); | 2332 | defsubr (&Smenu_or_popup_active_p); |
| 2341 | 2333 | ||
| 2342 | #if defined (USE_GTK) || defined (USE_X_TOOLKIT) | 2334 | #if defined (USE_GTK) || defined (USE_X_TOOLKIT) |