From: Richard M. Stallman Date: Sun, 31 Dec 1995 19:15:18 +0000 (+0000) Subject: (xlwMenuActionsList): Add "key" and "nothing". X-Git-Tag: emacs-19.34~1961 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ba624d0f4c0347957c498658421e6f5c072ad725;p=emacs.git (xlwMenuActionsList): Add "key" and "nothing". (xlwMenuTranslations): Add translations for Key, KeyUp, and for the modifier keysyms. (Nothing, Key): New functions. (XlwMenuSetValues): Do redisplay if non-null contents get replaced by empty contents. --- diff --git a/lwlib/xlwmenu.c b/lwlib/xlwmenu.c index 2f5066130d9..26b56315e05 100644 --- a/lwlib/xlwmenu.c +++ b/lwlib/xlwmenu.c @@ -37,9 +37,39 @@ XFontStruct *xlwmenu_default_font; static char xlwMenuTranslations [] = -": start()\n\ -: drag()\n\ -: select()\n\ +": start()\n\ +: drag()\n\ +: select()\n\ +Shift_L: nothing()\n\ +Shift_R: nothing()\n\ +Meta_L: nothing()\n\ +Meta_R: nothing()\n\ +Control_L: nothing()\n\ +Control_R: nothing()\n\ +Hyper_L: nothing()\n\ +Hyper_R: nothing()\n\ +Super_L: nothing()\n\ +Super_R: nothing()\n\ +Alt_L: nothing()\n\ +Alt_R: nothing()\n\ +Caps_Lock: nothing()\n\ +Shift_Lock: nothing()\n\ +Shift_L: nothing()\n\ +Shift_R: nothing()\n\ +Meta_L: nothing()\n\ +Meta_R: nothing()\n\ +Control_L: nothing()\n\ +Control_R: nothing()\n\ +Hyper_L: nothing()\n\ +Hyper_R: nothing()\n\ +Super_L: nothing()\n\ +Super_R: nothing()\n\ +Alt_L: nothing()\n\ +Alt_R: nothing()\n\ +Caps_Lock: nothing()\n\ +Shift_Lock:nothing()\n\ +: key()\n\ +: key()\n\ "; #define offset(field) XtOffset(XlwMenuWidget, field) @@ -97,6 +127,8 @@ static void XlwMenuClassInitialize(); static void Start(); static void Drag(); static void Select(); +static void Key(); +static void Nothing(); static XtActionsRec xlwMenuActionsList [] = @@ -104,6 +136,8 @@ xlwMenuActionsList [] = {"start", Start}, {"drag", Drag}, {"select", Select}, + {"key", Key}, + {"nothing", Nothing}, }; #define SuperClass ((CoreWidgetClass)&coreClassRec) @@ -1251,6 +1285,11 @@ XlwMenuSetValues (current, request, new) && newmw->menu.contents->contents && newmw->menu.contents->contents->change >= VISIBLE_CHANGE) redisplay = True; + /* Do redisplay if the contents are entirely eliminated. */ + if (newmw->menu.contents + && newmw->menu.contents->contents == 0 + && newmw->menu.contents->change >= VISIBLE_CHANGE) + redisplay = True; if (newmw->core.background_pixel != oldmw->core.background_pixel || newmw->menu.foreground != oldmw->menu.foreground @@ -1378,7 +1417,50 @@ Drag (w, ev, params, num_params) handle_motion_event (mw, &ev->xmotion); } -static void +/* Do nothing. + This is how we handle presses and releases of modifier keys. */ +static void +Nothing (w, ev, params, num_params) + Widget w; + XEvent *ev; + String *params; + Cardinal *num_params; +{ +} + +/* Handle key press and release events while menu is popped up. + Our action is to get rid of the menu. */ +static void +Key (w, ev, params, num_params) + Widget w; + XEvent *ev; + String *params; + Cardinal *num_params; +{ + XlwMenuWidget mw = (XlwMenuWidget)w; + + /* Pop down everything. */ + mw->menu.new_depth = 1; + remap_menubar (mw); + + if (mw->menu.popped_up) + { + mw->menu.popped_up = False; + XtUngrabPointer ((Widget)mw, ev->xmotion.time); + if (XtIsShell (XtParent ((Widget) mw))) + XtPopdown (XtParent ((Widget) mw)); + else + { + XtRemoveGrab ((Widget) mw); + display_menu (mw, 0, False, NULL, NULL, NULL, NULL, NULL); + } + } + + /* callback */ + XtCallCallbackList ((Widget)mw, mw->menu.select, (XtPointer)0); +} + +static void Select (w, ev, params, num_params) Widget w; XEvent *ev;