Function: posframe-mouse-banish-default

posframe-mouse-banish-default is a byte-compiled function defined in posframe.el.

Signature

(posframe-mouse-banish-default INFO)

Documentation

Banish mouse base on INFO.

FIXME: This is a hacky fix for the mouse focus problem, which like: https://github.com/tumashu/posframe/issues/4#issuecomment-357514918

Source Code

;; Defined in ~/.emacs.d/elpa/posframe-20260415.14/posframe.el
(defun posframe-mouse-banish-default (info)
  "Banish mouse base on INFO.

FIXME: This is a hacky fix for the mouse focus problem, which like:
https://github.com/tumashu/posframe/issues/4#issuecomment-357514918"
  (let* ((parent-frame (plist-get info :parent-frame))
         (m-x (plist-get info :mouse-x))
         (m-y (plist-get info :mouse-y))
         (x (plist-get info :posframe-x))
         (y (plist-get info :posframe-y))
         (w (plist-get info :posframe-width))
         (h (plist-get info :posframe-height))
         (p-w (plist-get info :parent-frame-width))
         (p-h (plist-get info :parent-frame-height)))
    (when (and m-x m-y
               (>= m-x x)
               (<= m-x (+ x w))
               (>= m-y y)
               (<= m-y (+ y h)))
      (set-mouse-pixel-position
       parent-frame
       (if (= x 0)
           (min p-w (+ w 5))
         (max 0 (- x 5)))
       (if (= y 0)
           (min p-h (+ h 10))
         (max 0 (- y 10)))))))