From 5505cff826b361d5d0090a6314891005595e3279 Mon Sep 17 00:00:00 2001 From: Chris Feng Date: Sun, 25 Aug 2019 00:00:00 +0000 Subject: [PATCH] Fix a lock issue with _NET_CLOSE_WINDOW and WM_DELETE_WINDOW * exwm.el (exwm--on-ClientMessage): Calling `kill-buffer' directly from an event context won't work since the DestroyNotify event for a WM_DELETE_WINDOW request won't be handled until the current event context terminates. * exwm-manage.el (exwm-manage--kill-buffer-query-function): Avoid potential side effects with MapWindow. --- exwm-manage.el | 6 ++++-- exwm.el | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/exwm-manage.el b/exwm-manage.el index 797fc15..deb475d 100644 --- a/exwm-manage.el +++ b/exwm-manage.el @@ -513,8 +513,10 @@ manager is shutting down." (catch 'return (when (or (not exwm--id) (xcb:+request-checked+request-check exwm--connection - (make-instance 'xcb:MapWindow - :window exwm--id))) + (make-instance 'xcb:ChangeWindowAttributes + :window exwm--id + :value-mask xcb:CW:EventMask + :event-mask (exwm--get-client-event-mask)))) ;; The X window is no longer alive so just close the buffer. (when exwm--floating-frame (let ((window (frame-parameter exwm--floating-frame 'exwm-outer-id)) diff --git a/exwm.el b/exwm.el index 9ebfabf..8ea4a76 100644 --- a/exwm.el +++ b/exwm.el @@ -420,7 +420,8 @@ (setq type (slot-value obj 'type) id (slot-value obj 'window) data (slot-value (slot-value obj 'data) 'data32)) - (exwm--log "atom=%s(%s)" (x-get-atom-name type exwm-workspace--current) type) + (exwm--log "atom=%s(%s)" (x-get-atom-name type exwm-workspace--current) + type) (cond ;; _NET_NUMBER_OF_DESKTOPS. ((= type xcb:Atom:_NET_NUMBER_OF_DESKTOPS) @@ -459,7 +460,7 @@ ((= type xcb:Atom:_NET_CLOSE_WINDOW) (let ((buffer (exwm--id->buffer id))) (when (buffer-live-p buffer) - (kill-buffer buffer)))) + (exwm--defer 0 #'kill-buffer buffer)))) ;; _NET_WM_MOVERESIZE ((= type xcb:Atom:_NET_WM_MOVERESIZE) (let ((direction (elt data 2))