mirror of
https://github.com/emacs-exwm/exwm.git
synced 2024-11-27 14:57: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
|
;; Create new frame
|
||||||
(frame (with-current-buffer
|
(frame (with-current-buffer
|
||||||
(or (get-buffer "*scratch*")
|
(or (get-buffer "*scratch*")
|
||||||
(prog1 (get-buffer-create "*scratch*")
|
(progn
|
||||||
(set-buffer-major-mode "*scratch*")))
|
(set-buffer-major-mode
|
||||||
|
(get-buffer-create "*scratch*"))
|
||||||
|
(get-buffer "*scratch*")))
|
||||||
(prog2
|
(prog2
|
||||||
(exwm--lock)
|
(exwm--lock)
|
||||||
(make-frame
|
(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 ()
|
(defun exwm-input--update-focus ()
|
||||||
"Update input focus."
|
"Update input focus."
|
||||||
(when (and exwm-input--focus-window
|
(when (window-live-p exwm-input--focus-window)
|
||||||
;; The Emacs window may have been deleted
|
|
||||||
(window-buffer exwm-input--focus-window))
|
|
||||||
(with-current-buffer (window-buffer exwm-input--focus-window)
|
(with-current-buffer (window-buffer exwm-input--focus-window)
|
||||||
(if (eq major-mode 'exwm-mode)
|
(if (eq major-mode 'exwm-mode)
|
||||||
(if (not (eq exwm--frame exwm-workspace--current))
|
(if (not (eq exwm--frame exwm-workspace--current))
|
||||||
|
|
|
@ -215,18 +215,19 @@
|
||||||
"Refresh layout."
|
"Refresh layout."
|
||||||
(let ((frame (selected-frame))
|
(let ((frame (selected-frame))
|
||||||
(placeholder (or (get-buffer "*scratch*")
|
(placeholder (or (get-buffer "*scratch*")
|
||||||
(prog1 (get-buffer-create "*scratch*")
|
(progn
|
||||||
(set-buffer-major-mode "*scratch*"))))
|
(set-buffer-major-mode
|
||||||
|
(get-buffer-create "*scratch*"))
|
||||||
|
(get-buffer "*scratch*"))))
|
||||||
windows)
|
windows)
|
||||||
(if (not (memq frame exwm-workspace--list))
|
(if (not (memq frame exwm-workspace--list))
|
||||||
(if (frame-parameter frame 'exwm-window-id)
|
(if (frame-parameter frame 'exwm-window-id)
|
||||||
;; Refresh a floating frame
|
;; Refresh a floating frame
|
||||||
(progn
|
(when (eq major-mode 'exwm-mode)
|
||||||
(when (eq major-mode 'exwm-mode)
|
(let ((window (frame-first-window frame)))
|
||||||
(let ((window (frame-first-window frame)))
|
(with-current-buffer (window-buffer window)
|
||||||
(with-current-buffer (window-buffer window)
|
(exwm--log "Refresh floating window #x%x" exwm--id)
|
||||||
(exwm--log "Refresh floating window #x%x" exwm--id)
|
(exwm-layout--show exwm--id window))))
|
||||||
(exwm-layout--show exwm--id window)))))
|
|
||||||
;; Other frames (e.g. terminal/graphical frame of emacsclient)
|
;; Other frames (e.g. terminal/graphical frame of emacsclient)
|
||||||
;; We shall bury all `exwm-mode' buffers in this case
|
;; We shall bury all `exwm-mode' buffers in this case
|
||||||
(unless placeholder ;create the *scratch* buffer if it's killed
|
(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-current-index 0 "Index of current active workspace.")
|
||||||
(defvar exwm-workspace-show-all-buffers nil
|
(defvar exwm-workspace-show-all-buffers nil
|
||||||
"Non-nil to show buffers on other workspaces.")
|
"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
|
;;;###autoload
|
||||||
(defun exwm-workspace-switch (index &optional force)
|
(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)))
|
(let ((frame (elt exwm-workspace--list index)))
|
||||||
(setq exwm-workspace--current frame
|
(setq exwm-workspace--current frame
|
||||||
exwm-workspace-current-index index)
|
exwm-workspace-current-index index)
|
||||||
(unless force (cl-incf exwm-workspace--switch-count))
|
|
||||||
(select-frame-set-input-focus frame)
|
(select-frame-set-input-focus frame)
|
||||||
;; Move mouse when necessary
|
;; Move mouse when necessary
|
||||||
(let ((position (mouse-pixel-position))
|
(let ((position (mouse-pixel-position))
|
||||||
|
@ -167,14 +162,14 @@ The optional FORCE option is for internal use only."
|
||||||
|
|
||||||
(defun exwm-workspace--on-focus-in ()
|
(defun exwm-workspace--on-focus-in ()
|
||||||
"Fix unexpected frame switch."
|
"Fix unexpected frame switch."
|
||||||
(let ((index (cl-position (selected-frame) exwm-workspace--list)))
|
;; `focus-in-hook' is run by `handle-switch-frame'
|
||||||
(exwm--log "Focus on workspace %s" index)
|
(unless (eq this-command 'handle-switch-frame)
|
||||||
;; Close the (possible) active minibuffer
|
(let ((index (cl-position (selected-frame) exwm-workspace--list)))
|
||||||
(when (active-minibuffer-window) (abort-recursive-edit))
|
(exwm--log "Focus on workspace %s" index)
|
||||||
(when (and index (/= index exwm-workspace-current-index))
|
(when (and index (/= index exwm-workspace-current-index))
|
||||||
(exwm--log "Workspace was switched unexpectedly")
|
(exwm--log "Workspace was switched unexpectedly")
|
||||||
(if (< 0 exwm-workspace--switch-count)
|
;; Close the (possible) active minibuffer
|
||||||
(cl-decf exwm-workspace--switch-count)
|
(when (active-minibuffer-window) (abort-recursive-edit))
|
||||||
(exwm-workspace-switch index)))))
|
(exwm-workspace-switch index)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
@ -221,8 +216,10 @@ The optional FORCE option is for internal use only."
|
||||||
(bury-buffer)
|
(bury-buffer)
|
||||||
(set-window-buffer (get-buffer-window (current-buffer) t)
|
(set-window-buffer (get-buffer-window (current-buffer) t)
|
||||||
(or (get-buffer "*scratch*")
|
(or (get-buffer "*scratch*")
|
||||||
(prog1 (get-buffer-create "*scratch*")
|
(progn
|
||||||
(set-buffer-major-mode "*scratch*")))))
|
(set-buffer-major-mode
|
||||||
|
(get-buffer-create "*scratch*"))
|
||||||
|
(get-buffer "*scratch*")))))
|
||||||
(exwm-layout--hide id)
|
(exwm-layout--hide id)
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:ReparentWindow
|
(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))
|
(select-frame-set-input-focus (car exwm-workspace--list))
|
||||||
(dolist (i exwm-workspace--list)
|
(dolist (i exwm-workspace--list)
|
||||||
(set-frame-parameter i 'visibility t)
|
(set-frame-parameter i 'visibility t)
|
||||||
(lower-frame i)
|
(lower-frame i))
|
||||||
(set-frame-parameter i 'fullscreen 'fullboth))
|
;; 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))
|
(raise-frame (car exwm-workspace--list))
|
||||||
;; Handle unexpected frame switch
|
;; Handle unexpected frame switch
|
||||||
(add-hook 'focus-in-hook #'exwm-workspace--on-focus-in)
|
(add-hook 'focus-in-hook #'exwm-workspace--on-focus-in)
|
||||||
|
|
Loading…
Reference in a new issue