From 66070bd113a6a6f7397fb0af264495c5daaea43c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dj=C3=A4rv?= Date: Mon, 12 Jan 2004 01:46:49 +0000 Subject: [PATCH] * 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. --- src/ChangeLog | 10 ++++++++++ src/xmenu.c | 22 +++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 8b6160fb5e..9c21defd65 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2004-01-12 Jan Dj,Ad(Brv + + * 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 * alloc.c (allocate_vectorlike): Surround calls to mallopt with diff --git a/src/xmenu.c b/src/xmenu.c index 439f5002dd..473e29de88 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -1121,17 +1121,19 @@ on the left of the dialog box and all following items on the right. 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 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers) 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 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click) 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 @@ create_and_show_dialog (f, first_wv) 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); } -- 2.20.1