Mercurial > emacs
changeset 19323:b686f7cb6849
(mouse-avoidance-timer): New variable.
(mouse-avoidance-mode): Create or cancel a time,
instead of using post-command-idle-hook.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 12 Aug 1997 18:20:00 +0000 |
parents | cc9e75f82cdb |
children | 02a8fe146fa6 |
files | lisp/avoid.el |
diffstat | 1 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/avoid.el Tue Aug 12 17:23:14 1997 +0000 +++ b/lisp/avoid.el Tue Aug 12 18:20:00 1997 +0000 @@ -111,6 +111,9 @@ (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 @@ 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 @@ ((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))