about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2018-11-04T00·00+0000
committerChris Feng <chris.w.feng@gmail.com>2018-11-04T00·00+0000
commitfec85bb72a2d93fb86949f3409327b0f88ae60bc (patch)
tree45d4d633af89c406508ec7418f8ab7efc30947d9
parentdbccda22a6b6e32a9e547954ec660ad8e80b7416 (diff)
Select more sensible buffers after creating new windows
* exwm-layout.el (exwm-layout--refresh-other)
(exwm-layout--refresh-workspace): When filling vacated windows
select more sensible buffer by calling `switch-to-next-buffer' for
newly created windows.
-rw-r--r--exwm-layout.el12
1 files changed, 9 insertions, 3 deletions
diff --git a/exwm-layout.el b/exwm-layout.el
index bee6901f8291..b97c2f3ed2e6 100644
--- a/exwm-layout.el
+++ b/exwm-layout.el
@@ -296,7 +296,9 @@ selected by `other-buffer'."
     (dolist (window windows)
       (with-current-buffer (window-buffer window)
         (when (derived-mode-p 'exwm-mode)
-          (switch-to-prev-buffer window))))))
+          (if (window-prev-buffers window)
+              (switch-to-prev-buffer window)
+            (switch-to-next-buffer window)))))))
 
 (defun exwm-layout--refresh-workspace (frame)
   "Refresh workspace frame FRAME."
@@ -346,14 +348,18 @@ selected by `other-buffer'."
     ;; Set some sensible buffer to vacated windows.
     (let ((exwm-layout--other-buffer-exclude-buffers covered-buffers))
       (dolist (window vacated-windows)
-        (switch-to-prev-buffer window)))
+        (if (window-prev-buffers window)
+            (switch-to-prev-buffer window)
+          (switch-to-next-buffer window))))
     ;; Make sure windows floating / on other workspaces are excluded
     (let ((exwm-layout--other-buffer-exclude-exwm-mode-buffers t))
       (dolist (window (window-list frame 'nomini))
         (with-current-buffer (window-buffer window)
           (when (and (derived-mode-p 'exwm-mode)
                      (or exwm--floating-frame (not (eq frame exwm--frame))))
-            (switch-to-prev-buffer window)))))
+            (if (window-prev-buffers window)
+                (switch-to-prev-buffer window)
+              (switch-to-next-buffer window))))))
     (exwm-layout--set-client-list-stacking)
     (xcb:flush exwm--connection)))