branch: externals/posframe
commit 3c7d3eaab3ce680b70bde2bd766d9e9df821c5d7
Merge: d93828bf6c 6ac22a6419
Author: tumashu <[email protected]>
Commit: GitHub <[email protected]>

    Merge pull request #151 from dgutov/faster-rendering-no-x-wait-for-event
    
    Faster refresh when using width/height and `x-wait-for-event-timeout`=nil
---
 posframe.el | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/posframe.el b/posframe.el
index 282fec3b0f..5c9e3d3458 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
@@ -949,7 +961,8 @@ This need PARENT-FRAME-WIDTH and PARENT-FRAME-HEIGHT"
                (equal posframe--last-posframe-displayed-size
                       (cons (frame-pixel-width posframe)
                             (frame-pixel-height posframe))))
-    (set-frame-position posframe (car position) (cdr position))
+    (unless (equal (frame-position posframe) position)
+      (set-frame-position posframe (car position) (cdr position)))
     (setq-local posframe--last-posframe-pixel-position position)
     (setq-local posframe--last-parent-frame-size
                 (cons parent-frame-width parent-frame-height))

Reply via email to