From 274cf834866e9cd6b1b64ac19267de41e31f18ec Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 3 Dec 2025 09:24:41 -0800 Subject: [PATCH] Document and warn about XIM deadlocks Emacs's built-in XIM support can deadlock when trying to communicate with EXWM. This can be fixed by configuring Emacs to NOT use XIM, so we now try to detect potential deadlocks and warn about them. * exwm-xim.el: Document how to configure Emacs to not use XIM. (exwm-xim--deadlock-warning): Add a function that warns when Emacs may deadlock with EXWM's XIM module. (exwm-xim--init): Use it. (Bug #122) --- exwm-xim.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/exwm-xim.el b/exwm-xim.el index 26aee3e..79682db 100644 --- a/exwm-xim.el +++ b/exwm-xim.el @@ -59,6 +59,11 @@ ;; export GTK_IM_MODULE=xim ;; export QT_IM_MODULE=xim ;; export CLUTTER_IM_MODULE=xim +;; +;; However, to avoid deadlocks, emacs.useXIM must be set to false or +;; off in your Xresources (see xrdb(1) and emacs(1)). Alternatively, +;; you may pass "--xrm=emacs.useXIM:false" as a command-line flag to +;; Emacs. ;; References: ;; + XIM (https://www.x.org/releases/X11R7.6/doc/libX11/specs/XIM/xim.html) @@ -673,11 +678,23 @@ Such event would be received when the client window is destroyed." (make-instance 'xcb:DestroyWindow :window server-xwin)) (xcb:disconnect conn)))) +(defun exwm-xim--deadlock-warning () + "Warn when XIM may cause Emacs to deadlock." + ;; NOTE: Checking `system-configuration-features' is unsupported, + ;; but this is JUST a warning, so it's probably fine. + (when (and (string-match-p "\\bXIM\\b" system-configuration-features) + (not (member (x-get-resource "useXIM" "UseXIM") + '("false" "off")))) + (warn "Emacs itself is configured to use XIM and may deadlock \ +when trying to communicate with EXWM. If this happens, set the \ +emacs.useXim Xresource to false or off (see xrdb(1) and emacs(1))."))) + (cl-defun exwm-xim--init () "Initialize the XIM module." (exwm--log) (when exwm-xim--conn (cl-return-from exwm-xim--init)) + (exwm-xim--deadlock-warning) ;; Initialize atoms. (setq exwm-xim--@server (exwm--intern-atom "@server=exwm-xim") exwm-xim--LOCALES (exwm--intern-atom "LOCALES")