diff options
author | Richard M. Stallman <rms@gnu.org> | 1997-08-12 18:20:00 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1997-08-12 18:20:00 +0000 |
commit | 85c922901f4187472ebd99f2c2b26e63467bcfa2 (patch) | |
tree | 1976ee1802e0de7e5e7be17fbfa9cdaa50874a6d /lisp/avoid.el | |
parent | a1bf98fa223ddafc0421c3200f7600e972c304e9 (diff) | |
download | emacs-85c922901f4187472ebd99f2c2b26e63467bcfa2.tar.gz |
(mouse-avoidance-timer): New variable.
(mouse-avoidance-mode): Create or cancel a time,
instead of using post-command-idle-hook.
Diffstat (limited to 'lisp/avoid.el')
-rw-r--r-- | lisp/avoid.el | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lisp/avoid.el b/lisp/avoid.el index 48f0914f163..7aee1e6b11e 100644 --- a/lisp/avoid.el +++ b/lisp/avoid.el @@ -111,6 +111,9 @@ Only applies in mouse-avoidance-modes `animate' and `jump'." (defvar mouse-avoidance-n-pointer-shapes 0) (defvar mouse-avoidance-old-pointer-shape nil) +;; This timer is used to run something when Emacs is idle. +(defvar mouse-avoidance-timer nil) + ;;; Functions: (defsubst mouse-avoidance-set-pointer-shape (shape) @@ -335,9 +338,9 @@ definition of \"random distance\".)" nil t)))) (if (eq mode 'cat-and-mouse) (setq mode 'animate)) - (remove-hook 'post-command-idle-hook 'mouse-avoidance-banish-hook) - (remove-hook 'post-command-idle-hook 'mouse-avoidance-exile-hook) - (remove-hook 'post-command-idle-hook 'mouse-avoidance-fancy-hook) + (if mouse-avoidance-timer + (cancel-timer mouse-avoidance-timer)) + (setq mouse-avoidance-timer nil) ;; Restore pointer shape if necessary (if (eq mouse-avoidance-mode 'proteus) @@ -349,19 +352,22 @@ definition of \"random distance\".)" ((or (eq mode 'jump) (eq mode 'animate) (eq mode 'proteus)) - (add-hook 'post-command-idle-hook 'mouse-avoidance-fancy-hook) + (setq mouse-avoidance-timer + (run-with-idle-timer 0.1 t 'mouse-avoidance-fancy-hook)) (setq mouse-avoidance-mode mode mouse-avoidance-state (cons 0 0) mouse-avoidance-old-pointer-shape x-pointer-shape)) ((eq mode 'exile) - (add-hook 'post-command-idle-hook 'mouse-avoidance-exile-hook) + (setq mouse-avoidance-timer + (run-with-idle-timer 0.1 t 'mouse-avoidance-exile-hook)) (setq mouse-avoidance-mode mode mouse-avoidance-state nil)) ((or (eq mode 'banish) (eq mode t) (and (null mode) (null mouse-avoidance-mode)) (and mode (> (prefix-numeric-value mode) 0))) - (add-hook 'post-command-idle-hook 'mouse-avoidance-banish-hook) + (setq mouse-avoidance-timer + (run-with-idle-timer 0.1 t 'mouse-avoidance-banish-hook)) (setq mouse-avoidance-mode 'banish)) (t (setq mouse-avoidance-mode nil))) (force-mode-line-update)) |