changeset 20993:c87385403522

(mouse-avoidance-kbd-command): Function deleted. (mouse-avoidance-fancy-hook, mouse-avoidance-exile-hook) (mouse-avoidance-banish-hook): Test whether last command was a mouse command of any kind.
author Richard M. Stallman <rms@gnu.org>
date Fri, 27 Feb 1998 21:52:27 +0000
parents d2366423bc00
children 4d4daf482e68
files lisp/avoid.el
diffstat 1 files changed, 21 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/avoid.el	Fri Feb 27 21:52:08 1998 +0000
+++ b/lisp/avoid.el	Fri Feb 27 21:52:27 1998 +0000
@@ -267,21 +267,30 @@
 
 (defun mouse-avoidance-banish-hook ()
   (if (and (not executing-kbd-macro)	; don't check inside macro
-	   ;; Don't check while mouse is down.
+	   ;; Don't do anything if last event was a mouse event.
 	   (not (and (consp last-input-event)
 		     (symbolp (car last-input-event))
-		     (memq 'down (event-modifiers (car last-input-event)))))
-	   (mouse-avoidance-kbd-command (this-command-keys)))
+		     (let ((modifiers (event-modifiers (car last-input-event))))
+		       (or (memq (car last-input-event)
+				 '(mouse-movement scroll-bar-movement))
+			   (memq 'click modifiers)
+			   (memq 'drag modifiers)
+			   (memq 'down modifiers))))))
       (mouse-avoidance-banish-mouse)))
 
 (defun mouse-avoidance-exile-hook ()
   ;; For exile mode, the state is nil when the mouse is in its normal
   ;; position, and set to the old mouse-position when the mouse is in exile.
   (if (and (not executing-kbd-macro)
+	   ;; Don't do anything if last event was a mouse event.
 	   (not (and (consp last-input-event)
 		     (symbolp (car last-input-event))
-		     (memq 'down (event-modifiers (car last-input-event)))))
-	   (mouse-avoidance-kbd-command (this-command-keys)))
+		     (let ((modifiers (event-modifiers (car last-input-event))))
+		       (or (memq (car last-input-event)
+				 '(mouse-movement scroll-bar-movement))
+			   (memq 'click modifiers)
+			   (memq 'drag modifiers)
+			   (memq 'down modifiers))))))
       (let ((mp (mouse-position)))
 	(cond ((and (not mouse-avoidance-state)
 		    (mouse-avoidance-too-close-p mp))
@@ -300,10 +309,15 @@
 (defun mouse-avoidance-fancy-hook ()
   ;; Used for the "fancy" modes, ie jump et al.
   (if (and (not executing-kbd-macro)	; don't check inside macro
+	   ;; Don't do anything if last event was a mouse event.
 	   (not (and (consp last-input-event)
 		     (symbolp (car last-input-event))
-		     (memq 'down (event-modifiers (car last-input-event)))))
-	   (mouse-avoidance-kbd-command (this-command-keys))
+		     (let ((modifiers (event-modifiers (car last-input-event))))
+		       (or (memq (car last-input-event)
+				 '(mouse-movement scroll-bar-movement))
+			   (memq 'click modifiers)
+			   (memq 'drag modifiers)
+			   (memq 'down modifiers)))))
 	   (mouse-avoidance-too-close-p (mouse-position)))
       (let ((old-pos (mouse-position)))
 	(mouse-avoidance-nudge-mouse)
@@ -311,21 +325,6 @@
 	    ;; This should never happen.
 	    (apply 'set-mouse-position old-pos)))))
 
-(defun mouse-avoidance-kbd-command (key)
-  "Return t if the KEYSEQENCE is composed of keyboard events only.
-Return nil if there are any lists in the key sequence."
-  (cond ((null key) nil)		; Null event seems to be
-					; returned occasionally.
-	((not (vectorp key)) t)		; Strings are keyboard events.
-	((catch 'done
-	   (let ((i 0)
-		 (l (length key)))
-	     (while (< i l)
-	       (if (listp (aref key i))
-		   (throw 'done nil))
-	       (setq i (1+ i))))
-	   t))))
-
 ;;;###autoload
 (defun mouse-avoidance-mode (&optional mode)
   "Set cursor avoidance mode to MODE.