Function: strokes-event-closest-point

strokes-event-closest-point is a byte-compiled function defined in strokes.el.gz.

Signature

(strokes-event-closest-point EVENT &optional START-WINDOW)

Documentation

Return the nearest position to where EVENT ended its motion.

This is computed for the window where EVENT's motion started, or for window START-WINDOW if that is specified.

Source Code

;; Defined in /usr/src/emacs/lisp/strokes.el.gz
(defun strokes-event-closest-point (event &optional start-window)
  "Return the nearest position to where EVENT ended its motion.
This is computed for the window where EVENT's motion started,
or for window START-WINDOW if that is specified."
  (or start-window (setq start-window (posn-window (event-start event))))
  (if (eq start-window (posn-window (event-end event)))
      (if (eq (posn-point (event-end event)) 'vertical-line)
	  (strokes-event-closest-point-1 start-window
					 (cdr (posn-col-row (event-end event))))
	(if (eq (posn-point (event-end event)) 'mode-line)
	    (strokes-event-closest-point-1 start-window)
	  (posn-point (event-end event))))
    ;; EVENT ended in some other window.
    (let* ((end-w (posn-window (event-end event)))
	   (end-w-top)
	   (w-top (nth 1 (window-edges start-window))))
      (setq end-w-top
	    (if (windowp end-w)
		(nth 1 (window-edges end-w))
	      (/ (cdr (posn-x-y (event-end event)))
		 (frame-char-height end-w))))
      (if (>= end-w-top w-top)
	  (strokes-event-closest-point-1 start-window)
	(window-start start-window)))))