Add cleanup codes for Emacs daemon

* exwm-floating.el (exwm-floating--exit):
* exwm-input.el (exwm-input--exit):
* exwm-layout.el (exwm-layout--exit):
* exwm-manage.el (exwm-manage--exit):
* exwm-randr.el (exwm-randr--exit):
* exwm-systemtray.el (exwm-systemtray--exit):
* exwm-workspace.el (exwm-workspace--exit):
New functions for cleanup each module.

* exwm-input.el (exwm-input--on-pre-command, exwm-input--on-post-command)
(exwm-input--init): Name lambda functions.

* exwm-layout.el (exwm-layout--timer, exwm-layout--init): Save timer.

* exwm-randr.el (exwm-randr-enable): Register the cleanup function.

* exwm-systemtray.el (exwm-systemtray--init): Force refresh atoms in XEMBED
and system tray protocols.
(exwm-systemtray-enable): Register the cleanup function.

* exwm-workspace.el (exwm-workspace--client): Save the server process.
(exwm-workspace--confirm-kill-emacs): Add emacsclient-specific
cleanup codes.
(exwm-workspace--timer): Save the timer.
(exwm-workspace--init): Save the server process and timer;
fix problems with emacsclient frames.

* exwm.el (exwm-init): Always select the newly created frame;
force refresh ICCCM & EWMH atoms.
(exwm-exit-hook): New hook for holding cleanup codes.
(exwm--exit): Run `exwm-exit-hook', execute cleanup codes for
each module and reset the environment.
This commit is contained in:
Chris Feng 2016-05-23 19:13:42 +08:00
parent dc0c0f5131
commit 1b2ae3749e
8 changed files with 149 additions and 22 deletions

View file

@ -476,6 +476,14 @@ SIMULATION-KEYS is an alist of the form (original-key . simulated-key)."
(dolist (j pair)
(exwm-input--fake-key j))))))
(defun exwm-input--on-pre-command ()
"Run in `pre-command-hook'."
(setq exwm-input--during-command t))
(defun exwm-input--on-post-command ()
"Run in `post-command-hook'."
(setq exwm-input--during-command nil))
(declare-function exwm-floating--stop-moveresize "exwm-floating.el"
(&rest _args))
(declare-function exwm-floating--do-moveresize "exwm-floating.el"
@ -510,14 +518,20 @@ SIMULATION-KEYS is an alist of the form (original-key . simulated-key)."
;; `pre-command-hook' marks the end of a key sequence (existing or not)
(add-hook 'pre-command-hook #'exwm-input--finish-key-sequence)
;; Control `exwm-input--during-command'
(add-hook 'pre-command-hook (lambda () (setq exwm-input--during-command t)))
(add-hook 'post-command-hook
(lambda () (setq exwm-input--during-command nil)))
(add-hook 'pre-command-hook #'exwm-input--on-pre-command)
(add-hook 'post-command-hook #'exwm-input--on-post-command)
;; Update focus when buffer list updates
(add-hook 'buffer-list-update-hook #'exwm-input--on-buffer-list-update)
;; Update prefix keys for global keys
(exwm-input--update-global-prefix-keys))
(defun exwm-input--exit ()
"Exit the input module."
(remove-hook 'pre-command-hook #'exwm-input--finish-key-sequence)
(remove-hook 'pre-command-hook #'exwm-input--on-pre-command)
(remove-hook 'post-command-hook #'exwm-input--on-post-command)
(remove-hook 'buffer-list-update-hook #'exwm-input--on-buffer-list-update))
(provide 'exwm-input)