emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/xelb f0d9e5af9f: Cleanup X connections on disconnect (#


From: ELPA Syncer
Subject: [elpa] externals/xelb f0d9e5af9f: Cleanup X connections on disconnect (#2)
Date: Sun, 14 Jan 2024 01:50:52 -0500 (EST)

branch: externals/xelb
commit f0d9e5af9f20fce6a270e0b316a2bed426cc5eba
Author: Steven Allen <steven@stebalien.com>
Commit: GitHub <noreply@github.com>

    Cleanup X connections on disconnect (#2)
    
    If the server disconnects from us (e.g., exits), use the process
    sentinel to cleanup the connection object and mark it as disconnected.
    Otherwise, all the "is connected" checks in EXWM aren't very useful.
    
    This makes it possible to call `(exwm-exit)` followed by `(exwm-init)`
    after X crashes to restart exwm. Otherwise, `exwm-exit` errors.
    
    * xelb.el (xcb:-connection-sentinel): Define a sentinel function that
      marks the connection as disconnected on disconnect.
      (xcb:-connect): Bind the sentinel function.
      (xcb:disconnect): Ignore connection errors on disconnect (in case
      we're already disconnected).
---
 xcb.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/xcb.el b/xcb.el
index 7c3446946e..6c2d9e7920 100644
--- a/xcb.el
+++ b/xcb.el
@@ -204,6 +204,7 @@
                        (plist-put (process-plist process) 'connection obj))
     (set-process-coding-system process 'binary 'binary)
     (set-process-filter process #'xcb:-connection-setup-filter)
+    (set-process-sentinel process #'xcb:-connection-sentinel)
     (process-send-string                ;send setup packet
      process
      (apply #'unibyte-string
@@ -267,6 +268,11 @@
             (x (error "Unrecognized setup status: %d" x)))))
       (setf (slot-value connection 'lock) nil))))
 
+(defun xcb:-connection-sentinel (process _event)
+  "Process sentinel used to teardown the connection on disconnect."
+  (unless (process-live-p process)
+    (xcb:disconnect (plist-get (process-plist process) 'connection))))
+
 (cl-defmethod xcb:-convert-sequence ((obj xcb:connection) sequence16)
   "Convert 16-bit sequence number SEQUENCE16 (read from a packet).
 
@@ -419,7 +425,7 @@ Concurrency is disabled as it breaks the orders of errors, 
replies and events."
 (cl-defmethod xcb:disconnect ((obj xcb:connection))
   "Disconnect from X server."
   (when (slot-value obj 'connected)
-    (xcb:flush obj)
+    (ignore-errors (xcb:flush obj))
     (delete-process (slot-value obj 'process))
     ;; Reset every slot to its default value
     (let ((slots (eieio-class-slots 'xcb:connection)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]