From b12c67de2ed10e2528b1c494aa08d51b43e563dd Mon Sep 17 00:00:00 2001 From: Chris Feng Date: Sun, 10 Mar 2019 00:00:00 +0000 Subject: [PATCH] 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. --- exwm-core.el | 3 --- exwm.el | 11 +++++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/exwm-core.el b/exwm-core.el index 9b6877b..55fbecd 100644 --- a/exwm-core.el +++ b/exwm-core.el @@ -41,9 +41,6 @@ (defvar exwm--wmsn-acquire-timeout 3 "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 "An X window separating workspaces and X windows.") diff --git a/exwm.el b/exwm.el index fca8b5d..7d301ab 100644 --- a/exwm.el +++ b/exwm.el @@ -99,6 +99,12 @@ "Subrs (primitives) that would normally block EXWM." :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" "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) (setq replace (yes-or-no-p "Replace existing window manager? "))) (when (not replace) - (error "Other window manager detected"))) + (user-error "Other window manager detected"))) (let ((new-owner (xcb:generate-id exwm--connection))) (xcb:+request exwm--connection (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:ewmh:init exwm--connection t) ;; Try to register window manager selection. - (exwm--wmsn-acquire 'ask) + (exwm--wmsn-acquire exwm-replace) (when (xcb:+request-checked+request-check exwm--connection (make-instance 'xcb:ChangeWindowAttributes :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) ;; Manage existing windows (exwm-manage--scan)) + (user-error) ((quit error) (exwm-exit) ;; Rethrow error