changeset 27422:5c5bb4b1ff45

(make_menu_in_widget): Don't add XmNpopdownCallback, add XmNunmapCallback. (xm_unmap_callback): New function. (xm_pull_down_callback): Call pre-activate callback only if parent is the menu bar.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 25 Jan 2000 15:50:53 +0000
parents 34b81c946198
children c3199813ea4d
files lwlib/lwlib-Xm.c
diffstat 1 files changed, 44 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lwlib/lwlib-Xm.c	Tue Jan 25 15:44:52 2000 +0000
+++ b/lwlib/lwlib-Xm.c	Tue Jan 25 15:50:53 2000 +0000
@@ -125,6 +125,7 @@
 static void xm_nosel_callback P_ ((Widget, XtPointer, XtPointer));
 static void xm_pull_down_callback P_ ((Widget, XtPointer, XtPointer));
 static void xm_pop_down_callback P_ ((Widget, XtPointer, XtPointer));
+static void xm_unmap_callback P_ ((Widget, XtPointer, XtPointer));
 void xm_set_keyboard_focus P_ ((Widget, Widget));
 void xm_set_main_areas P_ ((Widget, Widget, Widget));
 static void xm_internal_update_other_instances P_ ((Widget, XtPointer,
@@ -505,11 +506,18 @@
     abort ();
   menubar_p = type == XmMENU_BAR;
 
+#if 0 /* This can't be used in LessTif as of 2000-01-24 because it's
+	 impossible to decide from this plus the cascading callback if a
+	 popup is still posted or not.  When selecting cascade button A,
+	 then B, then clicking on the frame, the sequence of callbacks is
+	 `cascading A', cascading B', `popdown for all cascade buttons in
+	 the menu bar.  */
   /* Add a callback to popups and pulldowns that is called when
      it is made invisible again.  */
   if (!menubar_p)
     XtAddCallback (XtParent (widget), XmNpopdownCallback,
 		   xm_pop_down_callback, (XtPointer)instance);
+#endif
 
   /* Preserve the first KEEP_FIRST_CHILDREN old children.  */
   for (child_index = 0, cur = val; child_index < keep_first_children;
@@ -585,11 +593,15 @@
       else
 	{
 	  menu = XmCreatePulldownMenu (widget, cur->name, NULL, 0);
+
+	  /* XmNpopdownCallback is working strangely under LessTif.
+	     Using XmNunmapCallback is the only way to go there.  */
+	  if (menubar_p)
+	    XtAddCallback (menu, XmNunmapCallback, xm_unmap_callback,
+			   (XtPointer) instance);
+	  
 	  make_menu_in_widget (instance, menu, cur->contents, 0);
-          XtSetArg (al [ac], XmNsubMenuId, menu); ac++;
-          /* Non-zero values don't work reliably in conjunction with
-             Emacs' event loop */
-          XtSetArg (al [ac], XmNmappingDelay, 0); ac++;
+          XtSetArg (al[ac], XmNsubMenuId, menu); ac++;
 	  button = XmCreateCascadeButton (widget, cur->name, al, ac);
 
 	  xm_update_label (instance, button, cur);
@@ -1876,9 +1888,25 @@
      XtPointer closure;
      XtPointer call_data;
 {
-  do_call (widget, closure, pre_activate);
+  Widget parent = XtParent (widget);
+
+  if (XmIsRowColumn (parent))
+    {
+      unsigned char type = 0xff;
+      XtVaGetValues (parent, XmNrowColumnType, &type, NULL);
+      if (type == XmMENU_BAR)
+	do_call (widget, closure, pre_activate);
+    }
 }
 
+
+/* XmNpopdownCallback for MenuShell widgets.  WIDGET is the MenuShell,
+   CLOSURE is a pointer to the widget_instance of the shell, CALL_DATA
+   is always null under LessTif.
+
+   2000-01-23: This callback is called for each cascade button in 
+   a menu, whether or not its submenu is visible.  */
+
 static void
 xm_pop_down_callback (widget, closure, call_data)
      Widget widget;
@@ -1892,6 +1920,17 @@
     do_call (widget, closure, post_activate);
 }
 
+static void
+xm_unmap_callback (widget, closure, call_data)
+     Widget widget;
+     XtPointer closure;
+     XtPointer call_data;
+{
+  widget_instance *instance = (widget_instance *) closure;
+  if (!instance->pop_up_p)
+    do_call (widget, closure, post_activate);
+}
+
 
 /* set the keyboard focus */
 void