Mercurial > emacs
diff src/gtkutil.c @ 110091:66a2fac996a4
merge emacs-23
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 27 Aug 2010 23:05:43 +0900 |
parents | 507549811e3e |
children | a93344738bc8 1cdff3b101d6 |
line wrap: on
line diff
--- a/src/gtkutil.c Sat Apr 03 19:40:20 2010 -0400 +++ b/src/gtkutil.c Fri Aug 27 23:05:43 2010 +0900 @@ -2990,6 +2990,55 @@ } } +int +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; + + if (! (event->xbutton.x >= 0 + && event->xbutton.x < FRAME_PIXEL_WIDTH (f) + && event->xbutton.y >= 0 + && event->xbutton.y < f->output_data.x->menubar_height + && event->xbutton.same_screen)) + return 0; + + 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; + 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); + if (GTK_WIDGET_MAPPED (w) && gtk_widget_intersect (w, &rec, NULL)) + break; + } + g_list_free (list); + return iter == 0 ? 0 : 1; +} + /***********************************************************************