Comment 29 for bug 756273

Revision history for this message
Thomas Dickey (dickey-his) wrote : Re: [Bug 756273] Re: xterm dies on popup-menu action

On Sat, Apr 30, 2011 at 12:02:06AM -0000, Thomas Dickey wrote:
> I might be able to appease it by checking for this case and warping the
> pointer onto the menu widget (will see).

This seems to work:

===================================================================
RCS file: RCS/menu.c,v
retrieving revision 1.289
diff -u -r1.289 menu.c
--- menu.c 2011/04/24 18:18:30 1.289
+++ menu.c 2011/04/30 00:22:23
@@ -834,10 +834,29 @@
 {
     TRACE(("HandlePopupMenu\n"));
     if (domenu(w, event, params, param_count)) {
+ XtermWidget xw = term;
+ TScreen *screen = TScreenOf(xw);
+
 #if OPT_TOOLBAR
  w = select_menu(w, mainMenu)->w;
 #endif
- XtCallActionProc(w, "XawPositionSimpleMenu", event, params, 1);
+ /*
+ * The action procedure in SimpleMenu.c, PositionMenu does not expect a
+ * key translation event when we are popping up a menu. In particular,
+ * if the pointer is outside the menu, then the action procedure will
+ * fail in its attempt to determine the location of the pointer within
+ * the menu. Anticipate that by warping the pointer into the menu when
+ * a key event is detected.
+ */
+ switch (event->type) {
+ case KeyPress:
+ case KeyRelease:
+ XWarpPointer(screen->display, None, XtWindow(w), 0, 0, 0, 0, 0, 0);
+ break;
+ default:
+ XtCallActionProc(w, "XawPositionSimpleMenu", event, params, 1);
+ break;
+ }
  XtCallActionProc(w, "MenuPopup", event, params, 1);
     }
 }

--
Thomas E. Dickey <email address hidden>
http://invisible-island.net
ftp://invisible-island.net