Function: posframe--calculate-new-position

posframe--calculate-new-position is a byte-compiled function defined in posframe.el.

Signature

(posframe--calculate-new-position INFO POSITION REF-POSITION)

Documentation

Calculate new position according to INFO, POSITION and REF-POSITION.

Source Code

;; Defined in ~/.emacs.d/elpa/posframe-20260415.14/posframe.el
(defun posframe--calculate-new-position (info position ref-position)
  "Calculate new position according to INFO, POSITION and REF-POSITION."
  (let* ((parent-frame-width (plist-get info :parent-frame-width))
         (parent-frame-height (plist-get info :parent-frame-height))
         (posframe-width (plist-get info :posframe-width))
         (posframe-height (plist-get info :posframe-height))
         (ref-x (or (car ref-position) 0))
         (ref-y (or (cdr ref-position) 0))
         (x (car position))
         (y (cdr position)))
    (when (< x 0)
      (setq x (- (+ x parent-frame-width) posframe-width)))
    (when (< y 0)
      (setq y (- (+ y parent-frame-height) posframe-height)))
    (cons (+ ref-x x)
          (+ ref-y y))))