Change frame position display logic
This commit is contained in:
parent
8075b5662e
commit
0f2ba661f8
@ -331,28 +331,27 @@ All functions are run with the eldoc child frame selected."
|
|||||||
;; Frame geometry
|
;; Frame geometry
|
||||||
;; ---------------------------------- ;;
|
;; ---------------------------------- ;;
|
||||||
|
|
||||||
(defun eldoc-frame--selected-window-side ()
|
|
||||||
"Return which side of the frame the selected window is on.
|
|
||||||
Return ‘left’ if the selected window is on the left, or ‘right’ if the selected
|
|
||||||
window is on the right. Return ‘left’ if there is only one window in the frame."
|
|
||||||
(let* ((window-left (nth 0 (window-absolute-pixel-edges)))
|
|
||||||
(window-right (nth 2 (window-absolute-pixel-edges)))
|
|
||||||
(frame-left (nth 0 (frame-edges)))
|
|
||||||
(frame-right (nth 2 (frame-edges)))
|
|
||||||
(distance-left (- window-left frame-left))
|
|
||||||
(distance-right (- frame-right window-right)))
|
|
||||||
(if (<= distance-left distance-right) 'left 'right)))
|
|
||||||
|
|
||||||
(defun eldoc-frame--calc-frame-x-position (frame)
|
(defun eldoc-frame--calc-frame-x-position (frame)
|
||||||
"Calculate the appropriate X position (offset) for FRAME."
|
"Calculate the appropriate X position (offset) for FRAME.
|
||||||
(pcase-let ((`(,offset-l ,offset-r) eldoc-frame-offset))
|
If the selected window is on the right side of the selected frame and is too
|
||||||
(pcase (eldoc-frame--selected-window-side)
|
small to overlay FRAME over, or if `point' is too close to the right edge of the
|
||||||
;; Selected window is on the left, so child frame should be on the right:
|
selected frame, return an X coordinate that will place FRAME on the left side of
|
||||||
('left (- (frame-pixel-width (selected-frame))
|
the selected frame. Otherwise, return an X coordinate that will place FRAME on
|
||||||
|
the right side of the selected frame."
|
||||||
|
(let ((offset-l (nth 0 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)
|
||||||
|
(> window-left (* (frame-pixel-width) .40)))
|
||||||
|
(> cursor-x-position (* (frame-pixel-width) .70)))
|
||||||
|
;; FRAME should be displayed on the left:
|
||||||
|
offset-l
|
||||||
|
;; FRAME should be displayed on the right:
|
||||||
|
(- (frame-pixel-width (selected-frame))
|
||||||
(frame-pixel-width frame)
|
(frame-pixel-width frame)
|
||||||
offset-r))
|
offset-r))))
|
||||||
;; Selected window is on the right, so child frame should be on the left:
|
|
||||||
('right offset-l))))
|
|
||||||
|
|
||||||
(defun eldoc-frame--update-frame-geometry (frame)
|
(defun eldoc-frame--update-frame-geometry (frame)
|
||||||
"Update size and position of FRAME."
|
"Update size and position of FRAME."
|
||||||
|
Loading…
Reference in New Issue
Block a user