diff options
| author | Dmitry Antipov <dmantipov@yandex.ru> | 2014-07-15 13:59:05 +0400 |
|---|---|---|
| committer | Dmitry Antipov <dmantipov@yandex.ru> | 2014-07-15 13:59:05 +0400 |
| commit | 60c6e448ebdde76452283c60c2fb0f8b7cfccbe8 (patch) | |
| tree | b8ab0b81dd3345bb25e64efbbfd727c7b518459b /src/xmenu.c | |
| parent | fb32e9f8f3962c63a5edb0a36283ae543601b115 (diff) | |
| download | emacs-60c6e448ebdde76452283c60c2fb0f8b7cfccbe8.tar.gz | |
* 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; #ifdef USE_X_TOOLKIT -static int next_menubar_widget_id; +static LWLIB_ID next_menubar_widget_id; /* Return the frame whose ->output_data.x->id equals ID, or 0 if none. */ @@ -1273,8 +1273,8 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv, /* We need a unique id for each widget handled by the Lucid Widget library. - For the main windows, and popup menus, we use this counter, - which we increment each time after use. This starts from 1<<16. + For the main windows, and popup menus, we use this counter, which we + increment each time after use. This starts from WIDGET_ID_TICK_START. For menu bars, we use numbers starting at 0, counted in next_menubar_widget_id. */ @@ -1286,17 +1286,13 @@ popup_selection_callback (Widget widget, LWLIB_ID id, XtPointer client_data) menu_item_selection = client_data; } -/* ARG is the LWLIB ID of the dialog box, represented - as a Lisp object as (HIGHPART . LOWPART). */ +/* ID is the LWLIB ID of the dialog box. */ static void -pop_down_menu (Lisp_Object arg) +pop_down_menu (int id) { - LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID) - | XINT (XCDR (arg))); - block_input (); - lw_destroy_all_widgets (id); + lw_destroy_all_widgets ((LWLIB_ID) id); unblock_input (); popup_activated_flag = 0; } @@ -1362,11 +1358,9 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv, x_activate_timeout_atimer (); { - int fact = 4 * sizeof (LWLIB_ID); ptrdiff_t specpdl_count = SPECPDL_INDEX (); - record_unwind_protect (pop_down_menu, - Fcons (make_number (menu_id >> (fact)), - make_number (menu_id & ~(-1 << (fact))))); + + record_unwind_protect_int (pop_down_menu, (int) menu_id); /* Process events that apply to the menu. */ 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) Also handle timers. */ { ptrdiff_t count = SPECPDL_INDEX (); - int fact = 4 * sizeof (LWLIB_ID); /* xdialog_show_unwind is responsible for popping the dialog box down. */ - record_unwind_protect (pop_down_menu, - Fcons (make_number (dialog_id >> (fact)), - make_number (dialog_id & ~(-1 << (fact))))); + + record_unwind_protect_int (pop_down_menu, (int) dialog_id); popup_get_selection (0, FRAME_DISPLAY_INFO (f), dialog_id, 1); @@ -2330,13 +2322,13 @@ DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_ void syms_of_xmenu (void) { - DEFSYM (Qdebug_on_next_call, "debug-on-next-call"); - #ifdef USE_X_TOOLKIT - widget_id_tick = (1<<16); + enum { WIDGET_ID_TICK_START = 1 << 16 }; + widget_id_tick = WIDGET_ID_TICK_START; next_menubar_widget_id = 1; #endif + DEFSYM (Qdebug_on_next_call, "debug-on-next-call"); defsubr (&Smenu_or_popup_active_p); #if defined (USE_GTK) || defined (USE_X_TOOLKIT) |
