about summary refs log tree commit diff
path: root/exwm-workspace.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-07-21T05·02+0800
committerChris Feng <chris.w.feng@gmail.com>2016-07-21T05·02+0800
commit86777c54f341e3a0921c0970a4ed3fb99753e66d (patch)
tree75d8020cf5daf761e2d8772d5112d2d8910aa954 /exwm-workspace.el
parent76ced38ae43a9192ed97ca35dd1cc83c62b2a073 (diff)
Improve the performance of workspace creation
* exwm-workspace.el (exwm-workspace--add-frame-as-workspace): Do not run
`exwm-workspace-list-change-hook' when create workspace in the background.
(exwm-workspace-switch-create): Run the hook once.
(exwm-workspace--prompt-add): Run the hook.
Diffstat (limited to 'exwm-workspace.el')
-rw-r--r--exwm-workspace.el14
1 files changed, 9 insertions, 5 deletions
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 2ff5e0ce04..b3c2390936 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -110,14 +110,17 @@ NIL if FRAME is not a workspace"
 (defvar exwm-workspace--prompt-delete-allowed nil
   "Non-nil to allow deleting workspace from the prompt")
 (defvar exwm-workspace--create-silently nil
-  "When non-nil workspaces are created in the background (not switched to).")
+  "When non-nil workspaces are created in the background (not switched to).
+
+Please manually run the hook `exwm-workspace-list-change-hook' afterwards.")
 
 (defun exwm-workspace--prompt-add ()
   "Add workspace from the prompt."
   (interactive)
   (when exwm-workspace--prompt-add-allowed
     (let ((exwm-workspace--create-silently t))
-      (make-frame))
+      (make-frame)
+      (run-hooks 'exwm-workspace-list-change-hook))
     (exwm-workspace--update-switch-history)
     (goto-history-element minibuffer-history-position)))
 
@@ -507,7 +510,8 @@ each time.")
       (dotimes (_ (min exwm-workspace-switch-create-limit
                        (1+ (- frame-or-index
                               (exwm-workspace--count)))))
-        (make-frame)))
+        (make-frame))
+      (run-hooks 'exwm-workspace-list-change-hook))
     (exwm-workspace-switch (car (last exwm-workspace--list)))))
 
 (defvar exwm-workspace-list-change-hook nil
@@ -1174,8 +1178,8 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first."
     (exwm-workspace--update-ewmh-props)
     (if exwm-workspace--create-silently
         (setq exwm-workspace--switch-history-outdated t)
-      (exwm-workspace-switch frame t))
-    (run-hooks 'exwm-workspace-list-change-hook))))
+      (exwm-workspace-switch frame t)
+      (run-hooks 'exwm-workspace-list-change-hook)))))
 
 (defun exwm-workspace--remove-frame-as-workspace (frame)
   "Stop treating frame FRAME as a workspace."