From: Gerd Moellmann Date: Tue, 25 Jan 2000 15:50:53 +0000 (+0000) Subject: (make_menu_in_widget): Don't add XmNpopdownCallback, X-Git-Tag: emacs-pretest-21.0.90~5266 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=640438b0567da9f61128ca67739ebac6be014f70;p=emacs.git (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. --- diff --git a/lwlib/lwlib-Xm.c b/lwlib/lwlib-Xm.c index 266d1e0aab4..49c32293ef5 100644 --- a/lwlib/lwlib-Xm.c +++ b/lwlib/lwlib-Xm.c @@ -125,6 +125,7 @@ static void xm_generic_callback P_ ((Widget, XtPointer, XtPointer)); 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 @@ make_menu_in_widget (instance, widget, val, keep_first_children) 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 @@ make_menu_in_widget (instance, widget, val, keep_first_children) 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 @@ xm_pull_down_callback (widget, closure, call_data) 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 @@ xm_pop_down_callback (widget, closure, call_data) 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