diff options
Diffstat (limited to 'lwlib/lwlib-Xm.c')
-rw-r--r-- | lwlib/lwlib-Xm.c | 84 |
1 files changed, 52 insertions, 32 deletions
diff --git a/lwlib/lwlib-Xm.c b/lwlib/lwlib-Xm.c index 2ac543cad7c..52ea304f717 100644 --- a/lwlib/lwlib-Xm.c +++ b/lwlib/lwlib-Xm.c @@ -1,6 +1,6 @@ /* The lwlib interface to Motif widgets. -Copyright (C) 1994-1997, 1999-2017 Free Software Foundation, Inc. +Copyright (C) 1994-1997, 1999-2022 Free Software Foundation, Inc. Copyright (C) 1992 Lucid, Inc. This file is part of the Lucid Widget Library. @@ -115,6 +115,7 @@ static void xm_generic_callback (Widget, XtPointer, XtPointer); static void xm_nosel_callback (Widget, XtPointer, XtPointer); static void xm_pull_down_callback (Widget, XtPointer, XtPointer); static void xm_pop_down_callback (Widget, XtPointer, XtPointer); +static void xm_pop_up_callback (Widget, XtPointer, XtPointer); static void xm_internal_update_other_instances (Widget, XtPointer, XtPointer); static void xm_arm_callback (Widget, XtPointer, XtPointer); @@ -269,28 +270,23 @@ static void xm_arm_callback (Widget w, XtPointer client_data, XtPointer call_data) { XmPushButtonCallbackStruct *cbs = (XmPushButtonCallbackStruct *) call_data; - widget_value *wv = (widget_value *) client_data; - widget_instance *instance; - - /* Get the id of the menu bar or popup menu this widget is in. */ - while (w != NULL) - { - if (XmIsRowColumn (w)) - { - unsigned char type = 0xff; - - XtVaGetValues (w, XmNrowColumnType, &type, NULL); - if (type == XmMENU_BAR || type == XmMENU_POPUP) - break; - } + widget_value *wv = NULL; + widget_instance *instance = client_data; + XtPointer user_data; + Arg al[2]; + int ac = 0; - w = XtParent (w); - } + XtSetArg (al[ac], XmNuserData, &user_data); ac++; + XtGetValues (w, al, ac); + wv = user_data; - if (w != NULL) + if (wv != NULL) { - instance = lw_get_widget_instance (w); - if (instance && instance->info->highlight_cb) + if (instance->info->highlight_cb + && (cbs->reason == XmCR_DISARM + || (cbs->event + && (cbs->event->type == EnterNotify + || cbs->event->type == MotionNotify)))) { call_data = cbs->reason == XmCR_DISARM ? NULL : wv; instance->info->highlight_cb (w, instance->info->id, call_data); @@ -501,9 +497,11 @@ make_menu_in_widget (widget_instance* instance, ; children = (Widget*)(void*)XtMalloc (num_children * sizeof (Widget)); +#ifndef LESSTIF_VERSION /* WIDGET should be a RowColumn. */ if (!XmIsRowColumn (widget)) emacs_abort (); +#endif /* Determine whether WIDGET is a menu bar. */ type = -1; @@ -516,8 +514,12 @@ make_menu_in_widget (widget_instance* instance, /* 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); + { + XtAddCallback (XtParent (widget), XmNpopdownCallback, + xm_pop_down_callback, (XtPointer) instance); + XtAddCallback (XtParent (widget), XmNpopupCallback, + xm_pop_up_callback, (XtPointer) instance); + } /* Preserve the first KEEP_FIRST_CHILDREN old children. */ for (child_index = 0, cur = val; child_index < keep_first_children; @@ -537,7 +539,7 @@ make_menu_in_widget (widget_instance* instance, ac = 0; XtSetArg (al[ac], XmNsensitive, cur->enabled); ac++; XtSetArg (al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; - XtSetArg (al[ac], XmNuserData, cur->call_data); ac++; + XtSetArg (al[ac], XmNuserData, cur); ac++; if (instance->pop_up_p && !cur->contents && !cur->call_data && !lw_separator_p (cur->name, &separator, 1)) @@ -568,14 +570,18 @@ make_menu_in_widget (widget_instance* instance, ? XmN_OF_MANY : XmONE_OF_MANY)); ++ac; button = XmCreateToggleButton (widget, cur->name, al, ac); - XtAddCallback (button, XmNarmCallback, xm_arm_callback, cur); - XtAddCallback (button, XmNdisarmCallback, xm_arm_callback, cur); + XtAddCallback (button, XmNarmCallback, xm_arm_callback, + (XtPointer) instance); + XtAddCallback (button, XmNdisarmCallback, xm_arm_callback, + (XtPointer) instance); } else { button = XmCreatePushButton (widget, cur->name, al, ac); - XtAddCallback (button, XmNarmCallback, xm_arm_callback, cur); - XtAddCallback (button, XmNdisarmCallback, xm_arm_callback, cur); + XtAddCallback (button, XmNarmCallback, xm_arm_callback, + (XtPointer) instance); + XtAddCallback (button, XmNdisarmCallback, xm_arm_callback, + (XtPointer) instance); } xm_update_label (instance, button, cur); @@ -642,7 +648,7 @@ update_one_menu_entry (widget_instance* instance, /* update the sensitivity and userdata */ /* Common to all widget types */ XtSetSensitive (widget, val->enabled); - XtVaSetValues (widget, XmNuserData, val->call_data, NULL); + XtVaSetValues (widget, XmNuserData, val, NULL); /* update the menu button as a label. */ if (val->this_one_change >= VISIBLE_CHANGE) @@ -842,7 +848,7 @@ xm_update_one_widget (widget_instance* instance, /* Common to all widget types */ XtSetSensitive (widget, val->enabled); - XtVaSetValues (widget, XmNuserData, val->call_data, NULL); + XtVaSetValues (widget, XmNuserData, val, NULL); /* Common to all label like widgets */ if (XtIsSubclass (widget, xmLabelWidgetClass)) @@ -1787,6 +1793,7 @@ do_call (Widget widget, int ac; XtPointer user_data; widget_instance* instance = (widget_instance*)closure; + widget_value *wv; Widget instance_widget; LWLIB_ID id; @@ -1804,17 +1811,18 @@ do_call (Widget widget, user_data = NULL; XtSetArg (al [ac], XmNuserData, &user_data); ac++; XtGetValues (widget, al, ac); + wv = user_data; switch (type) { case pre_activate: if (instance->info->pre_activate_cb) - instance->info->pre_activate_cb (widget, id, user_data); + instance->info->pre_activate_cb (widget, id, wv ? wv->call_data : NULL); break; case selection: if (instance->info->selection_cb) - instance->info->selection_cb (widget, id, user_data); + instance->info->selection_cb (widget, id, wv ? wv->call_data : NULL); break; case no_selection: @@ -1824,7 +1832,7 @@ do_call (Widget widget, case post_activate: if (instance->info->post_activate_cb) - instance->info->post_activate_cb (widget, id, user_data); + instance->info->post_activate_cb (widget, id, wv ? wv->call_data : NULL); break; default: @@ -1912,6 +1920,18 @@ xm_pop_down_callback (Widget widget, do_call (widget, closure, post_activate); } +static void +xm_pop_up_callback (Widget widget, + XtPointer closure, + XtPointer call_data) +{ + widget_instance *instance = (widget_instance *) closure; + + if ((!instance->pop_up_p && XtParent (widget) == instance->widget) + || XtParent (widget) == instance->parent) + do_call (widget, closure, pre_activate); +} + /* set the keyboard focus */ void |