mirror of
https://github.com/ch11ng/exwm.git
synced 2024-11-27 13:07:59 +01:00
Refactor `exwm-workspace--get-remove-frame-next-workspace'
* exwm-workspace.el (exwm-workspace--prompt-delete) (exwm-workspace--set-desktop): Stop explicitly moving X windows to other workspace; dealt with by `exwm-workspace--remove-frame-as-workspace'. (exwm-workspace--get-remove-frame-next-workspace): Remove function. Refactored into `exwm-workspace--get-next-workspace' and `exwm-workspace--remove-frame-as-workspace'. (exwm-workspace--get-next-workspace): Add function. (exwm-workspace--remove-frame-as-workspace): Move X windows to next workspace.
This commit is contained in:
parent
10bd12234e
commit
62ffde76aa
2 changed files with 15 additions and 24 deletions
|
@ -264,7 +264,6 @@ NIL if FRAME is not a workspace"
|
||||||
(when (and exwm-workspace--prompt-delete-allowed
|
(when (and exwm-workspace--prompt-delete-allowed
|
||||||
(< 1 (exwm-workspace--count)))
|
(< 1 (exwm-workspace--count)))
|
||||||
(let ((frame (elt exwm-workspace--list (1- minibuffer-history-position))))
|
(let ((frame (elt exwm-workspace--list (1- minibuffer-history-position))))
|
||||||
(exwm-workspace--get-remove-frame-next-workspace frame)
|
|
||||||
(if (eq frame exwm-workspace--current)
|
(if (eq frame exwm-workspace--current)
|
||||||
;; Abort the recursive minibuffer if deleting the current workspace.
|
;; Abort the recursive minibuffer if deleting the current workspace.
|
||||||
(progn
|
(progn
|
||||||
|
@ -830,7 +829,6 @@ INDEX must not exceed the current number of workspaces."
|
||||||
(exwm-workspace--workspace-from-frame-or-index
|
(exwm-workspace--workspace-from-frame-or-index
|
||||||
frame-or-index)
|
frame-or-index)
|
||||||
exwm-workspace--current)))
|
exwm-workspace--current)))
|
||||||
(exwm-workspace--get-remove-frame-next-workspace frame)
|
|
||||||
(delete-frame frame))))
|
(delete-frame frame))))
|
||||||
|
|
||||||
(defun exwm-workspace--set-desktop (id)
|
(defun exwm-workspace--set-desktop (id)
|
||||||
|
@ -1385,20 +1383,12 @@ Please check `exwm-workspace--minibuffer-own-frame-p' first."
|
||||||
frame exwm-workspace-current-index original-index))
|
frame exwm-workspace-current-index original-index))
|
||||||
(run-hooks 'exwm-workspace-list-change-hook)))
|
(run-hooks 'exwm-workspace-list-change-hook)))
|
||||||
|
|
||||||
(defun exwm-workspace--get-remove-frame-next-workspace (frame)
|
(defun exwm-workspace--get-next-workspace (frame)
|
||||||
"Return the next workspace if workspace FRAME is removed.
|
"Return the next workspace if workspace FRAME were removed.
|
||||||
|
Return nil if FRAME is the only workspace."
|
||||||
All X windows currently on workspace FRAME will be automatically moved to
|
|
||||||
the next workspace."
|
|
||||||
(let* ((index (exwm-workspace--position frame))
|
(let* ((index (exwm-workspace--position frame))
|
||||||
(lastp (= index (1- (exwm-workspace--count))))
|
(lastp (= index (1- (exwm-workspace--count))))
|
||||||
(nextw (elt exwm-workspace--list (+ index (if lastp -1 +1)))))
|
(nextw (elt exwm-workspace--list (+ index (if lastp -1 +1)))))
|
||||||
;; Clients need to be moved to some other workspace before this being
|
|
||||||
;; removed.
|
|
||||||
(dolist (pair exwm--id-buffer-alist)
|
|
||||||
(with-current-buffer (cdr pair)
|
|
||||||
(when (eq exwm--frame frame)
|
|
||||||
(exwm-workspace-move-window nextw exwm--id))))
|
|
||||||
nextw))
|
nextw))
|
||||||
|
|
||||||
(defun exwm-workspace--remove-frame-as-workspace (frame)
|
(defun exwm-workspace--remove-frame-as-workspace (frame)
|
||||||
|
@ -1406,20 +1396,22 @@ the next workspace."
|
||||||
;; TODO: restore all frame parameters (e.g. exwm-workspace, buffer-predicate,
|
;; TODO: restore all frame parameters (e.g. exwm-workspace, buffer-predicate,
|
||||||
;; etc)
|
;; etc)
|
||||||
(exwm--log "Removing frame `%s' as workspace" frame)
|
(exwm--log "Removing frame `%s' as workspace" frame)
|
||||||
(let* ((index (exwm-workspace--position frame))
|
(let* ((next-frame (exwm-workspace--get-next-workspace frame))
|
||||||
(nextw (exwm-workspace--get-remove-frame-next-workspace frame)))
|
(following-frames (cdr (memq frame exwm-workspace--list))))
|
||||||
;; Need to remove the workspace from the list in order for
|
;; Need to remove the workspace from the list for the correct calculation of
|
||||||
;; the correct calculation of indexes.
|
;; indexes below.
|
||||||
(setq exwm-workspace--list (delete frame exwm-workspace--list))
|
(setq exwm-workspace--list (delete frame exwm-workspace--list))
|
||||||
;; Update the _NET_WM_DESKTOP property of each X window affected.
|
|
||||||
(dolist (pair exwm--id-buffer-alist)
|
(dolist (pair exwm--id-buffer-alist)
|
||||||
(when (<= (1- index)
|
(let ((other-frame (buffer-local-value 'exwm--frame (cdr pair))))
|
||||||
(exwm-workspace--position (buffer-local-value 'exwm--frame
|
;; Move X windows to next-frame.
|
||||||
(cdr pair))))
|
(when (eq other-frame frame)
|
||||||
(exwm-workspace--set-desktop (car pair))))
|
(exwm-workspace-move-window next-frame (car pair)))
|
||||||
|
;; Update the _NET_WM_DESKTOP property of each following X window.
|
||||||
|
(when (memq other-frame following-frames)
|
||||||
|
(exwm-workspace--set-desktop (car pair)))))
|
||||||
;; If the current workspace is deleted, switch to next one.
|
;; If the current workspace is deleted, switch to next one.
|
||||||
(when (eq frame exwm-workspace--current)
|
(when (eq frame exwm-workspace--current)
|
||||||
(exwm-workspace-switch nextw)))
|
(exwm-workspace-switch next-frame)))
|
||||||
;; Reparent out the frame.
|
;; Reparent out the frame.
|
||||||
(let ((outer-id (frame-parameter frame 'exwm-outer-id)))
|
(let ((outer-id (frame-parameter frame 'exwm-outer-id)))
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
|
|
1
exwm.el
1
exwm.el
|
@ -434,7 +434,6 @@
|
||||||
((and (> current requested)
|
((and (> current requested)
|
||||||
(> current 1))
|
(> current 1))
|
||||||
(let ((frame (car (last exwm-workspace--list))))
|
(let ((frame (car (last exwm-workspace--list))))
|
||||||
(exwm-workspace--get-remove-frame-next-workspace frame)
|
|
||||||
(delete-frame frame))))))
|
(delete-frame frame))))))
|
||||||
;; _NET_CURRENT_DESKTOP.
|
;; _NET_CURRENT_DESKTOP.
|
||||||
((= type xcb:Atom:_NET_CURRENT_DESKTOP)
|
((= type xcb:Atom:_NET_CURRENT_DESKTOP)
|
||||||
|
|
Loading…
Reference in a new issue