diff src/menubar-x.c @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents ac2d302a0011
children 441bb1e64a06
line wrap: on
line diff
--- a/src/menubar-x.c	Mon Aug 13 08:48:43 2007 +0200
+++ b/src/menubar-x.c	Mon Aug 13 08:49:20 2007 +0200
@@ -82,9 +82,7 @@
 
    We do not have to worry about the pointers to Lisp_String data after
    this function successfully finishes.  lwlib copies all such data with
-   strdup().
-
-   */
+   strdup().  */
 
 static widget_value *
 menu_item_descriptor_to_widget_value_1 (Lisp_Object desc, 
@@ -109,7 +107,7 @@
 
   if (STRINGP (desc))
     {
-      char *string_chars = (char *) string_data (XSTRING (desc));
+      char *string_chars = (char *) XSTRING_DATA (desc);
       wv->type = (separator_string_p (string_chars) ? SEPARATOR_TYPE :
 		  TEXT_TYPE);
 #if 1
@@ -150,8 +148,7 @@
 	  int included_spec = 0;
 	  wv->type = CASCADE_TYPE;
 	  wv->enabled = 1;
-	  wv->name =
-	    (char *) string_data (XSTRING (LISP_GETTEXT (XCAR (desc))));
+	  wv->name = (char *) XSTRING_DATA (LISP_GETTEXT (XCAR (desc)));
 	  desc = Fcdr (desc);
 
 	  while (key = Fcar (desc), KEYWORDP (key))
@@ -205,7 +202,7 @@
 		  incr_wv->call_data = LISP_TO_VOID (incremental_data);
 		  goto menu_item_done;
 		}
-#endif
+#endif /* LWLIB_MENUBARS_LUCID */
 	    }
 	  if (menu_type == POPUP_TYPE && popup_menu_titles && depth == 0)
 	    {
@@ -256,11 +253,8 @@
 		}
 	      else
 		{
-		  next = menu_item_descriptor_to_widget_value_1 (child,
-								 menu_type,
-								 deep_p,
-								 filter_p,
-								 depth + 1);
+		  next = menu_item_descriptor_to_widget_value_1
+		    (child, menu_type, deep_p, filter_p, depth + 1);
 		}
 	      if (! next)
 		continue;
@@ -342,6 +336,7 @@
   struct device *d = get_device_from_display (XtDisplay (widget));
   struct frame *f = x_any_window_to_frame (d, XtWindow (widget));
   Lisp_Object rest = Qnil;
+  Lisp_Object frame;
   int any_changes = 0;
 
   if (!f)
@@ -349,6 +344,10 @@
   if (!f)
     return;
 
+  /* make sure f is the selected frame */
+  XSETFRAME (frame, f);
+  Fselect_frame (frame);
+
   if (client_data)
     {
       /* this is an incremental menu construction callback */
@@ -439,12 +438,20 @@
     data = 0;
   else
     {
+      Lisp_Object old_buffer;
+      int count = specpdl_depth ();
+
+      old_buffer = Fcurrent_buffer ();
+      record_unwind_protect (Fset_buffer, old_buffer);
+      Fset_buffer ( XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer);
       data = menu_item_descriptor_to_widget_value (menubar, MENUBAR_TYPE,
 						   deep_p, 0);
 #ifdef ENERGIZE
       if (data)
 	set_panel_button_sensitivity (f, data);
 #endif
+      Fset_buffer (old_buffer);
+      unbind_to (count, Qnil);
     }
   return data;
 }