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

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

[elpa] externals/posframe d2f6d06 3/3: * posframe.el (posframe--redirect


From: ELPA Syncer
Subject: [elpa] externals/posframe d2f6d06 3/3: * posframe.el (posframe--redirect-posframe-focus): Re-add.
Date: Tue, 26 Oct 2021 22:57:29 -0400 (EDT)

branch: externals/posframe
commit d2f6d066c9df404788d3dea2e301d8d04502cc71
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>

    * posframe.el (posframe--redirect-posframe-focus): Re-add.
---
 posframe.el | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/posframe.el b/posframe.el
index 2c9b57c..bfe6249 100644
--- a/posframe.el
+++ b/posframe.el
@@ -742,6 +742,21 @@ 
https://github.com/tumashu/posframe/issues/4#issuecomment-357514918";
                (< m-y (+ y h)))
       (set-mouse-pixel-position parent-frame (- x 5) (- y 10)))))
 
+(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 (and (eq (selected-frame) posframe--frame)
+             ;; Do not redirect focus when posframe can accept focus.
+             ;; See posframe-show's accept-focus argument.
+             (not posframe--accept-focus))
+    (redirect-frame-focus posframe--frame (frame-parent))))
+
+(if (version< emacs-version "27.1")
+    (with-no-warnings
+      (add-hook 'focus-in-hook #'posframe--redirect-posframe-focus))
+  (add-function :after after-focus-change-function 
#'posframe--redirect-posframe-focus))
+
 (defun posframe--insert-string (string no-properties)
   "Insert STRING to current buffer.
 If NO-PROPERTIES is non-nil, all properties of STRING



reply via email to

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