diff options
| author | Daniel Colascione | 2018-06-12 23:09:23 -0700 |
|---|---|---|
| committer | Daniel Colascione | 2018-06-12 23:09:23 -0700 |
| commit | 5ed119141d10a09c4cd767c42a25a285f4f844ce (patch) | |
| tree | e38e6057e6d3dd484b8e3f2ff4c2ab50d300cb0f | |
| parent | 97b78542f60d1079a8407da5e1974d064951fb3d (diff) | |
| download | emacs-5ed119141d10a09c4cd767c42a25a285f4f844ce.tar.gz emacs-5ed119141d10a09c4cd767c42a25a285f4f844ce.zip | |
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.
| -rw-r--r-- | lisp/frame.el | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lisp/frame.el b/lisp/frame.el index 7dbd346bd91..70b4b242a02 100644 --- a/lisp/frame.el +++ b/lisp/frame.el | |||
| @@ -209,11 +209,12 @@ the window system." | |||
| 209 | (interactive "e") | 209 | (interactive "e") |
| 210 | (unless (eq (car-safe event) 'focus-in) | 210 | (unless (eq (car-safe event) 'focus-in) |
| 211 | (error "handle-focus-in should handle focus-in events")) | 211 | (error "handle-focus-in should handle focus-in events")) |
| 212 | (internal-handle-focus-in event) | ||
| 213 | (let ((frame (nth 1 event))) | 212 | (let ((frame (nth 1 event))) |
| 214 | (setf (frame-parameter frame 'last-focus-update) t) | 213 | (when (frame-live-p frame) |
| 215 | (run-hooks 'focus-in-hook) | 214 | (internal-handle-focus-in event) |
| 216 | (funcall after-focus-change-function))) | 215 | (setf (frame-parameter frame 'last-focus-update) t) |
| 216 | (run-hooks 'focus-in-hook))) | ||
| 217 | (funcall after-focus-change-function)) | ||
| 217 | 218 | ||
| 218 | (defun handle-focus-out (event) | 219 | (defun handle-focus-out (event) |
| 219 | "Handle a focus-out event. | 220 | "Handle a focus-out event. |
| @@ -225,9 +226,10 @@ that's not the whole story: see `after-focus-change-function'." | |||
| 225 | (unless (eq (car event) 'focus-out) | 226 | (unless (eq (car event) 'focus-out) |
| 226 | (error "handle-focus-out should handle focus-out events")) | 227 | (error "handle-focus-out should handle focus-out events")) |
| 227 | (let ((frame (nth 1 event))) | 228 | (let ((frame (nth 1 event))) |
| 228 | (setf (frame-parameter frame 'last-focus-update) nil) | 229 | (when (frame-live-p frame) |
| 229 | (run-hooks 'focus-out-hook) | 230 | (setf (frame-parameter frame 'last-focus-update) nil) |
| 230 | (funcall after-focus-change-function))) | 231 | (run-hooks 'focus-out-hook))) |
| 232 | (funcall after-focus-change-function)) | ||
| 231 | 233 | ||
| 232 | (defun handle-move-frame (event) | 234 | (defun handle-move-frame (event) |
| 233 | "Handle a move-frame event. | 235 | "Handle a move-frame event. |