TRANLE@INTELLICORP.COM (Minh Tran-Le) (08/13/89)
I would like to find out what is the window at a certain screen position. Is there any way to do it without using the hack about warping the mouse to that position and do a XQueryPointer and then warp back the mouse. My current hack cannot work when you have EnterNotify and LeaveNotify set. Thanks, Tran Le. Arpanet: tranle@IntelliCorp.com uucp: ..sun!icmv!mtranle -------
diamant@hpfclp.SDE.HP.COM (John Diamant) (08/21/89)
> I would like to find out what is the window at a certain screen position. > Is there any way to do it without using the hack about warping the mouse > to that position and do a XQueryPointer and then warp back the mouse. > My current hack cannot work when you have EnterNotify and LeaveNotify set. You can use XTranslateCoordinates. For example, here's a piece of code I use to find the smallest window in which the pointer was when the function was called (it expected a call to XQueryPointer to be done prior to the call, but you could pass in the root window and the x y coordinates instead): void find_smallest_window(dpy, parent, child, win_x, win_y) Display *dpy; Window *parent, *child; int win_x, win_y; { Window win; if (!child) child = parent; /* Note: The function XTranslateCoordinates must be used instead of */ /* XQueryPointer to avoid dependence on the pointer remaining */ /* stationary. This eliminates the race condition of the pointer */ /* moving, but not the one of the window hierarchy changing */ while (XTranslateCoordinates(dpy, *parent, *child, win_x, win_y, &win_x, &win_y, &win) && win != NULL) { *parent = *child; *child = win; } } John Diamant Software Engineering Systems Division Hewlett-Packard Co. Internet: diamant@hpfclp.sde.hp.com Fort Collins, CO UUCP: {hplabs,hpfcla}!hpfclp!diamant