about summary refs log tree commit diff
path: root/exwm-layout.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2015-08-10T02·55+0800
committerChris Feng <chris.w.feng@gmail.com>2015-08-10T02·55+0800
commit2d4104a0eceb7d043ed1cd6bdd1bda1db4f91a73 (patch)
treef5c4ff13d71d6d2a843e7478398822112cac272a /exwm-layout.el
parentedc70eb6616b818463c94b5ab8c9e3f1dfd177c9 (diff)
Fix emacsclient bugs
`emacsclient` started with `-c` or `-t` argument create a new frame that shall
not be used to manage X windows.
Also fix some related input focus issues (with some remaining unfixed).
Close #17.
Diffstat (limited to 'exwm-layout.el')
-rw-r--r--exwm-layout.el53
1 files changed, 32 insertions, 21 deletions
diff --git a/exwm-layout.el b/exwm-layout.el
index 414aa37cbc31..4ae4859a224f 100644
--- a/exwm-layout.el
+++ b/exwm-layout.el
@@ -160,32 +160,43 @@
 (defun exwm-layout--refresh ()
   "Refresh layout."
   (let ((frame (selected-frame))
-        windows placeholder)
+        (placeholder (get-buffer "*scratch*"))
+        windows)
     (if (not (memq frame exwm-workspace--list))
-        ;; Refresh a floating frame
-        (progn
-          (cl-assert (eq major-mode 'exwm-mode))
-          (let ((window (frame-first-window frame)))
+        (if (frame-parameter frame 'exwm-window-id)
+            ;; Refresh a floating frame
+            (progn
+              (cl-assert (eq major-mode 'exwm-mode))
+              (let ((window (frame-first-window frame)))
+                (with-current-buffer (window-buffer window)
+                  (exwm--log "Refresh floating window #x%x" exwm--id)
+                  (exwm-layout--show exwm--id window))))
+          ;; Other frames (e.g. terminal/graphical frame of emacsclient)
+          ;; We shall bury all `exwm-mode' buffers in this case
+          (unless placeholder ;create the *scratch* buffer if it's killed
+            (setq placeholder (get-buffer-create "*scratch*"))
+            (set-buffer-major-mode placeholder))
+          (setq windows (window-list frame 0)) ;exclude minibuffer
+          (dolist (window windows)
             (with-current-buffer (window-buffer window)
-              (exwm--log "Refresh floating window #x%x" exwm--id)
-              (exwm-layout--show exwm--id window))))
+              (when (eq major-mode 'exwm-mode)
+                (set-window-buffer window placeholder)))))
       ;; Refresh the whole workspace
       ;; Workspaces other than the active one can also be refreshed (RandR)
       (exwm--log "Refresh workspace %s" frame)
-      (let ((placeholder (get-buffer "*scratch*")))
-        (unless placeholder ;create the *scratch* buffer if it's killed
-          (setq placeholder (get-buffer-create "*scratch*"))
-          (set-buffer-major-mode placeholder))
-        (dolist (pair exwm--id-buffer-alist)
-          (with-current-buffer (cdr pair)
-            ;; Exclude windows on other workspaces and floating frames
-            (when (and (eq frame exwm--frame) (not exwm--floating-frame))
-              (setq windows (get-buffer-window-list (current-buffer) 0))
-              (if (not windows)
-                  (exwm-layout--hide exwm--id)
-                (exwm-layout--show exwm--id (car windows))
-                (dolist (i (cdr windows))
-                  (set-window-buffer i placeholder))))))))))
+      (unless placeholder  ;create the *scratch* buffer if it's killed
+        (setq placeholder (get-buffer-create "*scratch*"))
+        (set-buffer-major-mode placeholder))
+      (dolist (pair exwm--id-buffer-alist)
+        (with-current-buffer (cdr pair)
+          ;; Exclude windows on other workspaces and floating frames
+          (when (and (eq frame exwm--frame) (not exwm--floating-frame))
+            (setq windows (get-buffer-window-list (current-buffer) 0))
+            (if (not windows)
+                (exwm-layout--hide exwm--id)
+              (exwm-layout--show exwm--id (car windows))
+              (dolist (i (cdr windows))
+                (set-window-buffer i placeholder)))))))))
 
 (defun exwm-layout--on-minibuffer-setup ()
   "Refresh layout when minibuffer grows."