comparison lisp/avoid.el @ 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 efafba146bb5
children 808ecc2eaa84
comparison
equal deleted inserted replaced
20992:d2366423bc00 20993:c87385403522
265 (nth (random mouse-avoidance-n-pointer-shapes) 265 (nth (random mouse-avoidance-n-pointer-shapes)
266 mouse-avoidance-pointer-shapes)) 266 mouse-avoidance-pointer-shapes))
267 267
268 (defun mouse-avoidance-banish-hook () 268 (defun mouse-avoidance-banish-hook ()
269 (if (and (not executing-kbd-macro) ; don't check inside macro 269 (if (and (not executing-kbd-macro) ; don't check inside macro
270 ;; Don't check while mouse is down. 270 ;; Don't do anything if last event was a mouse event.
271 (not (and (consp last-input-event) 271 (not (and (consp last-input-event)
272 (symbolp (car last-input-event)) 272 (symbolp (car last-input-event))
273 (memq 'down (event-modifiers (car last-input-event))))) 273 (let ((modifiers (event-modifiers (car last-input-event))))
274 (mouse-avoidance-kbd-command (this-command-keys))) 274 (or (memq (car last-input-event)
275 '(mouse-movement scroll-bar-movement))
276 (memq 'click modifiers)
277 (memq 'drag modifiers)
278 (memq 'down modifiers))))))
275 (mouse-avoidance-banish-mouse))) 279 (mouse-avoidance-banish-mouse)))
276 280
277 (defun mouse-avoidance-exile-hook () 281 (defun mouse-avoidance-exile-hook ()
278 ;; For exile mode, the state is nil when the mouse is in its normal 282 ;; For exile mode, the state is nil when the mouse is in its normal
279 ;; position, and set to the old mouse-position when the mouse is in exile. 283 ;; position, and set to the old mouse-position when the mouse is in exile.
280 (if (and (not executing-kbd-macro) 284 (if (and (not executing-kbd-macro)
285 ;; Don't do anything if last event was a mouse event.
281 (not (and (consp last-input-event) 286 (not (and (consp last-input-event)
282 (symbolp (car last-input-event)) 287 (symbolp (car last-input-event))
283 (memq 'down (event-modifiers (car last-input-event))))) 288 (let ((modifiers (event-modifiers (car last-input-event))))
284 (mouse-avoidance-kbd-command (this-command-keys))) 289 (or (memq (car last-input-event)
290 '(mouse-movement scroll-bar-movement))
291 (memq 'click modifiers)
292 (memq 'drag modifiers)
293 (memq 'down modifiers))))))
285 (let ((mp (mouse-position))) 294 (let ((mp (mouse-position)))
286 (cond ((and (not mouse-avoidance-state) 295 (cond ((and (not mouse-avoidance-state)
287 (mouse-avoidance-too-close-p mp)) 296 (mouse-avoidance-too-close-p mp))
288 (setq mouse-avoidance-state mp) 297 (setq mouse-avoidance-state mp)
289 (mouse-avoidance-banish-mouse)) 298 (mouse-avoidance-banish-mouse))
298 (setq mouse-avoidance-state nil)))))) 307 (setq mouse-avoidance-state nil))))))
299 308
300 (defun mouse-avoidance-fancy-hook () 309 (defun mouse-avoidance-fancy-hook ()
301 ;; Used for the "fancy" modes, ie jump et al. 310 ;; Used for the "fancy" modes, ie jump et al.
302 (if (and (not executing-kbd-macro) ; don't check inside macro 311 (if (and (not executing-kbd-macro) ; don't check inside macro
312 ;; Don't do anything if last event was a mouse event.
303 (not (and (consp last-input-event) 313 (not (and (consp last-input-event)
304 (symbolp (car last-input-event)) 314 (symbolp (car last-input-event))
305 (memq 'down (event-modifiers (car last-input-event))))) 315 (let ((modifiers (event-modifiers (car last-input-event))))
306 (mouse-avoidance-kbd-command (this-command-keys)) 316 (or (memq (car last-input-event)
317 '(mouse-movement scroll-bar-movement))
318 (memq 'click modifiers)
319 (memq 'drag modifiers)
320 (memq 'down modifiers)))))
307 (mouse-avoidance-too-close-p (mouse-position))) 321 (mouse-avoidance-too-close-p (mouse-position)))
308 (let ((old-pos (mouse-position))) 322 (let ((old-pos (mouse-position)))
309 (mouse-avoidance-nudge-mouse) 323 (mouse-avoidance-nudge-mouse)
310 (if (not (eq (selected-frame) (car old-pos))) 324 (if (not (eq (selected-frame) (car old-pos)))
311 ;; This should never happen. 325 ;; This should never happen.
312 (apply 'set-mouse-position old-pos))))) 326 (apply 'set-mouse-position old-pos)))))
313
314 (defun mouse-avoidance-kbd-command (key)
315 "Return t if the KEYSEQENCE is composed of keyboard events only.
316 Return nil if there are any lists in the key sequence."
317 (cond ((null key) nil) ; Null event seems to be
318 ; returned occasionally.
319 ((not (vectorp key)) t) ; Strings are keyboard events.
320 ((catch 'done
321 (let ((i 0)
322 (l (length key)))
323 (while (< i l)
324 (if (listp (aref key i))
325 (throw 'done nil))
326 (setq i (1+ i))))
327 t))))
328 327
329 ;;;###autoload 328 ;;;###autoload
330 (defun mouse-avoidance-mode (&optional mode) 329 (defun mouse-avoidance-mode (&optional mode)
331 "Set cursor avoidance mode to MODE. 330 "Set cursor avoidance mode to MODE.
332 MODE should be one of the symbols `banish', `exile', `jump', `animate', 331 MODE should be one of the symbols `banish', `exile', `jump', `animate',