emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/posframe 5696463 1/2: Merge pull request #77 from tumas


From: Feng Shu
Subject: [elpa] externals/posframe 5696463 1/2: Merge pull request #77 from tumashu/indirect-focus
Date: Fri, 9 Oct 2020 05:48:23 -0400 (EDT)

branch: externals/posframe
commit 5696463afe2b0bc7b9c2705663daf9afc7ef18ad
Merge: 7b92a54 fc540f8
Author: tumashu <tumashu@163.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #77 from tumashu/indirect-focus
    
    Fix: Add the option to disable focus redirection #76
---
 posframe.el | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/posframe.el b/posframe.el
index 281a1d0..c220223 100644
--- a/posframe.el
+++ b/posframe.el
@@ -584,9 +584,6 @@ You can use `posframe-delete-all' to delete all posframes."
             (funcall func)
             (setq posframe--initialized-p t))))
 
-      ;; Move mouse to (0 . 0)
-      (posframe--mouse-banish parent-frame)
-
       ;; Create posframe
       (setq posframe
             (posframe--create-posframe
@@ -607,6 +604,9 @@ You can use `posframe-delete-all' to delete all posframes."
              :override-parameters override-parameters
              :accept-focus accept-focus))
 
+      ;; Move mouse to (0 . 0)
+      (posframe--mouse-banish parent-frame posframe)
+
       ;; Insert string into the posframe buffer
       (posframe--insert-string string no-properties)
 
@@ -687,18 +687,27 @@ You can use `posframe-delete-all' to delete all 
posframes."
 (defun posframe--redirect-posframe-focus ()
   "Redirect focus from the posframe to the parent frame. This prevents the
 posframe from catching keyboard input if the window manager selects it."
-  (when (eq (selected-frame) posframe--frame)
+  (when (and (eq (selected-frame) posframe--frame)
+             ;; Do not redirect focus when posframe can accept focus.
+             ;; See posframe-show's accept-focus argument.
+             (frame-parameter (selected-frame) 'no-accept-focus))
     (redirect-frame-focus posframe--frame (frame-parent))))
 
 (add-hook 'focus-in-hook #'posframe--redirect-posframe-focus)
 
-(defun posframe--mouse-banish (frame)
-  "Banish mouse to the (0 . 0) of FRAME.
+(defun posframe--mouse-banish (parent-frame &optional posframe)
+  "Banish mouse to the (0 . 0) of PARENT-FRAME.
+Do not banish mouse when no-accept-focus frame parameter of POSFRAME
+is non-nil.
+
 FIXME: This is a hacky fix for the mouse focus problem, which like:
 https://github.com/tumashu/posframe/issues/4#issuecomment-357514918";
   (when (and posframe-mouse-banish
+             ;; Do not banish mouse when posframe can accept focus.
+             ;; See posframe-show's accept-focus argument.
+             (frame-parameter posframe 'no-accept-focus)
              (not (equal (cdr (mouse-position)) '(0 . 0))))
-    (set-mouse-position frame 0 0)))
+    (set-mouse-position parent-frame 0 0)))
 
 (defun posframe--insert-string (string no-properties)
   "Insert STRING to current buffer.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]