Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pixelwise width and height in posframe-show #123

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions posframe.el
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ effect.")
poshandler-extra-info
width
height
pixel-width
pixel-height
max-width
max-height
min-width
Expand Down Expand Up @@ -376,6 +378,8 @@ An example parent frame poshandler function is:

You can use `posframe-delete-all' to delete all posframes."
(let* ((position (or position (point)))
(pixel-width (if (and pixel-width width) t nil))
(pixel-height (if (and pixel-width height) t nil))
(max-width (if (numberp max-width)
(min max-width (frame-width))
(frame-width)))
Expand All @@ -385,9 +389,11 @@ You can use `posframe-delete-all' to delete all posframes."
(min-width (min (or min-width 1) max-width))
(min-height (min (or min-height 1) max-height))
(width (when width
(min (max width min-width) max-width)))
(if pixel-width width
(min (max width min-width) max-width))))
(height (when height
(min (max height min-height) max-height)))
(if pixel-height height
(min (max height min-height) max-height))))
(x-pixel-offset (or x-pixel-offset 0))
(y-pixel-offset (or y-pixel-offset 0))
(window-point (or window-point 0))
Expand Down Expand Up @@ -467,7 +473,9 @@ You can use `posframe-delete-all' to delete all posframes."
:max-width max-width
:max-height max-height
:min-width min-width
:min-height min-height)))
:min-height min-height
:pixel-width pixel-width
:pixel-height pixel-height)))
;; Set posframe's size
(posframe--set-frame-size size-info)
;; Re-adjust posframe's size when buffer's content has changed.
Expand Down Expand Up @@ -827,9 +835,11 @@ will be removed."
(max-width (plist-get size-info :max-width))
(max-height (plist-get size-info :max-height))
(min-width (plist-get size-info :min-width))
(min-height (plist-get size-info :min-height)))
(when height (set-frame-height posframe height))
(when width (set-frame-width posframe width))
(min-height (plist-get size-info :min-height))
(pixel-width (plist-get size-info :pixel-width))
(pixel-height (plist-get size-info :pixel-height)))
(when height (set-frame-height posframe height nil pixel-height))
(when width (set-frame-width posframe width nil pixel-width))
(unless (and height width)
(posframe--fit-frame-to-buffer
posframe max-height min-height max-width min-width
Expand Down