aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/avoid.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/avoid.el')
-rw-r--r--lisp/avoid.el25
1 files changed, 15 insertions, 10 deletions
diff --git a/lisp/avoid.el b/lisp/avoid.el
index 1868707720e..b497c2007bd 100644
--- a/lisp/avoid.el
+++ b/lisp/avoid.el
@@ -124,6 +124,7 @@ Only applies in mouse-avoidance-modes `animate' and `jump'."
124(defvar mouse-avoidance-pointer-shapes nil) 124(defvar mouse-avoidance-pointer-shapes nil)
125(defvar mouse-avoidance-n-pointer-shapes 0) 125(defvar mouse-avoidance-n-pointer-shapes 0)
126(defvar mouse-avoidance-old-pointer-shape nil) 126(defvar mouse-avoidance-old-pointer-shape nil)
127(defvar mouse-avoidance-animating-pointer nil)
127 128
128;; This timer is used to run something when Emacs is idle. 129;; This timer is used to run something when Emacs is idle.
129(defvar mouse-avoidance-timer nil) 130(defvar mouse-avoidance-timer nil)
@@ -243,16 +244,19 @@ You can redefine this if you want the mouse banished to a different corner."
243 (+ (cdr mouse-avoidance-state) deltay))) 244 (+ (cdr mouse-avoidance-state) deltay)))
244 (if (or (eq mouse-avoidance-mode 'animate) 245 (if (or (eq mouse-avoidance-mode 'animate)
245 (eq mouse-avoidance-mode 'proteus)) 246 (eq mouse-avoidance-mode 'proteus))
246 (let ((i 0.0)) 247 (let ((i 0.0)
248 (incr (max .1 (/ 1.0 mouse-avoidance-nudge-dist))))
249 (setq mouse-avoidance-animating-pointer t)
247 (while (<= i 1) 250 (while (<= i 1)
248 (mouse-avoidance-set-mouse-position 251 (mouse-avoidance-set-mouse-position
249 (cons (+ (car cur-pos) (round (* i deltax))) 252 (cons (+ (car cur-pos) (round (* i deltax)))
250 (+ (cdr cur-pos) (round (* i deltay))))) 253 (+ (cdr cur-pos) (round (* i deltay)))))
251 (setq i (+ i (max .1 (/ 1.0 mouse-avoidance-nudge-dist)))) 254 (setq i (+ i incr))
252 (if (eq mouse-avoidance-mode 'proteus) 255 (if (eq mouse-avoidance-mode 'proteus)
253 (mouse-avoidance-set-pointer-shape 256 (mouse-avoidance-set-pointer-shape
254 (mouse-avoidance-random-shape))) 257 (mouse-avoidance-random-shape)))
255 (sit-for mouse-avoidance-animation-delay))) 258 (sit-for mouse-avoidance-animation-delay))
259 (setq mouse-avoidance-animating-pointer nil))
256 (mouse-avoidance-set-mouse-position (cons (+ (car (cdr cur)) deltax) 260 (mouse-avoidance-set-mouse-position (cons (+ (car (cdr cur)) deltax)
257 (+ (cdr (cdr cur)) deltay)))))) 261 (+ (cdr (cdr cur)) deltay))))))
258 262
@@ -294,11 +298,11 @@ redefine this function to suit your own tastes."
294 (memq 'drag modifiers) 298 (memq 'drag modifiers)
295 (memq 'down modifiers))))))) 299 (memq 'down modifiers)))))))
296 300
297(defun mouse-avoidance-banish-hook () 301(defun mouse-avoidance-banish ()
298 (if (not (mouse-avoidance-ignore-p)) 302 (if (not (mouse-avoidance-ignore-p))
299 (mouse-avoidance-banish-mouse))) 303 (mouse-avoidance-banish-mouse)))
300 304
301(defun mouse-avoidance-exile-hook () 305(defun mouse-avoidance-exile ()
302 ;; For exile mode, the state is nil when the mouse is in its normal 306 ;; For exile mode, the state is nil when the mouse is in its normal
303 ;; position, and set to the old mouse-position when the mouse is in exile. 307 ;; position, and set to the old mouse-position when the mouse is in exile.
304 (if (not (mouse-avoidance-ignore-p)) 308 (if (not (mouse-avoidance-ignore-p))
@@ -317,9 +321,10 @@ redefine this function to suit your own tastes."
317 ;; but clear state anyway, to be ready for another move 321 ;; but clear state anyway, to be ready for another move
318 (setq mouse-avoidance-state nil)))))) 322 (setq mouse-avoidance-state nil))))))
319 323
320(defun mouse-avoidance-fancy-hook () 324(defun mouse-avoidance-fancy ()
321 ;; Used for the "fancy" modes, ie jump et al. 325 ;; Used for the "fancy" modes, ie jump et al.
322 (if (and (not (mouse-avoidance-ignore-p)) 326 (if (and (not mouse-avoidance-animating-pointer)
327 (not (mouse-avoidance-ignore-p))
323 (mouse-avoidance-too-close-p (mouse-position))) 328 (mouse-avoidance-too-close-p (mouse-position)))
324 (let ((old-pos (mouse-position))) 329 (let ((old-pos (mouse-position)))
325 (mouse-avoidance-nudge-mouse) 330 (mouse-avoidance-nudge-mouse)
@@ -375,14 +380,14 @@ definition of \"random distance\".)"
375 (eq mode 'animate) 380 (eq mode 'animate)
376 (eq mode 'proteus)) 381 (eq mode 'proteus))
377 (setq mouse-avoidance-timer 382 (setq mouse-avoidance-timer
378 (run-with-idle-timer 0.1 t 'mouse-avoidance-fancy-hook)) 383 (run-with-idle-timer 0.1 t 'mouse-avoidance-fancy))
379 (setq mouse-avoidance-mode mode 384 (setq mouse-avoidance-mode mode
380 mouse-avoidance-state (cons 0 0) 385 mouse-avoidance-state (cons 0 0)
381 mouse-avoidance-old-pointer-shape 386 mouse-avoidance-old-pointer-shape
382 (and (boundp 'x-pointer-shape) x-pointer-shape))) 387 (and (boundp 'x-pointer-shape) x-pointer-shape)))
383 ((eq mode 'exile) 388 ((eq mode 'exile)
384 (setq mouse-avoidance-timer 389 (setq mouse-avoidance-timer
385 (run-with-idle-timer 0.1 t 'mouse-avoidance-exile-hook)) 390 (run-with-idle-timer 0.1 t 'mouse-avoidance-exile))
386 (setq mouse-avoidance-mode mode 391 (setq mouse-avoidance-mode mode
387 mouse-avoidance-state nil)) 392 mouse-avoidance-state nil))
388 ((or (eq mode 'banish) 393 ((or (eq mode 'banish)
@@ -390,7 +395,7 @@ definition of \"random distance\".)"
390 (and (null mode) (null mouse-avoidance-mode)) 395 (and (null mode) (null mouse-avoidance-mode))
391 (and mode (> (prefix-numeric-value mode) 0))) 396 (and mode (> (prefix-numeric-value mode) 0)))
392 (setq mouse-avoidance-timer 397 (setq mouse-avoidance-timer
393 (run-with-idle-timer 0.1 t 'mouse-avoidance-banish-hook)) 398 (run-with-idle-timer 0.1 t 'mouse-avoidance-banish))
394 (setq mouse-avoidance-mode 'banish)) 399 (setq mouse-avoidance-mode 'banish))
395 (t (setq mouse-avoidance-mode nil))) 400 (t (setq mouse-avoidance-mode nil)))
396 (force-mode-line-update)) 401 (force-mode-line-update))