Mercurial > emacs
changeset 53565:5a46a8191136
* xmenu.c (popup_get_selection): Check new parameter down_on_keypress
if a key press should pop down. Only pop down if a key is pressed
outside the menu/dialog.
(create_and_show_popup_menu): Pass 0 for down_on_keypress to
popup_get_selection.
(create_and_show_dialog): Pass 1 for down_on_keypress to
popup_get_selection.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Mon, 12 Jan 2004 01:46:49 +0000 |
parents | 609ef1718642 |
children | b0c5a3919cb8 |
files | src/ChangeLog src/xmenu.c |
diffstat | 2 files changed, 25 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Mon Jan 12 01:45:22 2004 +0000 +++ b/src/ChangeLog Mon Jan 12 01:46:49 2004 +0000 @@ -1,3 +1,13 @@ +2004-01-12 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> + + * xmenu.c (popup_get_selection): Check new parameter down_on_keypress + if a key press should pop down. Only pop down if a key is pressed + outside the menu/dialog. + (create_and_show_popup_menu): Pass 0 for down_on_keypress to + popup_get_selection. + (create_and_show_dialog): Pass 1 for down_on_keypress to + popup_get_selection. + 2004-01-11 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> * alloc.c (allocate_vectorlike): Surround calls to mallopt with
--- a/src/xmenu.c Mon Jan 12 01:45:22 2004 +0000 +++ b/src/xmenu.c Mon Jan 12 01:46:49 2004 +0000 @@ -1121,17 +1121,19 @@ and x-popup-dialog; it is not used for the menu bar. If DO_TIMERS is nonzero, run timers. + If DOWN_ON_KEYPRESS is nonzero, pop down if a key is pressed. NOTE: All calls to popup_get_selection should be protected with BLOCK_INPUT, UNBLOCK_INPUT wrappers. */ #ifdef USE_X_TOOLKIT static void -popup_get_selection (initial_event, dpyinfo, id, do_timers) +popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress) XEvent *initial_event; struct x_display_info *dpyinfo; LWLIB_ID id; int do_timers; + int down_on_keypress; { XEvent event; @@ -1167,15 +1169,20 @@ event.xbutton.state = 0; #endif } - /* If the user presses a key, deactivate the menu. + /* If the user presses a key that doesn't go to the menu, + deactivate the menu. The user is likely to do that if we get wedged. - This is mostly for Lucid, Motif pops down the menu on ESC. */ + All toolkits now pop down menus on ESC. + For dialogs however, the focus may not be on the dialog, so + in that case, we pop down. */ else if (event.type == KeyPress + && down_on_keypress && dpyinfo->display == event.xbutton.display) { KeySym keysym = XLookupKeysym (&event.xkey, 0); - if (!IsModifierKey (keysym)) - popup_activated_flag = 0; + if (!IsModifierKey (keysym) + && x_any_window_to_frame (dpyinfo, event.xany.window) != NULL) + popup_activated_flag = 0; } x_dispatch_event (&event, event.xany.display); @@ -2448,7 +2455,7 @@ popup_activated_flag = 1; /* Process events that apply to the menu. */ - popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 0); + popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 0, 0); /* fp turned off the following statement and wrote a comment that it is unnecessary--that the menu has already disappeared. @@ -2842,7 +2849,8 @@ Fcons (make_number (dialog_id >> (fact)), make_number (dialog_id & ~(-1 << (fact))))); - popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), dialog_id, 1); + popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), + dialog_id, 1, 1); unbind_to (count, Qnil); }