Commit b78f9767 authored by Jan D's avatar Jan D

Fix menus as per bug 6499 and 6608.

* gtkutil.c (xg_event_is_for_menubar): New function (Bug#6499).

* gtkutil.h (xg_event_is_for_menubar): Declare.

* xfns.c (x_menubar_window_to_frame): Take XEvent as second parameter
instead of Window.  Call xg_event_is_for_menubar when
USE_GTK (Bug#6499).

* xmenu.c (x_activate_menubar): Revert previous fix for Bug#6499,
i.e. don't put back ButtonRelease (Bug#6608).

* xterm.c (handle_one_xevent): Pass event to x_menubar_window_to_frame.

* xterm.h (x_menubar_window_to_frame): Second parameter is XEvent*.
parent 1f60c16a
2010-07-14 Jan Djärv <jan.h.d@swipnet.se>
* xterm.h (x_menubar_window_to_frame): Second parameter is XEvent*.
* xterm.c (handle_one_xevent): Pass event to x_menubar_window_to_frame.
* xmenu.c (x_activate_menubar): Revert previous fix for Bug#6499,
i.e. don't put back ButtonRelease (Bug#6608).
* xfns.c (x_menubar_window_to_frame): Take XEvent as second parameter
instead of Window. Call xg_event_is_for_menubar when
USE_GTK (Bug#6499).
* gtkutil.h (xg_event_is_for_menubar): Declare.
* gtkutil.c (xg_event_is_for_menubar): New function (Bug#6499).
2010-07-14 Eli Zaretskii <eliz@gnu.org>
* w32fns.c (x_set_foreground_color): Fix setting the cursor color
......
......@@ -2990,6 +2990,38 @@ free_frame_menubar (f)
}
}
int
xg_event_is_for_menubar (FRAME_PTR f, XEvent *event)
{
struct x_output *x = f->output_data.x;
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;
GList *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);
if (GTK_WIDGET_MAPPED (w) && gtk_widget_intersect (w, &rec, NULL))
break;
}
g_list_free (list);
return iter == 0 ? 0 : 1;
}
/***********************************************************************
......
......@@ -154,6 +154,8 @@ extern void xg_modify_menubar_widgets P_ ((GtkWidget *menubar,
extern int xg_update_frame_menubar P_ ((FRAME_PTR f));
extern int xg_event_is_for_menubar P_ ((FRAME_PTR f, XEvent *event));
extern int xg_have_tear_offs P_ ((void));
extern int xg_get_scroll_id_for_window P_ ((Display *dpy, Window wid));
......
......@@ -404,10 +404,11 @@ x_any_window_to_frame (dpyinfo, wdesc)
/* Likewise, but consider only the menu bar widget. */
struct frame *
x_menubar_window_to_frame (dpyinfo, wdesc)
x_menubar_window_to_frame (dpyinfo, event)
struct x_display_info *dpyinfo;
int wdesc;
XEvent *event;
{
Window wdesc = event->xany.window;
Lisp_Object tail, frame;
struct frame *f;
struct x_output *x;
......@@ -423,21 +424,11 @@ x_menubar_window_to_frame (dpyinfo, wdesc)
if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
continue;
x = f->output_data.x;
/* Match if the window is this frame's menubar. */
#ifdef USE_GTK
if (x->menubar_widget)
{
GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc);
/* This gives false positives, but the rectangle check in xterm.c
where this is called takes care of that. */
if (gwdesc != 0
&& (gwdesc == x->menubar_widget
|| gtk_widget_is_ancestor (x->menubar_widget, gwdesc)
|| gtk_widget_is_ancestor (gwdesc, x->menubar_widget)))
return f;
}
if (x->menubar_widget && xg_event_is_for_menubar (f, event))
return f;
#else
/* Match if the window is this frame's menubar. */
if (x->menubar_widget
&& lw_window_is_in_menubar (wdesc, x->menubar_widget))
return f;
......
......@@ -684,14 +684,6 @@ x_activate_menubar (f)
set_frame_menubar (f, 0, 1);
BLOCK_INPUT;
#ifdef USE_GTK
/* If we click outside any menu item, the menu bar still grabs.
So we send Press and the Release. If outside, grab is released.
If on a menu item, it is popped up normally.
PutBack is like a stack, so we put back in reverse order. */
f->output_data.x->saved_menu_event->type = ButtonRelease;
XPutBackEvent (f->output_data.x->display_info->display,
f->output_data.x->saved_menu_event);
f->output_data.x->saved_menu_event->type = ButtonPress;
XPutBackEvent (f->output_data.x->display_info->display,
f->output_data.x->saved_menu_event);
popup_activated_flag = 1;
......
......@@ -6951,7 +6951,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
f->mouse_moved = 0;
#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
f = x_menubar_window_to_frame (dpyinfo, event.xbutton.window);
f = x_menubar_window_to_frame (dpyinfo, &event);
/* For a down-event in the menu bar,
don't pass it to Xt right now.
Instead, save it away
......
......@@ -383,7 +383,8 @@ extern void check_x P_ ((void));
extern struct frame *x_window_to_frame P_ ((struct x_display_info *, int));
extern struct frame *x_any_window_to_frame P_ ((struct x_display_info *, int));
extern struct frame *x_menubar_window_to_frame P_ ((struct x_display_info *, int));
extern struct frame *x_menubar_window_to_frame P_ ((struct x_display_info *,
XEvent *));
extern struct frame *x_top_window_to_frame P_ ((struct x_display_info *, int));
#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment