Function: mouse-wheel--get-scroll-window

mouse-wheel--get-scroll-window is a byte-compiled function defined in mwheel.el.gz.

Signature

(mouse-wheel--get-scroll-window EVENT)

Documentation

Return window for mouse wheel event EVENT.

If mouse-wheel-follow-mouse is non-nil, return the window that the mouse pointer is over. Otherwise, return the currently active window.

Source Code

;; Defined in /usr/src/emacs/lisp/mwheel.el.gz
(defun mouse-wheel--get-scroll-window (event)
  "Return window for mouse wheel event EVENT.
If `mouse-wheel-follow-mouse' is non-nil, return the window that
the mouse pointer is over.  Otherwise, return the currently
active window."
  (or (catch 'found
        (let* ((window (if mouse-wheel-follow-mouse
                           (mwheel-event-window event)
                         (selected-window)))
               (frame (when (window-live-p window)
                        (frame-parameter
                         (window-frame window) 'mouse-wheel-frame))))
          (when (frame-live-p frame)
            (let* ((pos (mouse-absolute-pixel-position))
                   (pos-x (car pos))
                   (pos-y (cdr pos)))
              (walk-window-tree
               (lambda (window-1)
                 (let ((edges (window-edges window-1 nil t t)))
                   (when (and (<= (nth 0 edges) pos-x)
                              (<= pos-x (nth 2 edges))
                              (<= (nth 1 edges) pos-y)
                              (<= pos-y (nth 3 edges)))
                     (throw 'found window-1))))
               frame nil t)))))
      (mwheel-event-window event)))