]> code.delx.au - gnu-emacs/commitdiff
* lwlib/lwlib.h (toplevel): Use unsigned int for LWLIB_ID.
authorDmitry Antipov <dmantipov@yandex.ru>
Tue, 15 Jul 2014 09:59:05 +0000 (13:59 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Tue, 15 Jul 2014 09:59:05 +0000 (13:59 +0400)
* 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.

lwlib/ChangeLog
lwlib/lwlib.h
src/ChangeLog
src/xmenu.c

index 20ace660739f8e08b1febd98f86c97b2777d4084..11ee10edac2d43385372c4b1ea8a33735e0053cf 100644 (file)
@@ -1,3 +1,7 @@
+2014-07-15  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * lwlib.h (toplevel): Use unsigned int for LWLIB_ID.
+
 2014-06-28  Glenn Morris  <rgm@gnu.org>
 
        * Makefile.in: Use gcc auto-dependency information.
index 46e2d7a4891cbb10c0486d4cd0a4263ac41d2604..7d87facb90354feb8b404f37a5557035da216a43 100644 (file)
@@ -44,7 +44,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "lwlib-widget.h"
 
-typedef unsigned long LWLIB_ID;
+typedef unsigned int LWLIB_ID;
 
 /* Menu separator types.  */
 
index ee600602895b6e7628c943629bd827ce539e9ba0..a640b970b67f39e5c8ade898845b39bc1503e689 100644 (file)
@@ -1,3 +1,11 @@
+2014-07-15  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * 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.
+
 2014-07-14  Paul Eggert  <eggert@cs.ucla.edu>
 
        Use binary-io module, O_BINARY, and "b" flag (Bug#18006).
index e04a801ef718df4551635fac76425d86f02fb569..eb98125f6bb7f4b80a3f14cd57f6dcded90781ef 100644 (file)
@@ -117,7 +117,7 @@ static int popup_activated_flag;
 \f
 #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)