changeset 109332:507549811e3e

* gtkutil.c (xg_event_is_for_menubar): Also check that event window is related to the menu bar (Bug#6499).
author Jan D <jan.h.d@swipnet.se>
date Sat, 17 Jul 2010 11:59:19 +0200
parents 0c54c271bb98
children a13166a76062 a93344738bc8
files src/ChangeLog src/gtkutil.c
diffstat 2 files changed, 25 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Jul 16 13:17:13 2010 +0300
+++ b/src/ChangeLog	Sat Jul 17 11:59:19 2010 +0200
@@ -1,3 +1,8 @@
+2010-07-17  Jan Djärv  <jan.h.d@swipnet.se>
+
+	* gtkutil.c (xg_event_is_for_menubar): Also check that event window
+	is related to the menu bar (Bug#6499).
+
 2010-07-14  Jan Djärv  <jan.h.d@swipnet.se>
 
 	* xterm.h (x_menubar_window_to_frame): Second parameter is XEvent*.
--- a/src/gtkutil.c	Fri Jul 16 13:17:13 2010 +0300
+++ b/src/gtkutil.c	Sat Jul 17 11:59:19 2010 +0200
@@ -2994,6 +2994,13 @@
 xg_event_is_for_menubar (FRAME_PTR f, XEvent *event)
 {
   struct x_output *x = f->output_data.x;
+  GList *iter;
+  GdkRectangle rec;
+  GList *list;
+  GdkDisplay *gdpy;
+  GdkWindow *gw;
+  GdkEvent gevent;
+  GtkWidget *gwdesc;
 
   if (! x->menubar_widget) return 0;
 
@@ -3004,14 +3011,24 @@
          && event->xbutton.same_screen))
     return 0;
 
-  GList *list = gtk_container_get_children (GTK_CONTAINER (x->menubar_widget));
+  gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
+  gw = gdk_xid_table_lookup_for_display (gdpy, event->xbutton.window);
+  if (! gw) return 0;
+  gevent.any.window = gw;
+  gwdesc = gtk_get_event_widget (&gevent);
+  if (! gwdesc) return 0;
+  if (! GTK_IS_MENU_BAR (gwdesc)
+      && ! GTK_IS_MENU_ITEM (gwdesc)
+      && ! gtk_widget_is_ancestor (x->menubar_widget, gwdesc))
+    return 0;
+
+  list = gtk_container_get_children (GTK_CONTAINER (x->menubar_widget));
   if (! list) return 0;
-  GList *iter;
-  GdkRectangle rec;
   rec.x = event->xbutton.x;
   rec.y = event->xbutton.y;
   rec.width = 1;
   rec.height = 1;
+
   for (iter = list ; iter; iter = g_list_next (iter))
     {
       GtkWidget *w = GTK_WIDGET (iter->data);