XEmacs 21.2.26 "Millenium".
[chise/xemacs-chise.git.1] / src / menubar-x.c
index 61258db..c15e271 100644 (file)
@@ -120,7 +120,7 @@ menu_item_descriptor_to_widget_value_1 (Lisp_Object desc,
        }
       else
        {
-         wv->name = string_chars;
+         wv->name = xstrdup (string_chars);
          wv->enabled = 1;
          /* dverna Dec. 98: command_builder_operate_menu_accelerator will
             manipulate the accel as a Lisp_Object if the widget has a name.
@@ -131,7 +131,8 @@ menu_item_descriptor_to_widget_value_1 (Lisp_Object desc,
     }
   else if (VECTORP (desc))
     {
-      if (!button_item_to_widget_value (desc, wv, 1,
+      Lisp_Object gui_item = gui_parse_item_keywords (desc);
+      if (!button_item_to_widget_value (gui_item, wv, 1,
                                        (menu_type == MENUBAR_TYPE
                                         && depth <= 1)))
        {
@@ -156,8 +157,9 @@ menu_item_descriptor_to_widget_value_1 (Lisp_Object desc,
          wv->type = CASCADE_TYPE;
          wv->enabled = 1;
          wv->name = (char *) XSTRING_DATA (LISP_GETTEXT (XCAR (desc)));
+         wv->name = xstrdup (wv->name);
 
-         accel = menu_name_to_accelerator (wv->name);
+         accel = gui_name_accelerator (LISP_GETTEXT (XCAR (desc)));
          wv->accel = LISP_TO_VOID (accel);
 
          desc = Fcdr (desc);
@@ -225,6 +227,7 @@ menu_item_descriptor_to_widget_value_1 (Lisp_Object desc,
                  incr_wv->type = INCREMENTAL_TYPE;
                  incr_wv->enabled = 1;
                  incr_wv->name = wv->name;
+                 incr_wv->name = xstrdup (wv->name);
                  /* This is automatically GC protected through
                     the call to lw_map_widget_values(); no need
                     to worry. */
@@ -241,7 +244,7 @@ menu_item_descriptor_to_widget_value_1 (Lisp_Object desc,
              widget_value *title_wv = xmalloc_widget_value ();
              widget_value *sep_wv = xmalloc_widget_value ();
              title_wv->type = TEXT_TYPE;
-             title_wv->name = wv->name;
+             title_wv->name = xstrdup (wv->name);
              title_wv->enabled = 1;
              title_wv->next = sep_wv;
              sep_wv->type = SEPARATOR_TYPE;
@@ -257,7 +260,7 @@ menu_item_descriptor_to_widget_value_1 (Lisp_Object desc,
              widget_value *dummy;
              /* Add a fake entry so the menus show up */
              wv->contents = dummy = xmalloc_widget_value ();
-             dummy->name = "(inactive)";
+             dummy->name = xstrdup ("(inactive)");
              dummy->accel = LISP_TO_VOID (Qnil);
              dummy->enabled = 0;
              dummy->selected = 0;
@@ -272,7 +275,7 @@ menu_item_descriptor_to_widget_value_1 (Lisp_Object desc,
        }
       else if (menubar_root_p)
        {
-         wv->name = (char *) "menubar";
+         wv->name = xstrdup ("menubar");
          wv->type = CASCADE_TYPE; /* Well, nothing else seems to fit and
                                      this is ignored anyway...  */
        }
@@ -468,7 +471,7 @@ pre_activate_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
          wv->accel = LISP_TO_VOID (Qnil);
          wv->contents = xmalloc_widget_value ();
          wv->contents->type = TEXT_TYPE;
-         wv->contents->name = (char *) "No menu";
+         wv->contents->name = xstrdup ("No menu");
          wv->contents->next = NULL;
          wv->contents->accel = LISP_TO_VOID (Qnil);
        }
@@ -674,7 +677,6 @@ make_dummy_xbutton_event (XEvent *dummy,
   if (eev)
     {
       Position shellx, shelly, framex, framey;
-      Widget shell = XtParent (daddy);
       Arg al [2];
       btn->time = eev->timestamp;
       btn->button = eev->event.button.button;
@@ -682,9 +684,16 @@ make_dummy_xbutton_event (XEvent *dummy,
       btn->subwindow = (Window) NULL;
       btn->x = eev->event.button.x;
       btn->y = eev->event.button.y;
-      XtSetArg (al [0], XtNx, &shellx);
-      XtSetArg (al [1], XtNy, &shelly);
-      XtGetValues (shell, al, 2);
+      shellx = shelly = 0;
+#ifndef HAVE_WMCOMMAND
+      {
+       Widget shell = XtParent (daddy);
+
+       XtSetArg (al [0], XtNx, &shellx);
+       XtSetArg (al [1], XtNy, &shelly);
+       XtGetValues (shell, al, 2);
+      }
+#endif      
       XtSetArg (al [0], XtNx, &framex);
       XtSetArg (al [1], XtNy, &framey);
       XtGetValues (daddy, al, 2);
@@ -854,9 +863,15 @@ console_type_create_menubar_x (void)
 }
 
 void
-vars_of_menubar_x (void)
+reinit_vars_of_menubar_x (void)
 {
   last_popup_menu_selection_callback_id = (LWLIB_ID) -1;
+}
+
+void
+vars_of_menubar_x (void)
+{
+  reinit_vars_of_menubar_x ();
 
 #if defined (LWLIB_MENUBARS_LUCID)
   Fprovide (intern ("lucid-menubars"));