Support for killing the X terminal
Check whether frames are alive upon teardown, as it might not be the case when the terminal is killed as `delete-terminal-functions' might be invoked after the terminal is deleted. * exwm-core.el (exwm--terminal): New variable holding the terminal EXWM runs under. (exwm-init, exwm-exit): Set and unset it. * exwm.el (exwm--on-delete-terminal): New function for exiting EXWM when the terminal is deleted. (exwm-init): Use it. * exwm.el (exwm--confirm-kill-terminal, exwm-init): Ask for confirmation before deleting terminal. * exwm-workspace.el (exwm-workspace--fullscreen-workspace): New function. Ensure the frame is alive. (exwm-workspace--add-frame-as-workspace): Use it. (exwm-workspace--exit-minibuffer-frame): Cancel `exwm-workspace--display-echo-area-timer'. (exwm-workspace--exit-minibuffer-frame): Ensure the minibuffer frame is alive. (exwm-workspace--exit): Ignore dead workspace frames.
This commit is contained in:
parent
a11bb099fb
commit
1aa4ca781d
3 changed files with 63 additions and 25 deletions
24
exwm.el
24
exwm.el
|
|
@ -604,6 +604,13 @@
|
|||
(eq selection xcb:Atom:WM_S0))
|
||||
(exwm-exit))))
|
||||
|
||||
(defun exwm--on-delete-terminal (terminal)
|
||||
"Handle terminal being deleted without Emacs being killed.
|
||||
This may happen when invoking `save-buffers-kill-terminal' within an emacsclient
|
||||
session."
|
||||
(when (eq terminal exwm--terminal)
|
||||
(exwm-exit)))
|
||||
|
||||
(defun exwm--init-icccm-ewmh ()
|
||||
"Initialize ICCCM/EWMH support."
|
||||
(exwm--log)
|
||||
|
|
@ -840,6 +847,7 @@ manager. If t, replace it, if nil, abort and ask the user if `ask'."
|
|||
(condition-case err
|
||||
(progn
|
||||
(exwm-enable 'undo) ;never initialize again
|
||||
(setq exwm--terminal (frame-terminal frame))
|
||||
(setq exwm--connection (xcb:connect))
|
||||
(set-process-query-on-exit-flag (slot-value exwm--connection 'process)
|
||||
nil) ;prevent query message on exit
|
||||
|
|
@ -862,6 +870,10 @@ manager. If t, replace it, if nil, abort and ask the user if `ask'."
|
|||
;; Disable some features not working well with EXWM
|
||||
(setq use-dialog-box nil
|
||||
confirm-kill-emacs #'exwm--confirm-kill-emacs)
|
||||
(advice-add 'save-buffers-kill-terminal
|
||||
:before-while #'exwm--confirm-kill-terminal)
|
||||
;; Clean up if the terminal is deleted.
|
||||
(add-hook 'delete-terminal-functions 'exwm--on-delete-terminal)
|
||||
(exwm--lock)
|
||||
(exwm--init-icccm-ewmh)
|
||||
(exwm-layout--init)
|
||||
|
|
@ -898,7 +910,9 @@ manager. If t, replace it, if nil, abort and ask the user if `ask'."
|
|||
(when exwm--connection
|
||||
(xcb:flush exwm--connection)
|
||||
(xcb:disconnect exwm--connection))
|
||||
(setq exwm--connection nil))
|
||||
(setq exwm--connection nil)
|
||||
(setq exwm--terminal nil)
|
||||
(exwm--log "Exited"))
|
||||
|
||||
;;;###autoload
|
||||
(defun exwm-enable (&optional undo)
|
||||
|
|
@ -977,6 +991,14 @@ manager. If t, replace it, if nil, abort and ask the user if `ask'."
|
|||
;; For other types, return the value as-is.
|
||||
(t result))))))
|
||||
|
||||
(defun exwm--confirm-kill-terminal (&optional _)
|
||||
"Confirm before killing terminal."
|
||||
;; This is invoked instead of `save-buffers-kill-emacs' (C-x C-c) on client
|
||||
;; frames.
|
||||
(if (eq (frame-terminal) exwm--terminal)
|
||||
(exwm--confirm-kill-emacs "[EXWM] Kill terminal?")
|
||||
t))
|
||||
|
||||
(defun exwm--confirm-kill-emacs (prompt &optional force)
|
||||
"Confirm before exiting Emacs."
|
||||
(exwm--log)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue