This gets it mostly working. I think I'll leave it for someone else to
actually hack it the rest of the way. :)
Main differences were writing the functions window-at and
coordinates-in-window-p. coordinates-in-window-p is not 100% correct.
According to the docs of Emacs 21, it should be:
-------------------------------------------------------------------------------
Return non-nil if COORDINATES are in WINDOW.
COORDINATES is a cons of the form (X . Y), X and Y being distances
measured in characters from the upper-left corner of the frame.
(0 . 0) denotes the character in the upper left corner of the
frame.
If COORDINATES are in the text portion of WINDOW,
the coordinates relative to the window are returned.
If they are in the mode line of WINDOW, `mode-line' is returned.
If they are in the top mode line of WINDOW, `header-line' is returned.
If they are in the bitmap-area to the left of the window,
`left-bitmap-area' is returned, if they are in the area on the right of
the window, `right-bitmap-area' is returned.
If they are on the border between WINDOW and its right sibling,
`vertical-line' is returned.
-------------------------------------------------------------------------------
Nothing but the coordinate munging is done, so dragging the mode line and
friends won't work. And since XEmacs unread-command-events really does
what it says (command-events only), motion events are unimplemented.
Enjoy!
-Bill P.