[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/exwm 7318f857f2 02/14: Observe connection status on dei
From: |
ELPA Syncer |
Subject: |
[elpa] externals/exwm 7318f857f2 02/14: Observe connection status on deinitialization |
Date: |
Wed, 6 Sep 2023 15:57:51 -0400 (EDT) |
branch: externals/exwm
commit 7318f857f2937c421094d66d976d4e926feacc71
Author: Adrián Medraño Calvo <adrian@medranocalvo.com>
Commit: Adrián Medraño Calvo <adrian@medranocalvo.com>
Observe connection status on deinitialization
* exwm-workspace.el (exwm-workspace--remove-frame-as-workspace):
Add optional argument quit.
* exwm-background.el (exwm-background--exit):
* exwm-input.el (exwm-input--exit):
* exwm-manage.el (exwm-manage--unmanage-window):
* exwm-systemtray.el (exwm-systemtray--exit):
* exwm-workspace.el (exwm-workspace--exit-minibuffer-frame)
(exwm-workspace--exit):
* exwm-xim.el (exwm-xim--exit): Observe connection status when
deinitializing in order to support deinitializing when the
connection breaks.
---
exwm-background.el | 6 ++--
exwm-input.el | 2 +-
exwm-manage.el | 9 ++++--
exwm-systemtray.el | 27 +++++++++---------
exwm-workspace.el | 81 +++++++++++++++++++++++++++++-------------------------
exwm-xim.el | 6 ++--
exwm.el | 10 +++----
7 files changed, 77 insertions(+), 64 deletions(-)
diff --git a/exwm-background.el b/exwm-background.el
index e7a0360c97..f3e0d895c5 100644
--- a/exwm-background.el
+++ b/exwm-background.el
@@ -172,19 +172,17 @@ replace it.")
(defun exwm-background--init ()
"Initialize background module."
(exwm--log)
-
(add-hook 'enable-theme-functions 'exwm-background--update)
(add-hook 'disable-theme-functions 'exwm-background--update)
-
(exwm-background--update))
(defun exwm-background--exit ()
"Uninitialize the background module."
(exwm--log)
-
(remove-hook 'enable-theme-functions 'exwm-background--update)
(remove-hook 'disable-theme-functions 'exwm-background--update)
- (when exwm-background--connection
+ (when (and exwm-background--connection
+ (slot-value exwm-background--connection 'connected))
(xcb:disconnect exwm-background--connection))
(setq exwm-background--pixmap nil
exwm-background--connection nil
diff --git a/exwm-input.el b/exwm-input.el
index 2c65116aa3..3f9a305012 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -1215,7 +1215,7 @@ One use is to access the keymap bound to KEYS (as prefix
keys) in char-mode."
(when exwm-input--update-focus-timer
(cancel-timer exwm-input--update-focus-timer))
;; Make input focus working even without a WM.
- (when exwm--connection
+ (when (slot-value exwm--connection 'connected)
(xcb:+request exwm--connection
(make-instance 'xcb:SetInputFocus
:revert-to xcb:InputFocus:PointerRoot
diff --git a/exwm-manage.el b/exwm-manage.el
index c3d47f7225..1adf66d421 100644
--- a/exwm-manage.el
+++ b/exwm-manage.el
@@ -430,7 +430,9 @@ manager is shutting down."
(exwm-workspace--update-workareas)
(dolist (f exwm-workspace--list)
(exwm-workspace--set-fullscreen f)))
- (when (buffer-live-p buffer)
+ (when (and (buffer-live-p buffer)
+ ;; Invoked from `exwm-manage--exit' upon disconnection.
+ (slot-value exwm--connection 'connected))
(with-current-buffer buffer
;; Unmap the X window.
(xcb:+request exwm--connection
@@ -512,8 +514,11 @@ manager is shutting down."
(defun exwm-manage--kill-buffer-query-function ()
"Run in `kill-buffer-query-functions'."
- (exwm--log "id=#x%x; buffer=%s" exwm--id (current-buffer))
+ (exwm--log "id=#x%x; buffer=%s" (or exwm--id 0) (current-buffer))
(catch 'return
+ (when (or (not exwm--connection)
+ (not (slot-value exwm--connection 'connected)))
+ (throw 'return t))
(when (or (not exwm--id)
(xcb:+request-checked+request-check exwm--connection
(make-instance 'xcb:ChangeWindowAttributes
diff --git a/exwm-systemtray.el b/exwm-systemtray.el
index 0f19986624..51d5213df9 100644
--- a/exwm-systemtray.el
+++ b/exwm-systemtray.el
@@ -652,19 +652,20 @@ indicate how to support actual transparency."
"Exit the systemtray module."
(exwm--log)
(when exwm-systemtray--connection
- ;; Hide & reparent out the embedder before disconnection to prevent
- ;; embedded icons from being reparented to an Emacs frame (which is the
- ;; parent of the embedder).
- (xcb:+request exwm-systemtray--connection
- (make-instance 'xcb:UnmapWindow
- :window exwm-systemtray--embedder-window))
- (xcb:+request exwm-systemtray--connection
- (make-instance 'xcb:ReparentWindow
- :window exwm-systemtray--embedder-window
- :parent exwm--root
- :x 0
- :y 0))
- (xcb:disconnect exwm-systemtray--connection)
+ (when (slot-value exwm-systemtray--connection 'connected)
+ ;; Hide & reparent out the embedder before disconnection to prevent
+ ;; embedded icons from being reparented to an Emacs frame (which is the
+ ;; parent of the embedder).
+ (xcb:+request exwm-systemtray--connection
+ (make-instance 'xcb:UnmapWindow
+ :window exwm-systemtray--embedder-window))
+ (xcb:+request exwm-systemtray--connection
+ (make-instance 'xcb:ReparentWindow
+ :window exwm-systemtray--embedder-window
+ :parent exwm--root
+ :x 0
+ :y 0))
+ (xcb:disconnect exwm-systemtray--connection))
(setq exwm-systemtray--connection nil
exwm-systemtray--list nil
exwm-systemtray--selection-owner-window nil
diff --git a/exwm-workspace.el b/exwm-workspace.el
index 06217a7769..67e3523661 100644
--- a/exwm-workspace.el
+++ b/exwm-workspace.el
@@ -1389,32 +1389,34 @@ Return nil if FRAME is the only workspace."
(unless (eq frame nextw)
nextw)))
-(defun exwm-workspace--remove-frame-as-workspace (frame)
+(defun exwm-workspace--remove-frame-as-workspace (frame &optional quit)
"Stop treating frame FRAME as a workspace."
;; TODO: restore all frame parameters (e.g. exwm-workspace, buffer-predicate,
;; etc)
(exwm--log "Removing frame `%s' as workspace" frame)
- (let* ((next-frame (exwm-workspace--get-next-workspace frame))
- (following-frames (cdr (memq frame exwm-workspace--list))))
- ;; Need to remove the workspace from the list for the correct calculation
of
- ;; indexes below.
- (setq exwm-workspace--list (delete frame exwm-workspace--list))
- (unless next-frame
- ;; The user managed to delete the last workspace, so create a new one.
- (exwm--log "Last workspace deleted; create a new one")
- (let ((exwm-workspace--create-silently t))
- (setq next-frame (make-frame))))
- (dolist (pair exwm--id-buffer-alist)
- (let ((other-frame (buffer-local-value 'exwm--frame (cdr pair))))
- ;; Move X windows to next-frame.
- (when (eq other-frame frame)
- (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.
- (when (eq frame exwm-workspace--current)
- (exwm-workspace-switch next-frame)))
+ (unless quit
+ (let* ((next-frame (exwm-workspace--get-next-workspace frame))
+ (following-frames (cdr (memq frame exwm-workspace--list))))
+ ;; Need to remove the workspace from the list for the correct
calculation of
+ ;; indexes below.
+ (setq exwm-workspace--list (delete frame exwm-workspace--list))
+ ;; Move the windows to the next workspace and switch to it.
+ (unless next-frame
+ ;; The user managed to delete the last workspace, so create a new one.
+ (exwm--log "Last workspace deleted; create a new one")
+ (let ((exwm-workspace--create-silently t))
+ (setq next-frame (make-frame))))
+ (dolist (pair exwm--id-buffer-alist)
+ (let ((other-frame (buffer-local-value 'exwm--frame (cdr pair))))
+ ;; Move X windows to next-frame.
+ (when (eq other-frame frame)
+ (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.
+ (when (eq frame exwm-workspace--current)
+ (exwm-workspace-switch next-frame))))
;; Reparent out the frame.
(let ((outer-id (frame-parameter frame 'exwm-outer-id)))
(xcb:+request exwm--connection
@@ -1448,8 +1450,9 @@ Return nil if FRAME is the only workspace."
;; Update EWMH properties.
(exwm-workspace--update-ewmh-props)
;; Update switch history.
- (setq exwm-workspace--switch-history-outdated t)
- (run-hooks 'exwm-workspace-list-change-hook))
+ (unless quit
+ (setq exwm-workspace--switch-history-outdated t)
+ (run-hooks 'exwm-workspace-list-change-hook)))
(defun exwm-workspace--on-delete-frame (frame)
"Hook run upon `delete-frame' that tears down FRAME's configuration as a
workspace."
@@ -1623,7 +1626,9 @@ applied to all subsequently created X frames."
(setq default-minibuffer-frame nil)
(when (frame-live-p exwm-workspace--minibuffer) ; might be already dead
(let ((id (frame-parameter exwm-workspace--minibuffer 'exwm-outer-id)))
- (when (and exwm-workspace--minibuffer id)
+ (when (and exwm-workspace--minibuffer id
+ ;; Invoked from `exwm-manage--exit' upon disconnection.
+ (slot-value exwm--connection 'connected))
(xcb:+request exwm--connection
(make-instance 'xcb:ReparentWindow
:window id
@@ -1708,19 +1713,21 @@ applied to all subsequently created X frames."
#'exwm-workspace--on-echo-area-clear))
;; Hide & reparent out all frames (save-set can't be used here since
;; X windows will be re-mapped).
- (setq exwm-workspace--current nil)
- (dolist (i exwm-workspace--list)
- (when (frame-live-p i) ; might be already dead
- (exwm-workspace--remove-frame-as-workspace i)
- (modify-frame-parameters i '((exwm-selected-window . nil)
- (exwm-urgency . nil)
- (exwm-outer-id . nil)
- (exwm-id . nil)
- (exwm-container . nil)
- ;; (internal-border-width . nil) ; integerp
- (fullscreen . nil)
- (buffer-predicate . nil)))))
+ (when (slot-value exwm--connection 'connected)
+ (dolist (i exwm-workspace--list)
+ (when (frame-live-p i) ; might be already dead
+ (exwm-workspace--remove-frame-as-workspace i 'quit)
+ (modify-frame-parameters i '((exwm-selected-window . nil)
+ (exwm-urgency . nil)
+ (exwm-outer-id . nil)
+ (exwm-id . nil)
+ (exwm-container . nil)
+ ;; (internal-border-width . nil) ;
integerp
+ (fullscreen . nil)
+ (buffer-predicate . nil))))))
;; Don't let dead frames linger.
+ (setq exwm-workspace--current nil)
+ (setq exwm-workspace-current-index 0)
(setq exwm-workspace--list nil))
(defun exwm-workspace--post-init ()
diff --git a/exwm-xim.el b/exwm-xim.el
index 9589648d22..ac530f3893 100644
--- a/exwm-xim.el
+++ b/exwm-xim.el
@@ -754,10 +754,12 @@ Such event would be received when the client window is
destroyed."
;; Close IMS communication connections.
(mapc (lambda (i)
(when (vectorp i)
- (xcb:disconnect (elt i 0))))
+ (when (slot-value (elt i 0) 'connected)
+ (xcb:disconnect (elt i 0)))))
exwm-xim--server-client-plist)
;; Close the IMS connection.
- (unless exwm-xim--conn
+ (unless (and exwm-xim--conn
+ (slot-value exwm-xim--conn 'connected))
(cl-return-from exwm-xim--exit))
;; Remove exwm-xim from XIM_SERVERS.
(let ((reply (xcb:+request-unchecked+reply exwm-xim--conn
diff --git a/exwm.el b/exwm.el
index 345f76beb6..31fe684955 100644
--- a/exwm.el
+++ b/exwm.el
@@ -907,12 +907,12 @@ manager. If t, replace it, if nil, abort and ask the
user if `ask'."
(run-hooks 'exwm-exit-hook)
(setq confirm-kill-emacs nil)
;; Exit modules.
- (exwm-input--exit)
- (exwm-manage--exit)
- (exwm-workspace--exit)
- (exwm-floating--exit)
- (exwm-layout--exit)
(when exwm--connection
+ (exwm-input--exit)
+ (exwm-manage--exit)
+ (exwm-workspace--exit)
+ (exwm-floating--exit)
+ (exwm-layout--exit)
(xcb:flush exwm--connection)
(xcb:disconnect exwm--connection))
(setq exwm--connection nil)
- [elpa] externals/exwm updated (a417f0d45e -> 381637aa1c), ELPA Syncer, 2023/09/06
- [elpa] externals/exwm b100eb74c5 04/14: Merge branch 'nbarrientos.github.com/ib_exwm_conn_nil' into externals/exwm, ELPA Syncer, 2023/09/06
- [elpa] externals/exwm 23f1ca740d 07/14: Selectively ignore left & right struts in horizontally aligned monitors, ELPA Syncer, 2023/09/06
- [elpa] externals/exwm 612e64bf9b 10/14: Update copyright year to 2023, ELPA Syncer, 2023/09/06
- [elpa] externals/exwm d340a6a563 08/14: Merge branch 'jollm.github.com/ignore-struts-top-bottom' into externals/exwm, ELPA Syncer, 2023/09/06
- [elpa] externals/exwm c7d1fd45bc 12/14: Fix layout being refreshed too often on minibuffer setup, ELPA Syncer, 2023/09/06
- [elpa] externals/exwm 67c5b316be 05/14: Convert `exwm-workspace--workareas' to a list of `xcb:RECTANGLE's, ELPA Syncer, 2023/09/06
- [elpa] externals/exwm cff02333e2 01/14: Don't assume that exwm--connection is non-nil, ELPA Syncer, 2023/09/06
- [elpa] externals/exwm 7318f857f2 02/14: Observe connection status on deinitialization,
ELPA Syncer <=
- [elpa] externals/exwm d8fcf18db7 09/14: Declare defsubst indentation, ELPA Syncer, 2023/09/06
- [elpa] externals/exwm fb73aaaf8f 11/14: Convert `lsh' to `ash', ELPA Syncer, 2023/09/06
- [elpa] externals/exwm d3567a8c7f 13/14: Fix bytecompiler warnings, improve docstrings, ELPA Syncer, 2023/09/06
- [elpa] externals/exwm 381637aa1c 14/14: Declare external function, ELPA Syncer, 2023/09/06
- [elpa] externals/exwm 4970d6ad4e 03/14: More selectively ignore top and bottom struts, ELPA Syncer, 2023/09/06
- [elpa] externals/exwm 937da86458 06/14: Convert `delta' to the size the strut occupies in the workarea, ELPA Syncer, 2023/09/06