Didier Verna <verna(a)inf.enst.fr> writes:
Gunnar Evermann
<Gunnar.Evermann(a)nats.informatik.uni-hamburg.de> writes:
> but, how??? x_any_window_to_frame doesn't cut it. In a vanilla XEmacs,
> if the pointer is in the *scratch* buffer I need to traverse some
> steps down the Window hierarchy before I get the frame from
> x_any_window_to_frame. For the child_window returned by XQueryPointer
> I only get NIL :-(
I don't understand this.
OK, I'll try again:
First, I give *my* interpretation of how x_get_mouse_position() works
(this could be totally wrong):
1) call XQueryPointer to find out over which Window (if any) the
pointer currently is. ('child_window')
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)
3) repeat 2) until it returns None.
4) call x_any_window_to_frame with the previous window and store the
frame in an Lisp_Object.
5) get the coordinates from XTranslateCoordinates() with the frame's
text widget as the destination window.
The problem is that XQueryPointer can return a window that results in
a Bad Window on the first call to 2).
Jan suggested to move the call to x_any_window_to_frame between 1) and
2). This sounds reasonable but doesn't work. In all my tests
x_any_window_to_frame(d, child_window) returns NIL at this point.
If I call x_any_window_to_frame after each iteration, I only get the
frame after at least two iterations of the loop.
I used a freshly started XEmacs (with toolbar and scrollbars)
displaying only the *scratch* buffer. The Pointer was over the text in
that buffer. The above loop did 5 iterations in this case.
Another solution to this problem is to enclose the call to
XQueryPointer in an ephemeral error handler that would basically do nothing.
I don't understand this :-) more precisely I have no idea how to do
that. (maybe using this error_expected stuff?).
Please note that the error happens in a call to
XTranslateCoordinates().
Gunnar (who should really read those damned X manuals...)