+2004-01-12 Jan Dj\e,Ad\e(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\e,Ad\e(Brv <jan.h.d@swipnet.se>
* alloc.c (allocate_vectorlike): Surround calls to mallopt with
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;
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);
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.
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);
}