branch: externals/posframe
commit b4578a1d7427f1d65a08971b7f4cdd172777b4eb
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>
Use set-frame-size when passed both width and height
Rely on default-line-height to calculate px height in this case, to
account for possible line spacing customization on `default` face.
And after (also if width/height were passed), do not rely on the
return values of `frame-pixel-width` and `frame-pixel-height` which
could be outdated if `x-wait-for-event-timeout` is used - this makes
using this variable feasible as performance/flickering optimization.
Or it should make things faster anyway.
---
posframe.el | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/posframe.el b/posframe.el
index 282fec3b0f..0f35fb321a 100644
--- a/posframe.el
+++ b/posframe.el
@@ -496,8 +496,14 @@ You can use `posframe-delete-all' to delete all posframes."
:font-height font-height
:font-width font-width
:posframe posframe
- :posframe-width (frame-pixel-width posframe)
- :posframe-height (frame-pixel-height posframe)
+ :posframe-width
+ (if width
+ (* (default-font-width) width)
+ (frame-pixel-width posframe))
+ :posframe-height
+ (if height
+ (* (default-line-height) height)
+ (frame-pixel-height posframe))
:posframe-buffer buffer
:parent-frame parent-frame
:parent-frame-width parent-frame-width
@@ -847,8 +853,14 @@ will be removed."
(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))
+ (cond
+ ((and width height)
+ (set-frame-size posframe
+ (* (default-font-width) width)
+ (* (default-line-height) height)
+ t))
+ (height (set-frame-height posframe height))
+ (width (set-frame-width posframe width)))
(unless (and height width)
(posframe--fit-frame-to-buffer
posframe max-height min-height max-width min-width