* Emacs should properly render dynamically generated menus. Patch: fix-dynamic-menus.diff Originally-reported-by: Baylis Shanks Date: Sat, 10 Oct 2009 22:15:05 UTC Added-by: Rob Browning Backported-by: Reinhard Tartler Status: incorporated upstream Bug: 550541 This Debian patch is taken from this upstream commit: commit 3715ffe3e3b2c64d113bf26d94aab559f8559e83 Author: Jan Djärv Date: Wed Sep 2 17:03:20 2009 +0000 It was backported to emacs22 for the ubuntu package --- a/src/xfns.c +++ b/src/xfns.c @@ -369,10 +369,7 @@ x_any_window_to_frame (dpyinfo, wdesc) #ifdef USE_GTK GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc); if (gwdesc != 0 - && (gwdesc == x->widget - || gwdesc == x->edit_widget - || gwdesc == x->vbox_widget - || gwdesc == x->menubar_widget)) + && gtk_widget_get_toplevel (gwdesc) == x->widget) found = f; #else if (wdesc == XtWindow (x->widget) @@ -393,54 +390,6 @@ x_any_window_to_frame (dpyinfo, wdesc) return found; } -/* Likewise, but exclude the menu bar widget. */ - -struct frame * -x_non_menubar_window_to_frame (dpyinfo, wdesc) - struct x_display_info *dpyinfo; - int wdesc; -{ - Lisp_Object tail, frame; - struct frame *f; - struct x_output *x; - - if (wdesc == None) return 0; - - for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail)) - { - frame = XCAR (tail); - if (!GC_FRAMEP (frame)) - continue; - f = XFRAME (frame); - if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) - continue; - x = f->output_data.x; - /* This frame matches if the window is any of its widgets. */ - if (x->hourglass_window == wdesc) - return f; - else if (x->widget) - { -#ifdef USE_GTK - GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc); - if (gwdesc != 0 - && (gwdesc == x->widget - || gwdesc == x->edit_widget - || gwdesc == x->vbox_widget)) - return f; -#else - if (wdesc == XtWindow (x->widget) - || wdesc == XtWindow (x->column_widget) - || wdesc == XtWindow (x->edit_widget)) - return f; -#endif - } - else if (FRAME_X_WINDOW (f) == wdesc) - /* A tooltip frame. */ - return f; - } - return 0; -} - /* Likewise, but consider only the menu bar widget. */ struct frame * @@ -468,15 +417,14 @@ x_menubar_window_to_frame (dpyinfo, wdes if (x->menubar_widget) { GtkWidget *gwdesc = xg_win_to_widget (dpyinfo->display, wdesc); - int found = 0; - BLOCK_INPUT; + /* 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_get_parent (gwdesc) == x->menubar_widget)) - found = 1; - UNBLOCK_INPUT; - if (found) return f; + || gtk_widget_is_ancestor (x->menubar_widget, gwdesc) + || gtk_widget_is_ancestor (gwdesc, x->menubar_widget))) + return f; } #else if (x->menubar_widget --- a/src/xterm.c +++ b/src/xterm.c @@ -110,8 +110,6 @@ extern void xlwmenu_redisplay P_ ((Widge #if defined (USE_X_TOOLKIT) || defined (USE_GTK) extern void free_frame_menubar P_ ((struct frame *)); -extern struct frame *x_menubar_window_to_frame P_ ((struct x_display_info *, - int)); #endif #ifdef USE_X_TOOLKIT @@ -144,11 +142,6 @@ extern void _XEditResCheckMessages (); #endif /* USE_X_TOOLKIT */ -#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) -#define x_any_window_to_frame x_window_to_frame -#define x_top_window_to_frame x_window_to_frame -#endif - #ifdef USE_X_TOOLKIT #include "widget.h" #ifndef XtNinitialState @@ -3788,7 +3781,14 @@ XTmouse_position (fp, insist, bar_window if (child == None || child == win) break; - +#ifdef USE_GTK + /* We don't wan't to know the innermost window. We + want the edit window. For non-Gtk+ the innermost + window is the edit window. For Gtk+ it might not + be. It might be the tool bar for example. */ + if (x_window_to_frame (FRAME_X_DISPLAY_INFO (*fp), win)) + break; +#endif win = child; parent_x = win_x; parent_y = win_y; @@ -3805,8 +3805,14 @@ XTmouse_position (fp, insist, bar_window parent_{x,y} are invalid, but that's okay, because we'll never use them in that case.) */ +#ifdef USE_GTK + /* We don't wan't to know the innermost window. We + want the edit window. */ + f1 = x_window_to_frame (FRAME_X_DISPLAY_INFO (*fp), win); +#else /* Is win one of our frames? */ f1 = x_any_window_to_frame (FRAME_X_DISPLAY_INFO (*fp), win); +#endif #ifdef USE_X_TOOLKIT /* If we end up with the menu bar window, say it's not --- a/src/xterm.h +++ b/src/xterm.h @@ -414,7 +414,7 @@ extern struct frame *x_window_to_frame P #if defined (USE_X_TOOLKIT) || defined (USE_GTK) extern struct frame *x_any_window_to_frame P_ ((struct x_display_info *, int)); -extern struct frame *x_non_menubar_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_top_window_to_frame P_ ((struct x_display_info *, int)); #endif