Function: window-absolute-pixel-position

window-absolute-pixel-position is a byte-compiled function defined in window.el.gz.

Signature

(window-absolute-pixel-position &optional POSITION WINDOW)

Documentation

Return display coordinates of POSITION in WINDOW.

If the buffer position POSITION is visible in window WINDOW, return the display coordinates of the upper/left corner of the glyph at POSITION. The return value is a cons of the X- and Y-coordinates of that corner, relative to an origin at (0, 0) of WINDOW's display. Return nil if POSITION is not visible in WINDOW.

WINDOW must be a live window and defaults to the selected window. POSITION defaults to the value of window-point of WINDOW.

View in manual

Probably introduced at or before Emacs version 25.1.

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun window-absolute-pixel-position (&optional position window)
  "Return display coordinates of POSITION in WINDOW.
If the buffer position POSITION is visible in window WINDOW,
return the display coordinates of the upper/left corner of the
glyph at POSITION.  The return value is a cons of the X- and
Y-coordinates of that corner, relative to an origin at (0, 0) of
WINDOW's display.  Return nil if POSITION is not visible in
WINDOW.

WINDOW must be a live window and defaults to the selected window.
POSITION defaults to the value of `window-point' of WINDOW."
  (let* ((window (window-normalize-window window t))
	 (pos-in-window
	  (pos-visible-in-window-p
	   (or position (window-point window)) window t)))
    (when pos-in-window
      (let ((edges (window-absolute-body-pixel-edges window)))
	(cons (+ (nth 0 edges) (nth 0 pos-in-window))
	      (+ (nth 1 edges) (nth 1 pos-in-window)))))))