Simplify position-finding code
This commit is contained in:
parent
fcebfaa141
commit
ec87e8c7f8
20
eldoc-box.el
20
eldoc-box.el
@ -242,21 +242,17 @@ Position is calculated base on WIDTH and HEIGHT of childframe text window"
|
|||||||
;; y position + a little padding (16)
|
;; y position + a little padding (16)
|
||||||
16))
|
16))
|
||||||
|
|
||||||
(defun eldoc-box--point-position-relative-to-native-frame (&optional position window)
|
(defun eldoc-box--point-position-relative-to-native-frame (&optional point window)
|
||||||
"Return (X . Y) as the coordinate of POSITION in WINDOW.
|
"Return (X . Y) as the coordinate of POINT in WINDOW.
|
||||||
The coordinate is relative to the native frame.
|
The coordinate is relative to the native frame.
|
||||||
|
|
||||||
WINDOW nil means use selected window."
|
WINDOW nil means use selected window."
|
||||||
(let* ((window (window-normalize-window window t))
|
(let* ((pos (pos (posn-at-point point window)))
|
||||||
(pos-in-window
|
(x-y (posn-x-y pos))
|
||||||
(pos-visible-in-window-p
|
(window (posn-window pos))
|
||||||
(or position (window-point window)) window t)))
|
(edges (window-body-pixel-edges window)))
|
||||||
(when pos-in-window
|
(cons (+ (car x-y) (car edges))
|
||||||
;; change absolute to relative to native frame
|
(+ (cdr x-y) (cadr edges)))))
|
||||||
(let ((edges (window-edges window t nil t)))
|
|
||||||
(cons (+ (nth 0 edges) (nth 0 pos-in-window)) ; x
|
|
||||||
(+ (nth 1 edges) (nth 1 pos-in-window)
|
|
||||||
(- (window-header-line-height window)))))))) ; y
|
|
||||||
|
|
||||||
(defun eldoc-box--default-at-point-position-function-1 (width height)
|
(defun eldoc-box--default-at-point-position-function-1 (width height)
|
||||||
"See `eldoc-box--default-at-point-position-function'."
|
"See `eldoc-box--default-at-point-position-function'."
|
||||||
|
Loading…
Reference in New Issue
Block a user