Improve child frame X position calculation logic

This commit is contained in:
Jessie Hildebrandt 2024-01-05 10:27:01 -05:00
parent 7b0477697b
commit bf7efd8903

View File

@ -333,19 +333,27 @@ All functions are run with the eldoc child frame selected."
(defun eldoc-frame--calc-frame-x-position (frame)
"Calculate the appropriate X position (offset) for FRAME.
If the selected window is on the right side of the selected frame and is too
small to overlay FRAME over, or if `point' is too close to the right edge of the
selected frame, return an X coordinate that will place FRAME on the left side of
the selected frame. Otherwise, return an X coordinate that will place FRAME on
the right side of the selected frame."
narrow to overlay FRAME over, or if FRAME would overlap with `point', return an
X coordinate that will position FRAME on the left side of the selected frame.
Otherwise, return an X coordinate that will position FRAME on the right
side of the selected frame."
(let ((offset-l (nth 0 eldoc-frame-offset))
(offset-y (nth 1 eldoc-frame-offset))
(offset-r (nth 2 eldoc-frame-offset))
(window-left (nth 0 (window-absolute-pixel-edges)))
(min-containing-width (* (eval eldoc-frame-max-pixel-width) 2))
(cursor-x-position (or (car (window-absolute-pixel-position)) 0)))
(if (or (and (< (window-pixel-width) min-containing-width)
(point-abs-x (or (car (window-absolute-pixel-position)) 0))
(point-abs-y (or (cdr (window-absolute-pixel-position)) 0))
(min-containing-width (* (eval eldoc-frame-max-pixel-width) 2)))
(if (or (and (< (window-pixel-width) (+ min-containing-width offset-r))
(> window-left (* (frame-pixel-width) .40)))
(> cursor-x-position (* (frame-pixel-width) .70)))
(and (> point-abs-x (- (frame-pixel-width)
(frame-pixel-width frame)))
(< point-abs-y (+ (frame-pixel-height frame)
offset-y
(frame-char-height)))))
;; FRAME should be displayed on the left:
offset-l
;; FRAME should be displayed on the right: