From 31c5f81f89f54ffe03dcbe3df26a3f9560d68cbf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dj=C3=A4rv?= Date: Mon, 29 May 2006 07:11:05 +0000 Subject: [PATCH] Connect menu_nav_ended to "selection-done" to fix grabs --- src/gtkutil.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/gtkutil.c b/src/gtkutil.c index b8d37df2214..a5022c7cfe5 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -1970,6 +1970,30 @@ xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group) return w; } +/* Callback called when keyboard traversal (started by x-menu-bar-start) ends. + WMENU is the menu for which traversal has been done. DATA points to the + frame for WMENU. We must release grabs, some bad interaction between GTK + and Emacs makes the menus keep the grabs. */ + +static void +menu_nav_ended (wmenu, data) + GtkMenuShell *wmenu; + gpointer data; +{ + FRAME_PTR f = (FRAME_PTR) data; + Display *dpy = FRAME_X_DISPLAY (f); + + BLOCK_INPUT; + GtkMenuShell *w = GTK_MENU_SHELL (FRAME_X_OUTPUT (f)->menubar_widget); + gtk_menu_shell_deactivate (w); + gtk_menu_shell_deselect (w); + + XUngrabKeyboard (dpy, CurrentTime); + XUngrabPointer (dpy, CurrentTime); + UNBLOCK_INPUT; +} + + static GtkWidget *create_menus P_ ((widget_value *, FRAME_PTR, GCallback, GCallback, GCallback, int, int, int, GtkWidget *, xg_menu_cb_data *, char *)); @@ -2024,6 +2048,12 @@ create_menus (data, f, select_cb, deactivate_cb, highlight_cb, } else wmenu = gtk_menu_bar_new (); + /* Fix up grabs after keyboard traversal ends. */ + g_signal_connect (G_OBJECT (wmenu), + "selection-done", + G_CALLBACK (menu_nav_ended), + f); + /* Put cl_data on the top menu for easier access. */ cl_data = make_cl_data (cl_data, f, highlight_cb); g_object_set_data (G_OBJECT (wmenu), XG_FRAME_DATA, (gpointer)cl_data); -- 2.39.2