Avoid unnecessary focus changes when creating/killing buffers

* exwm-input.el (exwm-input--skip-buffer-list-update): New internal
variable for skipping the next 'buffer-list-update'.
(exwm-input--on-buffer-list-update): Skip when
`exwm-input--skip-buffer-list-update` is set.

* exwm-manage.el (exwm-manage--manage-window): Set
`exwm-input--skip-buffer-list-update` when creating/killing buffers.
This commit is contained in:
Chris Feng 2018-12-16 00:00:00 +00:00
parent e6892216a6
commit 2efd7495d9
2 changed files with 9 additions and 2 deletions

View file

@ -117,6 +117,9 @@ defined in `exwm-mode-map' here."
(defvar exwm-input--simulation-keys nil "Simulation keys in line-mode.")
(defvar exwm-input--skip-buffer-list-update nil
"Skip the upcoming 'buffer-list-update'.")
(defvar exwm-input--temp-line-mode nil
"Non-nil indicates it's in temporary line-mode for char-mode.")
@ -264,6 +267,7 @@ ARGS are additional arguments to CALLBACK."
(defun exwm-input--on-buffer-list-update ()
"Run in `buffer-list-update-hook' to track input focus."
(when (and (not (eq this-command #'handle-switch-frame))
(not exwm-input--skip-buffer-list-update)
(not (exwm-workspace--client-p))
;; The following conditions filter out events relating to temp
;; buffers.