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-systemtray.el | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'exwm-systemtray.el') diff --git a/exwm-systemtray.el b/exwm-systemtray.el index cb08ba9560c3..d1783debdb15 100644 --- a/exwm-systemtray.el +++ b/exwm-systemtray.el @@ -311,8 +311,8 @@ You shall use the default value if using auto-hide minibuffer.") 'process) nil) ;; Initialize XELB modules. - (xcb:xembed:init exwm-systemtray--connection) - (xcb:systemtray:init exwm-systemtray--connection) + (xcb:xembed:init exwm-systemtray--connection t) + (xcb:systemtray:init exwm-systemtray--connection t) ;; Acquire the manager selection _NET_SYSTEM_TRAY_S0. (with-slots (owner) (xcb:+request-unchecked+reply exwm-systemtray--connection @@ -399,11 +399,27 @@ You shall use the default value if using auto-hide minibuffer.") #'exwm-systemtray--on-ClientMessage) ;; Add hook to move/reparent the embedder. (add-hook 'exwm-workspace-switch-hook #'exwm-systemtray--on-workspace-switch) - (add-hook 'exwm-randr-refresh-hook #'exwm-systemtray--on-randr-refresh)) + (when (boundp 'exwm-randr-refresh-hook) + (add-hook 'exwm-randr-refresh-hook #'exwm-systemtray--on-randr-refresh))) + +(defun exwm-systemtray--exit () + "Exit the systemtray module." + (when exwm-systemtray--connection + (xcb:disconnect exwm-systemtray--connection) + (setq exwm-systemtray--connection nil + exwm-systemtray--list nil + exwm-systemtray--selection-owner-window nil + exwm-systemtray--embedder nil) + (remove-hook 'exwm-workspace-switch-hook + #'exwm-systemtray--on-workspace-switch) + (when (boundp 'exwm-randr-refresh-hook) + (remove-hook 'exwm-randr-refresh-hook + #'exwm-systemtray--on-randr-refresh)))) (defun exwm-systemtray-enable () "Enable system tray support for EXWM." - (add-hook 'exwm-init-hook #'exwm-systemtray--init)) + (add-hook 'exwm-init-hook #'exwm-systemtray--init) + (add-hook 'exwm-exit-hook #'exwm-systemtray--exit)) -- cgit 1.4.1