annotate lisp/packages/avoid.el @ 194:2947057885e5

Added tag r20-3b23 for changeset f53b5ca2e663
author cvs
date Mon, 13 Aug 2007 09:58:32 +0200
parents 489f57a838ef
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1 ;;; avoid.el --- make mouse pointer stay out of the way of editing
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
5 ;; Author: Boris Goldowsky <boris@gnu.ai.mit.edu>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Version: 1.10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
24 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
26 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
30 ;; For those who are annoyed by the mouse pointer obscuring text,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
31 ;; this mode moves the mouse pointer - either just a little out of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
32 ;; the way, or all the way to the corner of the frame.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
33 ;; To use, load or evaluate this file and type M-x mouse-avoidance-mode .
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
34 ;; To set up permanently, put this file on your .emacs:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
35 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
36 ;; (if window-system (mouse-avoidance-mode 'animate))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
37 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
38 ;; The 'animate can be 'jump or 'banish or 'exile or 'protean if you prefer.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
39 ;; See the documentation for function `mouse-avoidance-mode' for
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
40 ;; details of the different modes.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
41 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
42 ;; For added silliness, make the animatee animate...
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
43 ;; put something similar to the following into your .emacs:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
44 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
45 ;; (if window-system
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
46 ;; (mouse-avoidance-set-pointer-shape
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
47 ;; (eval (nth (random 4)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
48 ;; '(x-pointer-man x-pointer-spider
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
49 ;; x-pointer-gobbler x-pointer-gumby)))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
50 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
51 ;; For completely random pointer shape, replace the setq above with:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
52 ;; (setq x-pointer-shape (mouse-avoidance-random-shape))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
53 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
54 ;; Bugs / Warnings / To-Do:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
55 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
56 ;; - Using this code does slow emacs down. "banish" mode shouldn't
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
57 ;; be too bad, and on my workstation even "animate" is reasonable.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
58 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
59 ;; - It ought find out where any overlapping frames are and avoid them,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
60 ;; rather than always raising the frame.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
61
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
62 ;; Credits:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
63 ;; This code was helped by all those who contributed suggestions,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
64 ;; fixes, and additions
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
65 ;; Joe Harrington (and his advisor), for the original inspiration.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
66 ;; Ken Manheimer, for dreaming up the Protean mode.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
67 ;; Richard Stallman, for the awful cat-and-mouse pun, among other things.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
68 ;; Mike Williams, Denis Howe, Bill Benedetto, Chris Moore, Don Morris,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
69 ;; Simon Marshall, and M.S. Ashton, for their feedback.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
70
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (provide 'avoid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
75 (defgroup avoid nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
76 "Make mouse pointer stay out of the way of editing."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
77 :prefix "mouse-avoidance-"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
78 :group 'mouse)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
79
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
80
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
81 ;;;###autoload
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
82 (defcustom mouse-avoidance-mode nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 "Value is t or a symbol if the mouse pointer should avoid the cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 See function `mouse-avoidance-mode' for possible values. Changing this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 variable is NOT the recommended way to change modes; use that function
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
86 instead."
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
87 :type '(radio
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
88 (const :tag "No mouse avoidance" nil)
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
89 (const :tag "Move the mouse on keypress" banish)
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
90 (const :tag "Move the mouse if the cursor gets too close" exile)
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
91 (const :tag "Displace the mouse if the cursor gets too close" jump)
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
92 (const :tag "Animate the mouse" animate)
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
93 (const :tag "Animate + change shape" proteus))
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
94 :set (lambda (symbol value)
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
95 (mouse-avoidance-mode (or value 'none)))
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
96 :initialize 'custom-initialize-default
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
97 :require 'avoid
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 134
diff changeset
98 :group 'avoid)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
100 (defcustom mouse-avoidance-nudge-dist 15
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 "*Average distance that mouse will be moved when approached by cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 Only applies in mouse-avoidance-mode `jump' and its derivatives.
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
103 For best results make this larger than `mouse-avoidance-threshold'."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
104 :type 'integer
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
105 :group 'avoid)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
107 (defcustom mouse-avoidance-nudge-var 10
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
108 "*Variability of `mouse-avoidance-nudge-dist' (which see)."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
109 :type 'integer
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
110 :group 'avoid)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
112 (defcustom mouse-avoidance-animation-delay .01
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
113 "Delay between animation steps, in seconds."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
114 :type 'number
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
115 :group 'avoid)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
116
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
117 (defcustom mouse-avoidance-threshold 5
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 "*Mouse-pointer's flight distance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 If the cursor gets closer than this, the mouse pointer will move away.
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
120 Only applies in mouse-avoidance-modes `animate' and `jump'."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
121 :type 'integer
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
122 :group 'avoid)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; Internal variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defvar mouse-avoidance-state nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (defvar mouse-avoidance-pointer-shapes nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (defvar mouse-avoidance-n-pointer-shapes 0)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
128 (defvar mouse-avoidance-old-pointer-shape nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;; Functions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
132 (defsubst mouse-avoidance-set-pointer-shape (shape)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
133 "Set the shape of the mouse pointer to SHAPE."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
134 (setq x-pointer-shape shape)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
135 (set-mouse-color nil))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
136
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
137 ;; XEmacs change -- this is so ugly. [FSF version is totally different -sb]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (defun mouse-avoidance-point-position ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 "Returns (WINDOW X . Y) of current point - analogous to mouse-position"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (let* ((beg (window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (col (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (row))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (setq row (count-lines beg pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (cons (selected-window) (cons col row))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;(defun mouse-avoidance-point-position-test ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ; (interactive)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
149 ; (message "point=%s mouse=%s"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
150 ; (cdr (mouse-avoidance-point-position))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
151 ; (cdr (mouse-position))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defun mouse-avoidance-set-mouse-position (pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; Carefully set mouse position to given position (X . Y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; Ideally, should check if X,Y is in the current frame, and if not,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; leave the mouse where it was. However, this is currently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; difficult to do, so we just raise the frame to avoid frame switches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; Returns t if it moved the mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (let ((f (selected-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (raise-frame f)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
161 ;; XEmacs: FSF version of set-mouse-position requires FRAME parameter
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (set-mouse-position (frame-selected-window f) (car pos) (cdr pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (defun mouse-avoidance-too-close-p (mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; Return t if mouse pointer and point cursor are too close.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; Acceptable distance is defined by mouse-avoidance-threshold.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (let ((point (mouse-avoidance-point-position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (and (eq (car mouse) (car point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (car (cdr mouse))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (< (abs (- (car (cdr mouse)) (car (cdr point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 mouse-avoidance-threshold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (< (abs (- (cdr (cdr mouse)) (cdr (cdr point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 mouse-avoidance-threshold))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (defun mouse-avoidance-banish-destination ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 "The position to which mouse-avoidance-mode `banish' moves the mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 You can redefine this if you want the mouse banished to a different corner."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (cons (1- (frame-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (defun mouse-avoidance-banish-mouse ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; Put the mouse pointer in the upper-right corner of the current frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (mouse-avoidance-set-mouse-position (mouse-avoidance-banish-destination)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (defsubst mouse-avoidance-delta (cur delta dist var min max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; Decide how far to move in either dimension.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; Args are the CURRENT location, the desired DELTA for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; warp-conservation, the DISTANCE we like to move, the VARIABILITY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; in distance allowed, and the MIN and MAX possible window positions.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
191 ;; Returns something as close to DELTA as possible within the constraints.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (let ((L1 (max (- min cur) (+ (- dist) (- var))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (R1 (+ (- dist) var ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (L2 (+ dist (- var)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (R2 (min (- max cur) (+ dist var))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (if (< R1 (- min cur)) (setq L1 nil R1 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (if (> L2 (- max cur)) (setq L2 nil R2 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (cond ((and L1 (< delta L1)) L1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ((and R1 (< delta R1)) delta)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ((and R1 (< delta 0)) R1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ((and L2 (< delta L2)) L2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ((and R2 (< delta R2)) delta)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (R2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ((or R1 L2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (t 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (defun mouse-avoidance-nudge-mouse ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; Push the mouse a little way away, possibly animating the move
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; For these modes, state keeps track of the total offset that we've
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; accumulated, and tries to keep it close to zero.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (let* ((cur (mouse-position))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
212 (cur-frame (car cur))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (cur-pos (cdr cur))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (deltax (mouse-avoidance-delta
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (car cur-pos) (- (random mouse-avoidance-nudge-var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (car mouse-avoidance-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 mouse-avoidance-nudge-dist mouse-avoidance-nudge-var
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 0 (frame-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (deltay (mouse-avoidance-delta
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (cdr cur-pos) (- (random mouse-avoidance-nudge-var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (cdr mouse-avoidance-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 mouse-avoidance-nudge-dist mouse-avoidance-nudge-var
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
223 0 (frame-height))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (setq mouse-avoidance-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (cons (+ (car mouse-avoidance-state) deltax)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (+ (cdr mouse-avoidance-state) deltay)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (if (or (eq mouse-avoidance-mode 'animate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (eq mouse-avoidance-mode 'proteus))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (let ((i 0.0)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
230 ;; XEmacs change
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (color (cdr (assoc 'mouse-color (frame-parameters)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (while (<= i 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (mouse-avoidance-set-mouse-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (cons (+ (car cur-pos) (round (* i deltax)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (+ (cdr cur-pos) (round (* i deltay)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (setq i (+ i (max .1 (/ 1.0 mouse-avoidance-nudge-dist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (if (eq mouse-avoidance-mode 'proteus)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
238 ;; XEmacs change
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (setq x-pointer-shape (mouse-avoidance-random-shape))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (set-mouse-color color)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (sit-for mouse-avoidance-animation-delay)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (mouse-avoidance-set-mouse-position (cons (+ (car (cdr cur)) deltax)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (+ (cdr (cdr cur)) deltay))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (defun mouse-avoidance-random-shape ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 "Return a random cursor shape.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 This assumes that any variable whose name begins with x-pointer- and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 has an integer value is a valid cursor shape. You might want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 redefine this function to suit your own tastes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (if (null mouse-avoidance-pointer-shapes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (setq mouse-avoidance-pointer-shapes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (mapcar '(lambda (x) (symbol-value (intern x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (all-completions "x-pointer-" obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 '(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (and (boundp x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (integerp (symbol-value x)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (setq mouse-avoidance-n-pointer-shapes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (length mouse-avoidance-pointer-shapes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (nth (random mouse-avoidance-n-pointer-shapes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 mouse-avoidance-pointer-shapes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (defun mouse-avoidance-banish-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (if (and (not executing-kbd-macro) ; don't check inside macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (mouse-avoidance-kbd-command (this-command-keys)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (mouse-avoidance-banish-mouse)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (defun mouse-avoidance-exile-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; For exile mode, the state is nil when the mouse is in its normal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; position, and set to the old mouse-position when the mouse is in exile.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (if (and (not executing-kbd-macro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (mouse-avoidance-kbd-command (this-command-keys)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (let ((mp (mouse-position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (cond ((and (not mouse-avoidance-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (mouse-avoidance-too-close-p mp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (setq mouse-avoidance-state mp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (mouse-avoidance-banish-mouse))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ((and mouse-avoidance-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (not (mouse-avoidance-too-close-p mouse-avoidance-state)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
281 ;; XEmacs change
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (if (and (eq (car mp) (if (< emacs-minor-version 12)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (selected-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (equal (cdr mp) (mouse-avoidance-banish-destination)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (mouse-avoidance-set-mouse-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;; move back only if user has not moved mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (cdr mouse-avoidance-state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;; but clear state anyway, to be ready for another move
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (setq mouse-avoidance-state nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (defun mouse-avoidance-fancy-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; Used for the "fancy" modes, ie jump et al.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (if (and (not executing-kbd-macro) ; don't check inside macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (mouse-avoidance-kbd-command (this-command-keys))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (mouse-avoidance-too-close-p (mouse-position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (let ((old-pos (mouse-position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (mouse-avoidance-nudge-mouse)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
299 ;; XEmacs change
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (if (not (eq (if (< emacs-minor-version 12)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (selected-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (selected-window)) (car old-pos))) ; move went awry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (set-mouse-position (car old-pos) ; sigh..
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (car (cdr old-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (cdr (cdr old-pos)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (defun mouse-avoidance-kbd-command (key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 "Return t if the KEYSEQENCE is composed of keyboard events only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 Return nil if there are any lists in the key sequence."
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
310 (cond ((null key) nil) ; Null event seems to be
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ; returned occasionally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ((not (vectorp key)) t) ; Strings are keyboard events.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ((catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (let ((i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (l (length key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (while (< i l)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
317 ;; XEmacs change: (Emacs version was: (listp (aref key i)))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 80
diff changeset
318 (if (not (key-press-event-p (aref key i)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (throw 'done nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (setq i (1+ i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
323 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (defun mouse-avoidance-mode (&optional mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 "Set cursor avoidance mode to MODE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 MODE should be one of the symbols `banish', `exile', `jump', `animate',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 `cat-and-mouse', `proteus', or `none'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 If MODE is nil, toggle mouse avoidance between `none` and `banish'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 modes. Positive numbers and symbols other than the above are treated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 as equivalent to `banish'; negative numbers and `-' are equivalent to `none'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 Effects of the different modes:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 * banish: Move the mouse to the upper-right corner on any keypress.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 * exile: Move the mouse to the corner only if the cursor gets too close,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 and allow it to return once the cursor is out of the way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 * jump: If the cursor gets too close to the mouse, displace the mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 a random distance & direction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 * animate: As `jump', but shows steps along the way for illusion of motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 * cat-and-mouse: Same as `animate'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 * proteus: As `animate', but changes the shape of the mouse pointer too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 Whenever the mouse is moved, the frame is also raised.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 \(see `mouse-avoidance-threshold' for definition of \"too close\",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 and `mouse-avoidance-nudge-dist' and `mouse-avoidance-nudge-var' for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 definition of \"random distance\".)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (list (intern (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 "Select cursor avoidance technique (SPACE for list): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 '(("banish") ("exile") ("jump") ("animate")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ("cat-and-mouse") ("proteus") ("none"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (if (eq mode 'cat-and-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (setq mode 'animate))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
356 ;; XEmacs change - We don't have post-command-idle-hook
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
357 (remove-hook 'post-command-hook 'mouse-avoidance-banish-hook)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
358 (remove-hook 'post-command-hook 'mouse-avoidance-exile-hook)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
359 (remove-hook 'post-command-hook 'mouse-avoidance-fancy-hook)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
360 ;; Restore pointer shape if necessary
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
361 (if (eq mouse-avoidance-mode 'proteus)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
362 (mouse-avoidance-set-pointer-shape mouse-avoidance-old-pointer-shape))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
363
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
364 ;; Do additional setup depending on version of mode requested
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (cond ((eq mode 'none)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (setq mouse-avoidance-mode nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ((or (eq mode 'jump)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (eq mode 'animate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (eq mode 'proteus))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
370 ;; XEmacs: we don't have post-command-idle-hook
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (add-hook 'post-command-hook 'mouse-avoidance-fancy-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (setq mouse-avoidance-mode mode
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
373 mouse-avoidance-state (cons 0 0)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
374 mouse-avoidance-old-pointer-shape x-pointer-shape))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ((eq mode 'exile)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
376 ;; XEmacs: FSF uses post-command-idle-hook
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (add-hook 'post-command-hook 'mouse-avoidance-exile-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (setq mouse-avoidance-mode mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 mouse-avoidance-state nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ((or (eq mode 'banish)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (eq mode t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (and (null mode) (null mouse-avoidance-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (and mode (> (prefix-numeric-value mode) 0)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
384 ;; XEmacs: FSF uses post-command-idle-hook
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (add-hook 'post-command-hook 'mouse-avoidance-banish-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (setq mouse-avoidance-mode 'banish))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (t (setq mouse-avoidance-mode nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (force-mode-line-update))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 ;(or (assq 'mouse-avoidance-mode minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ; (setq minor-mode-alist (cons '(mouse-avoidance-mode " Avoid")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 ; minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ;;XEmacs: do it right.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (add-minor-mode 'mouse-avoidance-mode " Avoid")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
397 ;;; avoid.el ends here