aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Volpiatto2012-04-13 23:15:22 +0200
committerLars Ingebrigtsen2012-04-13 23:15:22 +0200
commit0f84437ba220c859513e692f3753c8162d53a4d6 (patch)
tree4833f62e581e4da59f5ee18359c98a796d0bafe0
parent7b55b8bf5a443019fa4054ec14d4482bf8889fae (diff)
downloademacs-0f84437ba220c859513e692f3753c8162d53a4d6.tar.gz
emacs-0f84437ba220c859513e692f3753c8162d53a4d6.zip
Allow further `mouse-avoidance-mode' customisations
* avoid.el (mouse-avoidance-banish-position): New variable. (mouse-avoidance-banish-destination): Use it.
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/avoid.el59
2 files changed, 57 insertions, 5 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 095f783b523..f20b7a840b7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -41,6 +41,9 @@ been adding them there, put them somewhere else, eg site-lisp.
41** M-x move-to-column, if called interactively with no prefix arg, now 41** M-x move-to-column, if called interactively with no prefix arg, now
42prompts for a column number. 42prompts for a column number.
43 43
44** `mouse-avoidance-banish-position' can now be used to customize
45`mouse-avoidance-mode' further.
46
44 47
45* Changes in Specialized Modes and Packages in Emacs 24.2 48* Changes in Specialized Modes and Packages in Emacs 24.2
46 49
diff --git a/lisp/avoid.el b/lisp/avoid.el
index 17d99fd6517..81e0737c849 100644
--- a/lisp/avoid.el
+++ b/lisp/avoid.el
@@ -115,6 +115,23 @@ Only applies in Mouse Avoidance modes `animate' and `jump'."
115 :type 'integer 115 :type 'integer
116 :group 'avoid) 116 :group 'avoid)
117 117
118(defcustom mouse-avoidance-banish-position '((frame-or-window . frame)
119 (side . right)
120 (side-pos . 3)
121 (top-or-bottom . top)
122 (top-or-bottom-pos . 0))
123 "Position to which Mouse Avoidance mode `banish' moves the mouse.
124An alist where keywords mean:
125FRAME-OR-WINDOW: banish the mouse to corner of frame or window.
126SIDE: banish the mouse on right or left corner of frame or window.
127SIDE-POS: Distance from right or left edge of frame or window.
128TOP-OR-BOTTOM: banish the mouse to top or bottom of frame or window.
129TOP-OR-BOTTOM-POS: Distance from top or bottom edge of frame or window."
130 :group 'avoid
131 :type '(alist :key-type symbol :value-type symbol)
132 :options '(frame-or-window side (side-pos integer)
133 top-or-bottom (top-or-bottom-pos integer)))
134
118;; Internal variables 135;; Internal variables
119(defvar mouse-avoidance-state nil) 136(defvar mouse-avoidance-state nil)
120(defvar mouse-avoidance-pointer-shapes nil) 137(defvar mouse-avoidance-pointer-shapes nil)
@@ -183,13 +200,45 @@ Acceptable distance is defined by `mouse-avoidance-threshold'."
183 200
184(defun mouse-avoidance-banish-destination () 201(defun mouse-avoidance-banish-destination ()
185 "The position to which Mouse Avoidance mode `banish' moves the mouse. 202 "The position to which Mouse Avoidance mode `banish' moves the mouse.
186You can redefine this if you want the mouse banished to a different corner." 203
187 (let* ((pos (window-edges))) 204If you want the mouse banished to a different corner set
188 (cons (- (nth 2 pos) 2) 205`mouse-avoidance-banish-position' as you need."
189 (nth 1 pos)))) 206 (let* ((fra-or-win (assoc-default
207 'frame-or-window
208 mouse-avoidance-banish-position 'eq))
209 (list-values (case fra-or-win
210 (frame (list 0 0 (frame-width) (frame-height)))
211 (window (window-edges))))
212 (alist (loop for v in list-values
213 for k in '(left top right bottom)
214 collect (cons k v)))
215 (side (assoc-default
216 'side
217 mouse-avoidance-banish-position 'eq))
218 (side-dist (assoc-default
219 'side-pos
220 mouse-avoidance-banish-position 'eq))
221 (top-or-bottom (assoc-default
222 'top-or-bottom
223 mouse-avoidance-banish-position 'eq))
224 (top-or-bottom-dist (assoc-default
225 'top-or-bottom-pos
226 mouse-avoidance-banish-position 'eq))
227 (side-fn (case side
228 (left '+)
229 (right '-)))
230 (top-or-bottom-fn (case top-or-bottom
231 (top '+)
232 (bottom '-))))
233 (cons (funcall side-fn ; -/+
234 (assoc-default side alist 'eq) ; right or left
235 side-dist) ; distance from side
236 (funcall top-or-bottom-fn ; -/+
237 (assoc-default top-or-bottom alist 'eq) ; top/bottom
238 top-or-bottom-dist)))) ; distance from top/bottom
190 239
191(defun mouse-avoidance-banish-mouse () 240(defun mouse-avoidance-banish-mouse ()
192 ;; Put the mouse pointer in the upper-right corner of the current frame. 241 "Put the mouse pointer to `mouse-avoidance-banish-position'."
193 (mouse-avoidance-set-mouse-position (mouse-avoidance-banish-destination))) 242 (mouse-avoidance-set-mouse-position (mouse-avoidance-banish-destination)))
194 243
195(defsubst mouse-avoidance-delta (cur delta dist var min max) 244(defsubst mouse-avoidance-delta (cur delta dist var min max)