about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdrián Medraño Calvo <adrian@medranocalvo.com>2016-07-17T12·00+0000
committerAdrián Medraño Calvo <adrian@medranocalvo.com>2016-07-17T12·00+0000
commite4911181d317942e9946da4cbceeeb4c6ca98884 (patch)
treeb24773cc2b6d8de172a2f5f628698cf442992d35
parent2de2d42586a0a8866e7f5447d490a0c345c7ce10 (diff)
Support swapping workspaces
	* exwm-workspace.el (exwm-workspace-swap-workspaces): New
	function to interchange the position of two workspaces.
-rw-r--r--exwm-workspace.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 21a415eb813e..8627432e562d 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -394,6 +394,28 @@ The optional FORCE option is for internal use only."
       (xcb:flush exwm--connection))
      (run-hooks 'exwm-workspace-switch-hook)))
 
+;;;###autoload
+(defun exwm-workspace-swap-workspaces (workspace1 workspace2)
+  "Swap position of WORKSPACE1 with that of WORKSPACE2."
+  (interactive
+   (unless (and (eq major-mode 'exwm-mode) exwm--fullscreen) ;it's invisible
+     (list
+      (exwm-workspace--prompt-for-workspace)
+      (exwm-workspace--prompt-for-workspace))))
+  (let ((pos1 (exwm-workspace--position workspace1))
+        (pos2 (exwm-workspace--position workspace2)))
+    (if (and pos1 pos2)
+        (progn
+          (setf (elt exwm-workspace--list pos1) workspace2)
+          (setf (elt exwm-workspace--list pos2) workspace1)
+          (cond
+           ((eq exwm-workspace--current workspace1)
+            (setq exwm-workspace-current-index pos2))
+           ((eq exwm-workspace--current workspace2)
+            (setq exwm-workspace-current-index pos1))))
+      (user-error "[EXWM] Frames are not workspaces"))))
+
+
 (defun exwm-workspace--on-focus-in ()
   "Handle unexpected frame switch."
   ;; `focus-in-hook' is run by `handle-switch-frame'.