Function: hycontrol-frame-fit-to-screen
hycontrol-frame-fit-to-screen is a byte-compiled function defined in
hycontrol.el.
Signature
(hycontrol-frame-fit-to-screen &optional FRAME X-ORIGIN Y-ORIGIN)
Documentation
Ensure the selected frame fits within the screen.
Allow for hycontrol-screen-*-offsets. Accepts optional arguments FRAME, X-ORIGIN, and Y-ORIGIN (in pixels) to use when resizing FRAME (defaults to selected frame).
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hycontrol.el
(defun hycontrol-frame-fit-to-screen (&optional frame x-origin y-origin)
"Ensure the selected frame fits within the screen.
Allow for hycontrol-screen-*-offsets. Accepts optional arguments
FRAME, X-ORIGIN, and Y-ORIGIN (in pixels) to use when resizing
FRAME (defaults to selected frame)."
(let ((max-width (- (display-pixel-width) hycontrol-screen-left-offset hycontrol-screen-right-offset 2))
(max-height (- (display-pixel-height) hycontrol-screen-top-offset hycontrol-screen-bottom-offset 2))
(frame-resize-pixelwise t))
(setq x-origin (or x-origin (hycontrol-frame-x-origin frame))
y-origin (or y-origin (hycontrol-frame-y-origin frame)))
(when (> (hycontrol-frame-width frame) max-width)
;; Adjust frame size to fit within screen
(set-frame-width frame (min (hycontrol-frame-width frame) max-width) nil t)
(if hycontrol-debug (hycontrol-message hycontrol-debug "(HyDebug): Screen (X,Y): %d, %d; Frame Edges (L,T,R,B): %s"
(display-pixel-width) (display-pixel-height) (hycontrol-frame-edges frame))))
(when (> (hycontrol-frame-height frame) max-height)
;; Adjust frame size to fit within screen
(set-frame-height frame (min (hycontrol-frame-height frame) max-height) nil t)
(if hycontrol-debug (hycontrol-message hycontrol-debug "(HyDebug): Screen (X,Y): %d, %d; Frame Edges (L,T,R,B): %s"
(display-pixel-width) (display-pixel-height) (hycontrol-frame-edges frame))))
;; Ensure entire frame is positioned onscreen, keeping the
;; original frame origin coordinates if possible.
(set-frame-position frame
(min (max 0 x-origin)
(- (display-pixel-width) (hycontrol-frame-width frame) hycontrol-screen-right-offset))
(min (max 0 y-origin)
(- (display-pixel-height) (hycontrol-frame-height frame) hycontrol-screen-bottom-offset)))
(if hycontrol-debug (hycontrol-message hycontrol-debug "(HyDebug): Screen (X,Y): %d, %d; Frame Edges (L,T,R,B): %s"
(display-pixel-width) (display-pixel-height) (hycontrol-frame-edges frame)))))