[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/posframe 054c9f3 1/2: * posframe.el (posframe-show, po
From: |
ELPA Syncer |
Subject: |
[elpa] externals/posframe 054c9f3 1/2: * posframe.el (posframe-show, posframe-refposhandler-xwininfo): parent-frame-poshandler -> refposhandler |
Date: |
Thu, 8 Apr 2021 21:57:15 -0400 (EDT) |
branch: externals/posframe
commit 054c9f345ab3623c24de7ab16043cdae4218f9e4
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
* posframe.el (posframe-show, posframe-refposhandler-xwininfo):
parent-frame-poshandler -> refposhandler
---
posframe.el | 63 +++++++++++++++++++++++++++++++++----------------------------
1 file changed, 34 insertions(+), 29 deletions(-)
diff --git a/posframe.el b/posframe.el
index 73f8fb3..38fae83 100644
--- a/posframe.el
+++ b/posframe.el
@@ -418,7 +418,7 @@ This posframe's buffer is BUFFER-OR-NAME."
refresh
accept-focus
hidehandler
- parent-frame-poshandler
+ refposhandler
&allow-other-keys)
"Pop up a posframe and show STRING at POSITION.
@@ -459,9 +459,6 @@ position. Its argument is a plist of the following form:
:x-pixel-offset xxx
:y-pixel-offset xxx)
-Note: poshandler info include :parent-frame-position, but user
-should never use it in poshandler function.
-
By default, poshandler is auto-selected based on the type of POSITION,
but the selection can be overridden using the POSHANDLER argument.
The builtin poshandler functions are listed below:
@@ -594,17 +591,24 @@ The builtin hidehandler functions are listed below:
1. `posframe-hidehandler-when-buffer-switch'
-(18) PARENT-FRAME-POSHANDLER
+(18) REFPOSHANDLER
+
+REFPOSHANDLER is a function, a reference position (most is
+top-left of current frame) will be returned when call this
+function.
+
+when it is nil or it return nil, child-frame feature will be used
+and reference position will be deal with in emacs.
+
+The user case I know at the moment is let ivy-posframe work well
+in EXWM environment (let posframe show on the other appliction
+window).
+
+ DO NOT USE UNLESS NECESSARY!!!
-PARENT-FRAME-POSHANDLER is a function, posframe can get current
-frame's position in screen by call this function, PLEASE NOTE:
-this argument will disable child-frame feature, the user case at
-the moment I know is let ivy-posframe run properly in EXWM
-environment (let posframe show on the other appliction window).
-DO NOT USE UNLESS NECESSARY. an example parent frame poshandler
-function is:
+An example parent frame poshandler function is:
-1. `posframe-parent-frame-poshandler-xwininfo'
+1. `posframe-refposhandler-xwininfo'
(19) Others
@@ -638,7 +642,7 @@ You can use `posframe-delete-all' to delete all posframes."
(refresh (funcall posframe-arghandler buffer-or-name :refresh
refresh))
(accept-focus (funcall posframe-arghandler buffer-or-name
:accept-focus accept-focus))
(hidehandler (funcall posframe-arghandler buffer-or-name :hidehandler
hidehandler))
- (parent-frame-poshandler (funcall posframe-arghandler buffer-or-name
:parent-frame-poshandler parent-frame-poshandler))
+ (refposhandler (funcall posframe-arghandler buffer-or-name
:refposhandler refposhandler))
;;-----------------------------------------------------
(buffer (get-buffer-create buffer-or-name))
(parent-window (selected-window))
@@ -653,9 +657,9 @@ You can use `posframe-delete-all' to delete all posframes."
(parent-frame (window-frame parent-window))
(parent-frame-width (frame-pixel-width parent-frame))
(parent-frame-height (frame-pixel-height parent-frame))
- (parent-frame-position
- (when (functionp parent-frame-poshandler)
- (funcall parent-frame-poshandler)))
+ (ref-position
+ (when (functionp refposhandler)
+ (funcall refposhandler parent-frame)))
(font-width (default-font-width))
(font-height (with-current-buffer (window-buffer parent-window)
(posframe--get-font-height position)))
@@ -683,7 +687,7 @@ You can use `posframe-delete-all' to delete all posframes."
buffer
:font font
:parent-frame
- (unless parent-frame-position
+ (unless ref-position
parent-frame)
:left-fringe left-fringe
:right-fringe right-fringe
@@ -728,7 +732,7 @@ You can use `posframe-delete-all' to delete all posframes."
:parent-frame parent-frame
:parent-frame-width parent-frame-width
:parent-frame-height parent-frame-height
- :parent-frame-position parent-frame-position
+ :ref-position ref-position
:parent-window parent-window
:parent-window-top parent-window-top
:parent-window-left parent-window-left
@@ -1048,9 +1052,9 @@ of `posframe-show'."
(setq posframe--last-poshandler-info info)
(let* ((posframe-width (plist-get info :posframe-width))
(posframe-height (plist-get info :posframe-height))
- (parent-frame-position (plist-get info :parent-frame-position))
- (parent-frame-x (or (car parent-frame-position) 0))
- (parent-frame-y (or (cdr parent-frame-position) 0))
+ (ref-position (plist-get info :ref-position))
+ (ref-x (or (car ref-position) 0))
+ (ref-y (or (cdr ref-position) 0))
(position (funcall
(or (plist-get info :poshandler)
(let ((position (plist-get info :position)))
@@ -1061,17 +1065,18 @@ of `posframe-show'."
(integerp (cdr position)))
#'posframe-poshandler-absolute-x-y)
(t (error "Posframe: have no valid
poshandler")))))
- info))
+ ;; Set :ref-position to 'ignore, prevent misuse or abuse
in poshandler.
+ (plist-put info :ref-position 'ignore)))
(x (car position))
(y (cdr position)))
- (if (not parent-frame-position)
+ (if (not ref-position)
position
(when (< x 0)
(setq x (+ posframe-width x)))
(when (< y 0)
(setq y (+ posframe-height y)))
- (cons (+ parent-frame-x x)
- (+ parent-frame-y y))))))
+ (cons (+ ref-x x)
+ (+ ref-y y))))))
(cl-defun posframe-poshandler-argbuilder (&optional
child-frame
@@ -1403,7 +1408,7 @@ bottom center. The structure of INFO can be found in
docstring of
(+ window-top window-height
(- 0 mode-line-height posframe-height)))))
-(defun posframe-parent-frame-poshandler-xwininfo ()
+(defun posframe-refposhandler-xwininfo (&optional frame)
"Parent frame poshander function.
Get the position of parent frame (current frame) with the help of
xwininfo."
@@ -1411,8 +1416,8 @@ xwininfo."
(with-temp-buffer
(let ((case-fold-search nil)
(args (format "xwininfo -display %s -id %s"
- (frame-parameter nil 'display)
- (frame-parameter nil 'window-id))))
+ (frame-parameter frame 'display)
+ (frame-parameter frame 'window-id))))
(call-process shell-file-name nil t nil shell-command-switch args)
(goto-char (point-min))
(search-forward "Absolute upper-left")