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-08T12·12+0800
committerChris Feng <chris.w.feng@gmail.com>2015-08-08T12·12+0800
commit63402b0efc19a50e89d868fad3f91b134170aab6 (patch)
tree64fc73ac2844941b083a66c49bf6221c946de774 /exwm-layout.el
parent52984898ec8d59fe42e86a311c7e7dbeec95c611 (diff)
Correct layout refresh problems
* Relax the conditions to refresh layout; this may introduce some overheads
  though
* Fix the problem when `*scratch*` buffer is killed; close #12
* Enhance `exwm-reset` by forcing layout refresh in it. This should allow users
  to overcome some layout bugs
Diffstat (limited to 'exwm-layout.el')
-rw-r--r--exwm-layout.el34
1 files changed, 18 insertions, 16 deletions
diff --git a/exwm-layout.el b/exwm-layout.el
index 1dd8333bb420..906357ed3448 100644
--- a/exwm-layout.el
+++ b/exwm-layout.el
@@ -157,23 +157,25 @@
     (setq exwm--fullscreen nil)
     (exwm-input-grab-keyboard)))
 
-(defvar exwm-layout--window-configuration (current-window-configuration)
-  "Last saved window configuration, for avoiding unnecessary refreshes.")
-
 (defun exwm-layout--refresh ()
   "Refresh layout."
-  (unless (compare-window-configurations exwm-layout--window-configuration
-                                         (current-window-configuration))
-    (exwm--log "Refresh layout")
-    (setq exwm-layout--window-configuration (current-window-configuration))
-    (let ((frame (selected-frame))
-          windows)
-      (if (not (memq frame exwm-workspace--list))
-          ;; Refresh a floating frame
-          (when (eq major-mode 'exwm-mode)
-            (with-current-buffer (window-buffer (frame-first-window frame))
-              (exwm-layout--show exwm--id (frame-first-window frame))))
-        ;; Refresh the whole workspace
+  (let ((frame (selected-frame))
+        windows placeholder)
+    (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)))
+            (with-current-buffer (window-buffer window)
+              (exwm--log "Refresh floating window #x%x" exwm--id)
+              (exwm-layout--show exwm--id window))))
+      ;; 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
@@ -183,7 +185,7 @@
                   (exwm-layout--hide exwm--id)
                 (exwm-layout--show exwm--id (car windows))
                 (dolist (i (cdr windows))
-                  (set-window-buffer i "*scratch*"))))))))))
+                  (set-window-buffer i placeholder))))))))))
 
 (defun exwm-layout--init ()
   "Initialize layout module."