summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuwei Tian <ibluefocus@outlook.com>2022-05-29 23:18:35 +0800
committerDaniel Mendler <mail@daniel-mendler.de>2022-06-04 18:56:58 +0200
commit175835dc0c147887431c6f4a851a3e7fd32bab47 (patch)
treeeef61eee1b651b5b9e51a85b74bc57e1041136b3
parent68891b55856daad783077b1a493a21472a75a5e2 (diff)
Extract corfu--make-frame-1 from corfu--make-frame
-rw-r--r--corfu.el26
1 files changed, 19 insertions, 7 deletions
diff --git a/corfu.el b/corfu.el
index 0625f24..978b901 100644
--- a/corfu.el
+++ b/corfu.el
@@ -392,11 +392,9 @@ CONTENT-HANDLER is a function called with the inserted buffer content."
(goto-char (point-min))))
buffer))
-;; Function adapted from posframe.el by tumashu
-(defun corfu--make-frame (x y width height content
- buffer-name frame frame-params
- &optional content-handler)
- "Show child frame at X/Y with WIDTH/HEIGHT and CONTENT.
+(defun corfu--make-frame-1 (content buffer-name frame frame-params
+ &optional content-handler)
+ "Make child frame with CONTENT.
The BUFFER-NAME and CONTENT-HANDLER parameters are the same as
the corresponding parameters in the `corfu--make-buffer' function.
@@ -435,8 +433,6 @@ The created frame can be accessed via FRAME."
(set-window-buffer win buffer)
;; Mark window as dedicated to prevent frame reuse (#60)
(set-window-dedicated-p win t))
- (corfu--set-frame-position frame x y width height)
- (redirect-frame-focus frame parent)
frame))
(defvar x-gtk-resize-child-frames) ;; Not present on non-gtk builds
@@ -471,6 +467,22 @@ The created frame can be accessed via FRAME."
(redisplay 'force)
(make-frame-visible frame))))
+;; Function adapted from posframe.el by tumashu
+(defun corfu--make-frame (x y width height content
+ buffer-name frame frame-params
+ &optional content-handler)
+ "Show child frame at X/Y with WIDTH/HEIGHT and CONTENT.
+
+The rest of the parameters are the same as the corresponding parameters
+in `corfu--make-frame-1'."
+ (let ((parent (window-frame))
+ (frame
+ (corfu--make-frame-1
+ content buffer-name frame frame-params content-handler)))
+ (corfu--set-frame-position frame x y width height 'hack-redisplay)
+ (redirect-frame-focus frame parent)
+ frame))
+
(defun corfu--popup-show (pos off width lines &optional curr lo bar)
"Show LINES as popup at POS - OFF.
WIDTH is the width of the popup.