emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 5ed1191: Ignore focus events for dead frames


From: Daniel Colascione
Subject: [Emacs-diffs] master 5ed1191: Ignore focus events for dead frames
Date: Wed, 13 Jun 2018 02:10:00 -0400 (EDT)

branch: master
commit 5ed119141d10a09c4cd767c42a25a285f4f844ce
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>

    Ignore focus events for dead frames
    
    Frames can die between the time we generate a focus event and the time
    we get around to processing it.  Do run after-focus-change-function,
    since that's idempotent and we want to make sure not to miss
    any changes.
    
    * lisp/frame.el (handle-focus-in, handle-focus-out): Check for dead frames.
---
 lisp/frame.el | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lisp/frame.el b/lisp/frame.el
index 7dbd346..70b4b24 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -209,11 +209,12 @@ the window system."
   (interactive "e")
   (unless (eq (car-safe event) 'focus-in)
     (error "handle-focus-in should handle focus-in events"))
-  (internal-handle-focus-in event)
   (let ((frame (nth 1 event)))
-    (setf (frame-parameter frame 'last-focus-update) t)
-  (run-hooks 'focus-in-hook)
-  (funcall after-focus-change-function)))
+    (when (frame-live-p frame)
+      (internal-handle-focus-in event)
+      (setf (frame-parameter frame 'last-focus-update) t)
+      (run-hooks 'focus-in-hook)))
+  (funcall after-focus-change-function))
 
 (defun handle-focus-out (event)
   "Handle a focus-out event.
@@ -225,9 +226,10 @@ that's not the whole story: see 
`after-focus-change-function'."
   (unless (eq (car event) 'focus-out)
     (error "handle-focus-out should handle focus-out events"))
   (let ((frame (nth 1 event)))
-    (setf (frame-parameter frame 'last-focus-update) nil)
-    (run-hooks 'focus-out-hook)
-    (funcall after-focus-change-function)))
+    (when (frame-live-p frame)
+      (setf (frame-parameter frame 'last-focus-update) nil)
+      (run-hooks 'focus-out-hook)))
+  (funcall after-focus-change-function))
 
 (defun handle-move-frame (event)
   "Handle a move-frame event.



reply via email to

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