branch: externals/exwm
commit 7679a7bd0a4622398be3850527712f8c7538e59f
Author: Steven Allen <[email protected]>
Commit: Steven Allen <[email protected]>
Avoid stealing active workspaces
When deleting the current workspace, never try to replace it with
another active workspace from a different monitor.
* exwm-workspace.el (exwm-workspace--get-next-workspace): Avoid stealing
an active workspace.
---
exwm-workspace.el | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 61becb00f3..953d68c482 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -1377,12 +1377,21 @@ ALIST is an action alist, as accepted by function
`display-buffer'."
(defun exwm-workspace--get-next-workspace (frame)
"Return the next workspace if workspace FRAME were removed.
-Return nil if FRAME is the only workspace."
+Return nil there are no other worksapces and/or all other workspaces
+are currently visible on other monitors."
(let* ((index (exwm-workspace--position frame))
- (lastp (= index (1- (exwm-workspace--count))))
- (nextw (elt exwm-workspace--list (+ index (if lastp -1 +1)))))
- (unless (eq frame nextw)
- nextw)))
+ (count (exwm-workspace--count)))
+ (or
+ (cl-loop for i from (1+ index) below count
+ for nextw = (elt exwm-workspace--list i)
+ unless (or (eq frame nextw)
+ (exwm-workspace--active-p nextw))
+ return nextw)
+ (cl-loop for i from (1- index) downto 0
+ for nextw = (elt exwm-workspace--list i)
+ unless (or (eq frame nextw)
+ (exwm-workspace--active-p nextw))
+ return nextw))))
(defun exwm-workspace--remove-frame-as-workspace (frame &optional quit)
"Stop treating FRAME as a workspace.