Merge from emacs--devo--0
[bpt/emacs.git] / lisp / avoid.el
index b5e7d1f..1868707 100644 (file)
@@ -1,6 +1,7 @@
 ;;; avoid.el --- make mouse pointer stay out of the way of editing
 
-;; Copyright (C) 1993, 1994, 2000, 2004 Free  Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 2000, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Boris Goldowsky <boris@gnu.org>
 ;; Keywords: mouse
@@ -19,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -138,23 +139,13 @@ Only applies in mouse-avoidance-modes `animate' and `jump'."
 (defun mouse-avoidance-point-position ()
   "Return the position of point as (FRAME X . Y).
 Analogous to `mouse-position'."
-  (let* ((w (selected-window))
-        (edges (window-inside-edges w))
-        (list
-         (compute-motion (max (window-start w) (point-min))   ; start pos
-                         ;; window-start can be < point-min if the
-                         ;; latter has changed since the last redisplay
-                         '(0 . 0)                             ; start XY
-                         (point)                              ; stop pos
-                         nil                                  ; stop XY: none
-                         nil                                  ; width
-                         (cons (window-hscroll w) 0)          ; 0 may not be right?
-                         (selected-window))))
-    ;; compute-motion returns (pos HPOS VPOS prevhpos contin)
-    ;; we want:               (frame hpos . vpos)
+  (let ((edges (window-inside-edges))
+       (x-y (posn-x-y (posn-at-point))))
     (cons (selected-frame)
-         (cons (+ (car edges)       (car (cdr list)))
-               (+ (car (cdr edges)) (car (cdr (cdr list))))))))
+         (cons (+ (car edges)
+                  (/ (car x-y) (frame-char-width)))
+               (+ (car (cdr edges))
+                  (/ (cdr x-y) (frame-char-height)))))))
 
 ;(defun mouse-avoidance-point-position-test ()
 ;  (interactive)