Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!emory!stiatl!meo From: meo@stiatl.UUCP (Miles O'Neal) Newsgroups: comp.windows.x Subject: Re: updating widget state after a wm move Summary: use XQueryPointer () Keywords: cursor position, widget position Message-ID: <8863@stiatl.UUCP> Date: 6 Feb 90 16:22:29 GMT Organization: Sales Technologies Inc., "The Prototype IS the Product..." Lines: 37 In article <14274@cs.yale.edu> omtzigt-theo@CS.Yale.EDU (theo omtzigt) writes: | |To be able to pull down the menu at the right place, I am querying |the x and y position of both the form and the relative position of |the button. However, the state of the widget that I get back |through XtGetValues, is the position of the widget at realization, |which is not necessarily the position where the widget is, because |the user may have moved the widget. Use XQueryPointer - it returns the cursor position relative to both the window it's in and the root window. Example: /* Code isn't optimal as I ripped out some other stuff we do */ GetXY (w, x, y) Widget w; /* widget cursor is currently in */ int *x, *y; /* locs to hold new (x, y) */ { Display *D; /* display the widget is on */ Window W, /* input window */ rootW, /* root window returned from XQueryPointer */ childW; /* child window returned from XQueryPointer */ int rx, /* root-relative x location of pointer */ ry, /* root-relative y location of pointer */ wx, /* widget-relative x location of pointer */ wy; /* widget-relative y location of pointer */ unsigned int jive; /* current mouse buttons */ D = XtDisplay (w); W = XtWindow (w); XQueryPointer (D, W, &rootW, &childW, &rx, &ry, &wx, &wy, &jive); *x = rx; *y = ry; }