Manage workspace list via helper functions

Avoid manipulating the workspace list except through the functions
`exwm-workspace--{add,remove}-frame-as-workspace'.
This commit is contained in:
Urbano Ustero 2015-08-26 23:37:48 +02:00
parent 99493190c6
commit a834eb5f41

View file

@ -293,19 +293,22 @@ The optional FORCE option is for internal use only."
(x (yes-or-no-p (format "[EXWM] %d window%s currently alive. %s" (x (yes-or-no-p (format "[EXWM] %d window%s currently alive. %s"
x (if (= x 1) "" "s") prompt)))))) x (if (= x 1) "" "s") prompt))))))
;; Initialize workspaces ;; Initialize workspaces
(setq exwm-workspace--list (frame-list)) (let ((initial-workspaces (frame-list)))
(when (< 1 (exwm-workspace--count)) (when (< 1 (length initial-workspaces))
;; Emacs client creates an extra (but unusable) frame ;; Emacs client creates an extra (but unusable) frame
(dolist (i exwm-workspace--list) (dolist (i initial-workspaces)
(unless (frame-parameter i 'window-id) (unless (frame-parameter i 'window-id)
(setq exwm-workspace--list (delq i exwm-workspace--list)))) (setq initial-workspaces (delq i initial-workspaces))))
(cl-assert (= 1 (exwm-workspace--count))) (cl-assert (= 1 (exwm-workspace--count)))
;; Prevent user from deleting this frame by accident ;; Prevent user from deleting this frame by accident
(set-frame-parameter (car exwm-workspace--list) 'client nil)) (set-frame-parameter (car initial-workspaces) 'client nil))
;; Configure workspaces ;; TODO: this prevents user having a creating initial workspaces by making
(dolist (i exwm-workspace--list) ;; frames in their configuration before launching EXWM.
(exwm-workspace--add-frame-as-workspace i)) (cl-assert (= 1 (length initial-workspaces)))
(select-frame-set-input-focus (car exwm-workspace--list)) ;; Configure workspaces
(dolist (i initial-workspaces)
(exwm-workspace--add-frame-as-workspace i))
(select-frame-set-input-focus (car initial-workspaces)))
;; Handle unexpected frame switch ;; Handle unexpected frame switch
(add-hook 'focus-in-hook 'exwm-workspace--on-focus-in) (add-hook 'focus-in-hook 'exwm-workspace--on-focus-in)
;; Make new frames create new workspaces. ;; Make new frames create new workspaces.