diff options
| author | Xue Fuqiao | 2013-09-04 08:39:34 +0800 |
|---|---|---|
| committer | Xue Fuqiao | 2013-09-04 08:39:34 +0800 |
| commit | adf2fc4a01efe77d73cd52bc9173914ed56ff531 (patch) | |
| tree | a5a280a5554a7bffeaf94fccae29fa3ac1a5d066 /lisp/avoid.el | |
| parent | 63191d9f2043d2e67657e85a7b3842805dd1dad6 (diff) | |
| parent | 38726039b77db432989fed106c88e9f1aa463281 (diff) | |
| download | emacs-adf2fc4a01efe77d73cd52bc9173914ed56ff531.tar.gz emacs-adf2fc4a01efe77d73cd52bc9173914ed56ff531.zip | |
Merge from mainline.
Diffstat (limited to 'lisp/avoid.el')
| -rw-r--r-- | lisp/avoid.el | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lisp/avoid.el b/lisp/avoid.el index c92d456ef0c..72f90a30ff5 100644 --- a/lisp/avoid.el +++ b/lisp/avoid.el | |||
| @@ -41,9 +41,9 @@ | |||
| 41 | ;; | 41 | ;; |
| 42 | ;; (if (eq window-system 'x) | 42 | ;; (if (eq window-system 'x) |
| 43 | ;; (mouse-avoidance-set-pointer-shape | 43 | ;; (mouse-avoidance-set-pointer-shape |
| 44 | ;; (eval (nth (random 4) | 44 | ;; (nth (random 4) |
| 45 | ;; '(x-pointer-man x-pointer-spider | 45 | ;; (list x-pointer-man x-pointer-spider |
| 46 | ;; x-pointer-gobbler x-pointer-gumby))))) | 46 | ;; x-pointer-gobbler x-pointer-gumby)))) |
| 47 | ;; | 47 | ;; |
| 48 | ;; For completely random pointer shape, replace the setq above with: | 48 | ;; For completely random pointer shape, replace the setq above with: |
| 49 | ;; (setq x-pointer-shape (mouse-avoidance-random-shape)) | 49 | ;; (setq x-pointer-shape (mouse-avoidance-random-shape)) |
| @@ -154,13 +154,15 @@ TOP-OR-BOTTOM-POS: Distance from top or bottom edge of frame or window." | |||
| 154 | (defun mouse-avoidance-point-position () | 154 | (defun mouse-avoidance-point-position () |
| 155 | "Return the position of point as (FRAME X . Y). | 155 | "Return the position of point as (FRAME X . Y). |
| 156 | Analogous to `mouse-position'." | 156 | Analogous to `mouse-position'." |
| 157 | (let ((edges (window-inside-edges)) | 157 | (let* ((edges (window-inside-edges)) |
| 158 | (x-y (posn-x-y (posn-at-point)))) | 158 | (posn-at-point (posn-at-point)) |
| 159 | (cons (selected-frame) | 159 | (x-y (and posn-at-point (posn-x-y posn-at-point)))) |
| 160 | (cons (+ (car edges) | 160 | (when x-y |
| 161 | (/ (car x-y) (frame-char-width))) | 161 | (cons (selected-frame) |
| 162 | (+ (car (cdr edges)) | 162 | (cons (+ (car edges) |
| 163 | (/ (cdr x-y) (frame-char-height))))))) | 163 | (/ (car x-y) (frame-char-width))) |
| 164 | (+ (car (cdr edges)) | ||
| 165 | (/ (cdr x-y) (frame-char-height)))))))) | ||
| 164 | 166 | ||
| 165 | ;(defun mouse-avoidance-point-position-test () | 167 | ;(defun mouse-avoidance-point-position-test () |
| 166 | ; (interactive) | 168 | ; (interactive) |
| @@ -185,19 +187,21 @@ MOUSE is the current mouse position as returned by `mouse-position'. | |||
| 185 | Acceptable distance is defined by `mouse-avoidance-threshold'." | 187 | Acceptable distance is defined by `mouse-avoidance-threshold'." |
| 186 | (let* ((frame (car mouse)) | 188 | (let* ((frame (car mouse)) |
| 187 | (mouse-y (cdr (cdr mouse))) | 189 | (mouse-y (cdr (cdr mouse))) |
| 188 | (tool-bar-lines (frame-parameter nil 'tool-bar-lines))) | 190 | (tool-bar-lines (frame-parameter nil 'tool-bar-lines)) |
| 191 | point) | ||
| 189 | (or tool-bar-lines | 192 | (or tool-bar-lines |
| 190 | (setq tool-bar-lines 0)) | 193 | (setq tool-bar-lines 0)) |
| 191 | (if (and mouse-y (< mouse-y tool-bar-lines)) | 194 | (cond |
| 192 | nil | 195 | ((and mouse-y (< mouse-y tool-bar-lines)) |
| 193 | (let ((point (mouse-avoidance-point-position)) | 196 | nil) |
| 194 | (mouse-x (car (cdr mouse)))) | 197 | ((setq point (mouse-avoidance-point-position)) |
| 198 | (let ((mouse-x (car (cdr mouse)))) | ||
| 195 | (and (eq frame (car point)) | 199 | (and (eq frame (car point)) |
| 196 | (not (null mouse-x)) | 200 | (not (null mouse-x)) |
| 197 | (< (abs (- mouse-x (car (cdr point)))) | 201 | (< (abs (- mouse-x (car (cdr point)))) |
| 198 | mouse-avoidance-threshold) | 202 | mouse-avoidance-threshold) |
| 199 | (< (abs (- mouse-y (cdr (cdr point)))) | 203 | (< (abs (- mouse-y (cdr (cdr point)))) |
| 200 | mouse-avoidance-threshold)))))) | 204 | mouse-avoidance-threshold))))))) |
| 201 | 205 | ||
| 202 | (defun mouse-avoidance-banish-destination () | 206 | (defun mouse-avoidance-banish-destination () |
| 203 | "The position to which Mouse Avoidance mode `banish' moves the mouse. | 207 | "The position to which Mouse Avoidance mode `banish' moves the mouse. |