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
This commit is contained in:
Chris Feng 2015-08-08 20:12:07 +08:00
parent 52984898ec
commit 63402b0efc
2 changed files with 21 additions and 16 deletions

View file

@ -157,23 +157,25 @@
(setq exwm--fullscreen nil) (setq exwm--fullscreen nil)
(exwm-input-grab-keyboard))) (exwm-input-grab-keyboard)))
(defvar exwm-layout--window-configuration (current-window-configuration)
"Last saved window configuration, for avoiding unnecessary refreshes.")
(defun exwm-layout--refresh () (defun exwm-layout--refresh ()
"Refresh layout." "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)) (let ((frame (selected-frame))
windows) windows placeholder)
(if (not (memq frame exwm-workspace--list)) (if (not (memq frame exwm-workspace--list))
;; Refresh a floating frame ;; Refresh a floating frame
(when (eq major-mode 'exwm-mode) (progn
(with-current-buffer (window-buffer (frame-first-window frame)) (cl-assert (eq major-mode 'exwm-mode))
(exwm-layout--show exwm--id (frame-first-window frame)))) (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 ;; 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) (dolist (pair exwm--id-buffer-alist)
(with-current-buffer (cdr pair) (with-current-buffer (cdr pair)
;; Exclude windows on other workspaces and floating frames ;; Exclude windows on other workspaces and floating frames
@ -183,7 +185,7 @@
(exwm-layout--hide exwm--id) (exwm-layout--hide exwm--id)
(exwm-layout--show exwm--id (car windows)) (exwm-layout--show exwm--id (car windows))
(dolist (i (cdr windows)) (dolist (i (cdr windows))
(set-window-buffer i "*scratch*")))))))))) (set-window-buffer i placeholder))))))))))
(defun exwm-layout--init () (defun exwm-layout--init ()
"Initialize layout module." "Initialize layout module."

View file

@ -201,6 +201,8 @@
;; Force update input focus ;; Force update input focus
(setq exwm-input--focus-id xcb:Window:None) (setq exwm-input--focus-id xcb:Window:None)
(exwm-input--update-focus) (exwm-input--update-focus)
;; Force refresh
(exwm-layout--refresh)
(exwm-input-grab-keyboard)))) (exwm-input-grab-keyboard))))
(defmacro exwm--with-current-id (id &rest body) (defmacro exwm--with-current-id (id &rest body)
@ -396,6 +398,7 @@
(exwm--update-protocols id t)) (exwm--update-protocols id t))
((= atom xcb:Atom:WM_STATE) ((= atom xcb:Atom:WM_STATE)
(exwm--update-state id t)) (exwm--update-state id t))
((= atom xcb:Atom:_NET_WM_USER_TIME)) ;ignored
(t (exwm--log "Unhandled PropertyNotify: %s(%d)" (t (exwm--log "Unhandled PropertyNotify: %s(%d)"
(x-get-atom-name atom) atom))))))) (x-get-atom-name atom) atom)))))))