Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!uvaarpa!mcnc!duke!romeo!pusateri From: pusateri@romeo.cs.duke.edu (Thomas J. Pusateri) Newsgroups: comp.windows.x Subject: Re: x and y Summary: look at this source Message-ID: <15208@duke.cs.duke.edu> Date: 3 Aug 89 13:41:17 GMT Sender: news@duke.cs.duke.edu Lines: 69 In article <8908021500.AA01836@godzilla.mcs.anl.gov>, fineberg@ANTARES.MCS.ANL.GOV writes: > I am writting an application using Widgets and I want to have a popup > widget appear where the cursor is or else, at least where a known widget > > Sam Fineberg Sam, Haven't talked to you in a while. (If your the same Sam Fineberg I worked with at Purdue!) Anyway, here is a code fragment taken from a pop up menu widget that puts the popup where you want it. Tom Pusateri National Biomedical Simulation Resource Duke University Medical Center pusateri@nbsr.mc.duke.edu ---------------------------------------------------------------------------- * MenuShell Widget * Robert Blumen blumen@arisia.xerox.com blumen@cad.berkeley.edu * /*********************************************************** Copyright 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that /*----------------------------------------------------------- Find out where the pointer is and put the menu there. Geometry request should always be satisfied since we are an override shell. */ static void _GetLocation(w) Widget w; { MenuShellWidget msw = (MenuShellWidget) w; Window root, child; int x_root, y_root, x_win, y_win; unsigned int mask; XtWidgetGeometry request; XQueryPointer( XtDisplay( msw ), XtWindow( msw ), &root, &child, &x_root, &y_root, &x_win, &y_win, &mask); request.request_mode = CWX | CWY; switch (msw->menu.menu_under_cursor) { case XtJustifyLeft: request.x = x_root; break; case XtJustifyCenter: request.x = x_root - msw->core.width/2; break; case XtJustifyRight: request.x = x_root - msw->core.width; break; default: XtError("wrong type of menu justify.\n"); break; } request.y = y_root -1; XtMakeGeometryRequest(msw, &request, (XtWidgetGeometry *)NULL); return; }