Gunnar Evermann <Gunnar.Evermann(a)nats.informatik.uni-hamburg.de> writes:
1) call XQueryPointer to find out over which Window (if any) the
pointer currently is. ('child_window')
The race condition is here.
There is _no_ general purpose way you can
avoid it in an application -- potentially any other application can
delete the window between the time you do the query pointer and then
ask for the translate coordinates.
2) call XTranslateCoordinates() with this Window as the destination
window. 'If the coordinates are contained in a mapped child of
dest_w, that child is returned to child_window.' (quote from man
page)
To get around the problem, you (mentally) acknowledge that there is no
way you can avoid the problem in your application. Instead you
install an error handler that says -- "Oh, a bad window error, I'll
ignore that". Do the translate coordinates, uninstall the error
handler, and check if the error handler indicated an error. I'd be
surprised if XEmacs didn't have something to do this automatically.
--pete