🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #87767

Menu bar menus --with-x-toolkit=athena pop up in wrong place

#87767
From: Gary Barnes
Date: Wed, 31 Aug 1994 00:41
72 lines
3386 bytes
Emacs version 19.25, no modifications
SPARCstation2 SunOS 4.1.3
MIT X11R5, few if any patches

./configure sparc-sun-sunos4.1.3                \
            --x-includes=/vendor/X11R5/includes \
            --x-libraries=/vendor/X11R5/lib     \
            --with-gcc                          \
            --with-x-toolkit=athena

This might reflect a bug in Xt or Xaw from X11R5, or maybe it's a real
bug in Emacs.  Anyway, the patch below makes the problem go away.

When a menubar menu is popped up, it goes at coordinate 0,0 for the
frame.  It is supposed to go next-to and just-under the menubar
button.  At 0,0 they come up over/on-top-of the menu bar; hiding it
from sight.  Also, when this happens, the selected menu items don't
track the mouse very well, they are offset by a dozen or so pixels.
Also, submenus come up where they would come up if the main menu had
come up in the right place.

I tracked the X protocol stream down and discovered that the menu
window was being created with an x/y of 0/0.  I put a fprintf
statement in lwlib/xlwmenu.c:pop_up_menu just before the
XConfigureWindow that is supposed to set the x/y/width/height of the
menu window.  It was setting the right values but the x/y were not
being used in the CreateWindow protocol message for some reason.  The
problem goes away if I place a call to XtRealize just before the
XtConfigureWindow.

Here's the first part of lwlib/xlwmenu.c, the pop_up_menu function.
It shows my one-line change, surrounded by #ifdef GEB_MENU_POSITION.

void
pop_up_menu (mw, event)
     XlwMenuWidget mw;
     XButtonPressedEvent* event;
{
  int		x = event->x_root;
  int		y = event->y_root;
  int		w;
  int		h;
  int		borderwidth = mw->menu.shadow_thickness;
  Screen*	screen = XtScreen (mw);

  XtCallCallbackList ((Widget)mw, mw->menu.open, NULL);

  size_menu (mw, 0);

  w = mw->menu.windows [0].width;
  h = mw->menu.windows [0].height;

  x -= borderwidth;
  y -= borderwidth;
  if (x < borderwidth)
    x = borderwidth;
  if (x + w + 2 * borderwidth > WidthOfScreen (screen))
    x = WidthOfScreen (screen) - w - 2 * borderwidth;
  if (y < borderwidth)
    y = borderwidth;
  if (y + h + 2 * borderwidth> HeightOfScreen (screen))
    y = HeightOfScreen (screen) - h - 2 * borderwidth;

  mw->menu.popped_up = True;
#ifdef GEB_MENU_POSITION
  XtRealizeWidget (XtParent (mw));
#endif
  XtConfigureWidget (XtParent (mw), x, y, w, h,
		     XtParent (mw)->core.border_width);
  XtPopup (XtParent (mw), XtGrabExclusive);
  display_menu (mw, 0, False, NULL, NULL, NULL, NULL, NULL);
....
Technical Details
Message-ID: <9408310039.AA28162@igor.Rational.COM>
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!redstone.interpath.net!ddsw1!panix!MathWorks.Com!news.duke.edu!convex!cs.utexas.edu!howland.reston.ans.net!math.ohio-state.edu!cis.ohio-state.edu!rational.com!geb

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,33d782929253c291,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1994-08-30 18:10:19 PST
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!redstone.interpath.net!ddsw1!panix!MathWorks.Com!news.duke.edu!convex!cs.utexas.edu!howland.reston.ans.net!math.ohio-state.edu!cis.ohio-state.edu!rational.com!geb
From: geb@rational.com (Gary Barnes)
Newsgroups: gnu.emacs.bug
Subject: Menu bar menus --with-x-toolkit=athena pop up in wrong place
Date: 30 Aug 1994 20:41:03 -0400
Organization: GNUs Not Usenet
Lines: 73
Sender: daemon@cis.ohio-state.edu
Approved: bug-gnu-emacs@prep.ai.mit.edu
Distribution: gnu
Message-ID: <9408310039.AA28162@igor.Rational.COM>
Reply-To: geb@rational.com