Clean up when failing to start

* exwm.el (exwm-init, exwm-exit): Clean up when failing to start.
(exwm--exit-icccm-ewmh): Stop deleting root window properties on
exit: delete function.
This commit is contained in:
Adrián Medraño Calvo 2018-03-06 00:00:00 +00:00
parent cf98e3d921
commit 350950abfc

73
exwm.el
View file

@ -667,28 +667,6 @@
:data [0 0])) :data [0 0]))
(xcb:flush exwm--connection)) (xcb:flush exwm--connection))
(defun exwm--exit-icccm-ewmh ()
"Remove ICCCM/EWMH properties."
(dolist (p (list
xcb:Atom:_NET_WM_NAME
xcb:Atom:_NET_SUPPORTED
xcb:Atom:_NET_CLIENT_LIST
xcb:Atom:_NET_CLIENT_LIST_STACKING
xcb:Atom:_NET_NUMBER_OF_DESKTOPS
xcb:Atom:_NET_DESKTOP_GEOMETRY
xcb:Atom:_NET_DESKTOP_VIEWPORT
xcb:Atom:_NET_CURRENT_DESKTOP
xcb:Atom:_NET_ACTIVE_WINDOW
xcb:Atom:_NET_SUPPORTING_WM_CHECK
;; TODO: Keep this list synchronized with that in
;; `exwm--init-icccm-ewmh'.
))
(xcb:+request exwm--connection
(make-instance 'xcb:DeleteProperty
:window exwm--root
:property p))
(xcb:flush exwm--connection)))
;;;###autoload ;;;###autoload
(defun exwm-init (&optional frame) (defun exwm-init (&optional frame)
"Initialize EXWM." "Initialize EXWM."
@ -697,25 +675,25 @@
;; The frame might not be selected if it's created by emacslicnet. ;; The frame might not be selected if it's created by emacslicnet.
(select-frame-set-input-focus frame) (select-frame-set-input-focus frame)
(setq frame (selected-frame))) (setq frame (selected-frame)))
(if (not (eq 'x (framep frame))) (when (not (eq 'x (framep frame)))
(exwm--log "Not running under X environment") (user-error "Not running under X environment"))
(unless exwm--connection (when exwm--connection
(exwm-enable 'undo) ;never initialize again (user-error "EXWM already running"))
(setq exwm--connection (xcb:connect)) (condition-case err
(set-process-query-on-exit-flag (slot-value exwm--connection 'process) (progn
nil) ;prevent query message on exit (exwm-enable 'undo) ;never initialize again
(setq exwm--root (setq exwm--connection (xcb:connect))
(slot-value (car (slot-value (set-process-query-on-exit-flag (slot-value exwm--connection 'process)
(xcb:get-setup exwm--connection) 'roots)) nil) ;prevent query message on exit
'root)) (setq exwm--root
(if (xcb:+request-checked+request-check exwm--connection (slot-value (car (slot-value
(make-instance 'xcb:ChangeWindowAttributes (xcb:get-setup exwm--connection) 'roots))
:window exwm--root :value-mask xcb:CW:EventMask 'root))
:event-mask xcb:EventMask:SubstructureRedirect)) (when (xcb:+request-checked+request-check exwm--connection
;; Other window manager is running (make-instance 'xcb:ChangeWindowAttributes
(progn (xcb:disconnect exwm--connection) :window exwm--root :value-mask xcb:CW:EventMask
(setq exwm--connection nil) :event-mask xcb:EventMask:SubstructureRedirect))
(exwm--log "Other window manager detected")) (error "Other window manager is running"))
;; Disable some features not working well with EXWM ;; Disable some features not working well with EXWM
(setq use-dialog-box nil (setq use-dialog-box nil
confirm-kill-emacs #'exwm--confirm-kill-emacs) confirm-kill-emacs #'exwm--confirm-kill-emacs)
@ -734,7 +712,12 @@
(exwm-input--post-init) (exwm-input--post-init)
;; Manage existing windows ;; Manage existing windows
(exwm-manage--scan) (exwm-manage--scan)
(run-hooks 'exwm-init-hook))))) (run-hooks 'exwm-init-hook))
((quit error)
(exwm-exit)
;; Rethrow error
(signal (car err) (cdr err)))))
;;;###autoload ;;;###autoload
(defun exwm-exit () (defun exwm-exit ()
@ -748,13 +731,13 @@
(exwm-workspace--exit) (exwm-workspace--exit)
(exwm-floating--exit) (exwm-floating--exit)
(exwm-layout--exit) (exwm-layout--exit)
(exwm--exit-icccm-ewmh)
(xcb:+request-checked+request-check exwm--connection (xcb:+request-checked+request-check exwm--connection
(make-instance 'xcb:ChangeWindowAttributes (make-instance 'xcb:ChangeWindowAttributes
:window exwm--root :value-mask xcb:CW:EventMask :window exwm--root :value-mask xcb:CW:EventMask
:event-mask xcb:EventMask:NoEvent)) :event-mask xcb:EventMask:NoEvent))
(xcb:flush exwm--connection) (when exwm--connection
(xcb:disconnect exwm--connection) (xcb:flush exwm--connection)
(xcb:disconnect exwm--connection))
(setq exwm--connection nil)) (setq exwm--connection nil))
(defun exwm-enable (&optional undo) (defun exwm-enable (&optional undo)