mirror of
https://github.com/ch11ng/exwm.git
synced 2025-02-26 06:14:33 +01:00
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:
parent
99493190c6
commit
a834eb5f41
1 changed files with 16 additions and 13 deletions
|
@ -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))
|
||||||
|
;; TODO: this prevents user having a creating initial workspaces by making
|
||||||
|
;; frames in their configuration before launching EXWM.
|
||||||
|
(cl-assert (= 1 (length initial-workspaces)))
|
||||||
;; Configure workspaces
|
;; Configure workspaces
|
||||||
(dolist (i exwm-workspace--list)
|
(dolist (i initial-workspaces)
|
||||||
(exwm-workspace--add-frame-as-workspace i))
|
(exwm-workspace--add-frame-as-workspace i))
|
||||||
(select-frame-set-input-focus (car exwm-workspace--list))
|
(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.
|
||||||
|
|
Loading…
Reference in a new issue