Steve Youngs <youngs(a)xemacs.org> wrote:
|--==> "JPW" == John Paul Wallington
<jpw(a)shootybangbang.com> writes:
JPW> Thanks for a confirmation! There are several fixes that IMHO should
JPW> be applied to the degenerate `mouse-avoidance-fancy-hook'. But
JPW> avoid.el lives in packages; should/can we accomodate XEmacs with
JPW> broken `mouse-position' ?
Is the problem in avoid.el or is it in 'mouse-position'? If avoid.el
does the right thing, don't "fix" it. Fix instead, the broken
'mouse-position'.
JPW> I guess the first thing is to work out the nature and extent of
JPW> `mouse-position' lossage.
Yep. John, are you able to work on this?
`mouse-position' is only broken insofar as it faithfully obeys its
documentation...
"When the cursor is *not over a character*, or not over a window, the
return value is a list (nil nil)."
whereas `mouse-pixel-position' will return positional values if the
mouse cursor is over a window, because it doesn't care about
characters.
GNU Emacs' `mouse-position' returns positional values based on
standard character cells, even if the cursor isn't over a character.
We could cook up some package-specific brain-damage:
(defun mouse-avoidance-mouse-position ()
"I wanna lose! Return approximate current mouse window and position."
(let ((m-pos (mouse-position)))
(if (car m-pos)
m-pos
(setq m-pos (mouse-pixel-position))
(if (car m-pos)
(cons (car m-pos)
(cons (/ (cadr m-pos) (face-width 'default))
(/ (cddr m-pos) (face-height 'default))))
m-pos))))
I guess `mouse-position' could do something similar, or preferably
better. I don't know whether any XEmacs specific code relies upon
`mouse-position' returning (nil nil) when not over a character though.
--
John Paul Wallington