Make replacing existing WM optional

* exwm.el (exwm-replace): New user option for specifying whether to
replace existing WM.
(exwm-init): Use it.
(exwm--wmsn-acquire, exwm-init): Do not print warning message when
user gives up replacing.
* exwm-core.el (exwm--wmsn-replace): Remove dead code.
This commit is contained in:
Chris Feng 2019-03-10 00:00:00 +00:00
parent 88c690217a
commit b12c67de2e
2 changed files with 9 additions and 5 deletions

View file

@ -41,9 +41,6 @@
(defvar exwm--wmsn-acquire-timeout 3 (defvar exwm--wmsn-acquire-timeout 3
"Number of seconds to wait for other window managers to release the selection.") "Number of seconds to wait for other window managers to release the selection.")
(defvar exwm--wmsn-replace 'ask
"Replace existing window manager.")
(defvar exwm--guide-window nil (defvar exwm--guide-window nil
"An X window separating workspaces and X windows.") "An X window separating workspaces and X windows.")

11
exwm.el
View file

@ -99,6 +99,12 @@
"Subrs (primitives) that would normally block EXWM." "Subrs (primitives) that would normally block EXWM."
:type '(repeat function)) :type '(repeat function))
(defcustom exwm-replace 'ask
"Whether to replace existing window manager."
:type '(radio (const :tag "Ask" ask)
(const :tag "Replace by default" t)
(const :tag "Do not replace" nil)))
(defconst exwm--server-name "server-exwm" (defconst exwm--server-name "server-exwm"
"Name of the subordinate Emacs server.") "Name of the subordinate Emacs server.")
@ -721,7 +727,7 @@ manager. If t, replace it, if nil, abort and ask the user if `ask'."
(when (eq replace 'ask) (when (eq replace 'ask)
(setq replace (yes-or-no-p "Replace existing window manager? "))) (setq replace (yes-or-no-p "Replace existing window manager? ")))
(when (not replace) (when (not replace)
(error "Other window manager detected"))) (user-error "Other window manager detected")))
(let ((new-owner (xcb:generate-id exwm--connection))) (let ((new-owner (xcb:generate-id exwm--connection)))
(xcb:+request exwm--connection (xcb:+request exwm--connection
(make-instance 'xcb:CreateWindow (make-instance 'xcb:CreateWindow
@ -812,7 +818,7 @@ manager. If t, replace it, if nil, abort and ask the user if `ask'."
(xcb:icccm:init exwm--connection t) (xcb:icccm:init exwm--connection t)
(xcb:ewmh:init exwm--connection t) (xcb:ewmh:init exwm--connection t)
;; Try to register window manager selection. ;; Try to register window manager selection.
(exwm--wmsn-acquire 'ask) (exwm--wmsn-acquire exwm-replace)
(when (xcb:+request-checked+request-check exwm--connection (when (xcb:+request-checked+request-check exwm--connection
(make-instance 'xcb:ChangeWindowAttributes (make-instance 'xcb:ChangeWindowAttributes
:window exwm--root :window exwm--root
@ -836,6 +842,7 @@ manager. If t, replace it, if nil, abort and ask the user if `ask'."
(run-hooks 'exwm-init-hook) (run-hooks 'exwm-init-hook)
;; Manage existing windows ;; Manage existing windows
(exwm-manage--scan)) (exwm-manage--scan))
(user-error)
((quit error) ((quit error)
(exwm-exit) (exwm-exit)
;; Rethrow error ;; Rethrow error