mirror of
https://github.com/emacs-exwm/exwm.git
synced 2024-11-23 13:07:59 +01:00
Fix problems introduced/exposed by last commit
* exwm-workspace.el (exwm-workspace-switch, exwm-workspace--on-focus-in): Use handle-switch-frame instead of exwm-workspace--switch-count to filter out events. * exwm-workspace.el (exwm-workspace--init): Delay making workspaces fullscreen. * exwm-workspace.el (exwm-workspace-move-window): * exwm-floating.el (exwm-floating--set-floating): * exwm-layout.el (exwm-layout--refresh): `set-buffer-major-mode` does not accept buffer names.
This commit is contained in:
parent
e8bc51280d
commit
d05df51b05
4 changed files with 32 additions and 30 deletions
|
@ -69,8 +69,10 @@
|
|||
;; Create new frame
|
||||
(frame (with-current-buffer
|
||||
(or (get-buffer "*scratch*")
|
||||
(prog1 (get-buffer-create "*scratch*")
|
||||
(set-buffer-major-mode "*scratch*")))
|
||||
(progn
|
||||
(set-buffer-major-mode
|
||||
(get-buffer-create "*scratch*"))
|
||||
(get-buffer "*scratch*")))
|
||||
(prog2
|
||||
(exwm--lock)
|
||||
(make-frame
|
||||
|
|
|
@ -111,9 +111,7 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
|
|||
|
||||
(defun exwm-input--update-focus ()
|
||||
"Update input focus."
|
||||
(when (and exwm-input--focus-window
|
||||
;; The Emacs window may have been deleted
|
||||
(window-buffer exwm-input--focus-window))
|
||||
(when (window-live-p exwm-input--focus-window)
|
||||
(with-current-buffer (window-buffer exwm-input--focus-window)
|
||||
(if (eq major-mode 'exwm-mode)
|
||||
(if (not (eq exwm--frame exwm-workspace--current))
|
||||
|
|
|
@ -215,18 +215,19 @@
|
|||
"Refresh layout."
|
||||
(let ((frame (selected-frame))
|
||||
(placeholder (or (get-buffer "*scratch*")
|
||||
(prog1 (get-buffer-create "*scratch*")
|
||||
(set-buffer-major-mode "*scratch*"))))
|
||||
(progn
|
||||
(set-buffer-major-mode
|
||||
(get-buffer-create "*scratch*"))
|
||||
(get-buffer "*scratch*"))))
|
||||
windows)
|
||||
(if (not (memq frame exwm-workspace--list))
|
||||
(if (frame-parameter frame 'exwm-window-id)
|
||||
;; Refresh a floating frame
|
||||
(progn
|
||||
(when (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)))))
|
||||
(when (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
|
||||
|
|
|
@ -100,10 +100,6 @@
|
|||
(defvar exwm-workspace-current-index 0 "Index of current active workspace.")
|
||||
(defvar exwm-workspace-show-all-buffers nil
|
||||
"Non-nil to show buffers on other workspaces.")
|
||||
(defvar exwm-workspace--switch-count 0
|
||||
"`exwm-workspace-switch' execution counts.
|
||||
|
||||
Consumed by `exwm-workspace--on-focus-in.'")
|
||||
|
||||
;;;###autoload
|
||||
(defun exwm-workspace-switch (index &optional force)
|
||||
|
@ -129,7 +125,6 @@ The optional FORCE option is for internal use only."
|
|||
(let ((frame (elt exwm-workspace--list index)))
|
||||
(setq exwm-workspace--current frame
|
||||
exwm-workspace-current-index index)
|
||||
(unless force (cl-incf exwm-workspace--switch-count))
|
||||
(select-frame-set-input-focus frame)
|
||||
;; Move mouse when necessary
|
||||
(let ((position (mouse-pixel-position))
|
||||
|
@ -167,14 +162,14 @@ The optional FORCE option is for internal use only."
|
|||
|
||||
(defun exwm-workspace--on-focus-in ()
|
||||
"Fix unexpected frame switch."
|
||||
(let ((index (cl-position (selected-frame) exwm-workspace--list)))
|
||||
(exwm--log "Focus on workspace %s" index)
|
||||
;; Close the (possible) active minibuffer
|
||||
(when (active-minibuffer-window) (abort-recursive-edit))
|
||||
(when (and index (/= index exwm-workspace-current-index))
|
||||
(exwm--log "Workspace was switched unexpectedly")
|
||||
(if (< 0 exwm-workspace--switch-count)
|
||||
(cl-decf exwm-workspace--switch-count)
|
||||
;; `focus-in-hook' is run by `handle-switch-frame'
|
||||
(unless (eq this-command 'handle-switch-frame)
|
||||
(let ((index (cl-position (selected-frame) exwm-workspace--list)))
|
||||
(exwm--log "Focus on workspace %s" index)
|
||||
(when (and index (/= index exwm-workspace-current-index))
|
||||
(exwm--log "Workspace was switched unexpectedly")
|
||||
;; Close the (possible) active minibuffer
|
||||
(when (active-minibuffer-window) (abort-recursive-edit))
|
||||
(exwm-workspace-switch index)))))
|
||||
|
||||
;;;###autoload
|
||||
|
@ -221,8 +216,10 @@ The optional FORCE option is for internal use only."
|
|||
(bury-buffer)
|
||||
(set-window-buffer (get-buffer-window (current-buffer) t)
|
||||
(or (get-buffer "*scratch*")
|
||||
(prog1 (get-buffer-create "*scratch*")
|
||||
(set-buffer-major-mode "*scratch*")))))
|
||||
(progn
|
||||
(set-buffer-major-mode
|
||||
(get-buffer-create "*scratch*"))
|
||||
(get-buffer "*scratch*")))))
|
||||
(exwm-layout--hide id)
|
||||
(xcb:+request exwm--connection
|
||||
(make-instance 'xcb:ReparentWindow
|
||||
|
@ -335,8 +332,12 @@ The optional FORCE option is for internal use only."
|
|||
(select-frame-set-input-focus (car exwm-workspace--list))
|
||||
(dolist (i exwm-workspace--list)
|
||||
(set-frame-parameter i 'visibility t)
|
||||
(lower-frame i)
|
||||
(set-frame-parameter i 'fullscreen 'fullboth))
|
||||
(lower-frame i))
|
||||
;; Delay making the workspaces fullscreen until Emacs becomes idle
|
||||
(run-with-idle-timer 0 nil
|
||||
(lambda ()
|
||||
(dolist (i exwm-workspace--list)
|
||||
(set-frame-parameter i 'fullscreen 'fullboth))))
|
||||
(raise-frame (car exwm-workspace--list))
|
||||
;; Handle unexpected frame switch
|
||||
(add-hook 'focus-in-hook #'exwm-workspace--on-focus-in)
|
||||
|
|
Loading…
Reference in a new issue