# HG changeset patch # User Jan Dj¸«£rv # Date 1107460183 0 # Node ID ef2f9fc4fd42f735aa95aed91caa4b67cc534017 # Parent aafd8ed9cff24327329b1321ae9e845348d76ad7 * xmenu.c (menubar_selection_callback): Force out GTK buffered events so the menu event comes after them. This is to prevent sit-for from exiting on buffered events directly after a menu selection, lisp code for Help => About Emacs uses sit-for. diff -r aafd8ed9cff2 -r ef2f9fc4fd42 src/xmenu.c --- a/src/xmenu.c Thu Feb 03 19:48:59 2005 +0000 +++ b/src/xmenu.c Thu Feb 03 19:49:43 2005 +0000 @@ -1445,9 +1445,9 @@ /* Find the menu selection and store it in the keyboard buffer. F is the frame the menu is on. MENU_BAR_ITEMS_USED is the length of VECTOR. - VECTOR is an array of menu events for the whole menu. - */ -void + VECTOR is an array of menu events for the whole menu. */ + +static void find_and_call_menu_selection (f, menu_bar_items_used, vector, client_data) FRAME_PTR f; int menu_bar_items_used; @@ -1464,6 +1464,8 @@ prefix = Qnil; i = 0; + while (gtk_events_pending ()) + gtk_main_iteration (); while (i < menu_bar_items_used) { if (EQ (XVECTOR (vector)->contents[i], Qnil)) @@ -1554,6 +1556,17 @@ if (! cb_data || ! cb_data->cl_data || ! cb_data->cl_data->f) return; + /* When a menu is popped down, X generates a focus event (i.e. focus + goes back to the frame below the menu). Since GTK buffers events, + we force it out here before the menu selection event. Otherwise + sit-for will exit at once if the focus event follows the menu selection + event. */ + + BLOCK_INPUT; + while (gtk_events_pending ()) + gtk_main_iteration (); + UNBLOCK_INPUT; + find_and_call_menu_selection (cb_data->cl_data->f, cb_data->cl_data->menu_bar_items_used, cb_data->cl_data->menu_bar_vector,