From 1b2ae3749e98b83f94cc19cef8830ce823c63367 Mon Sep 17 00:00:00 2001 From: Chris Feng Date: Mon, 23 May 2016 19:13:42 +0800 Subject: 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. --- exwm-layout.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'exwm-layout.el') diff --git a/exwm-layout.el b/exwm-layout.el index 9cbdd2b83d30..0069767d1a73 100644 --- a/exwm-layout.el +++ b/exwm-layout.el @@ -528,6 +528,8 @@ See also `exwm-layout-enlarge-window'." (exwm-layout-hide-mode-line) (exwm-layout-show-mode-line)))) +(defvar exwm-layout--timer nil "Timer used to track echo area changes.") + (defun exwm-layout--init () "Initialize layout module." ;; Auto refresh layout @@ -535,9 +537,19 @@ See also `exwm-layout-enlarge-window'." (unless (exwm-workspace--minibuffer-own-frame-p) ;; Refresh when minibuffer grows (add-hook 'minibuffer-setup-hook #'exwm-layout--on-minibuffer-setup t) - (run-with-idle-timer 0 t #'exwm-layout--on-echo-area-change t) + (setq exwm-layout--timer + (run-with-idle-timer 0 t #'exwm-layout--on-echo-area-change t)) (add-hook 'echo-area-clear-hook #'exwm-layout--on-echo-area-change))) +(defun exwm-layout--exit () + "Exit the layout module." + (remove-hook 'window-configuration-change-hook #'exwm-layout--refresh) + (remove-hook 'minibuffer-setup-hook #'exwm-layout--on-minibuffer-setup) + (when exwm-layout--timer + (cancel-timer exwm-layout--timer) + (setq exwm-layout--timer nil)) + (remove-hook 'echo-area-clear-hook #'exwm-layout--on-echo-area-change)) + (provide 'exwm-layout) -- cgit 1.4.1