changeset 97056:bda3c99f1515

(menu_nav_ended): Revert change from 2008-07-24. (create_menus): Connect selection-done to menu_nav_ended.
author Jan Djärv <jan.h.d@swipnet.se>
date Mon, 28 Jul 2008 07:15:34 +0000
parents bf2d011df79a
children 55c00acfe623
files src/gtkutil.c
diffstat 1 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkutil.c	Mon Jul 28 04:00:07 2008 +0000
+++ b/src/gtkutil.c	Mon Jul 28 07:15:34 2008 +0000
@@ -2139,6 +2139,34 @@
   return w;
 }
 
+/* Callback called when keyboard traversal (started by x-menu-bar-open) 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;
+
+  if (FRAME_X_OUTPUT (f)->menubar_widget)
+    {
+      GtkMenuShell *w = GTK_MENU_SHELL (FRAME_X_OUTPUT (f)->menubar_widget);
+      Display *dpy = FRAME_X_DISPLAY (f);
+
+      BLOCK_INPUT;
+      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 *));
@@ -2204,6 +2232,12 @@
       }
       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);