Fix XTerm crash on startup

* exwm-input.el (exwm-input--set-focus): Applications like XTerm
crashes on receiving WM_TAKE_FOCUS so only send it to X windows
accepting it.
This commit is contained in:
Chris Feng 2018-07-15 00:00:00 +08:00
parent bc5f0b3ffa
commit f45e9b9273

View file

@ -159,26 +159,28 @@ This value should always be overwritten.")
(when (exwm--id->buffer id) (when (exwm--id->buffer id)
(with-current-buffer (exwm--id->buffer id) (with-current-buffer (exwm--id->buffer id)
(exwm-input--update-timestamp (exwm-input--update-timestamp
(lambda (timestamp id send-input-focus) (lambda (timestamp id send-input-focus wm-take-focus)
(when send-input-focus (when send-input-focus
(xcb:+request exwm--connection (xcb:+request exwm--connection
(make-instance 'xcb:SetInputFocus (make-instance 'xcb:SetInputFocus
:revert-to xcb:InputFocus:Parent :revert-to xcb:InputFocus:Parent
:focus id :focus id
:time timestamp))) :time timestamp)))
(let ((event (make-instance 'xcb:icccm:WM_TAKE_FOCUS (when wm-take-focus
:window id (let ((event (make-instance 'xcb:icccm:WM_TAKE_FOCUS
:time timestamp))) :window id
(setq event (xcb:marshal event exwm--connection)) :time timestamp)))
(xcb:+request exwm--connection (setq event (xcb:marshal event exwm--connection))
(make-instance 'xcb:icccm:SendEvent (xcb:+request exwm--connection
:destination id (make-instance 'xcb:icccm:SendEvent
:event event))) :destination id
:event event))))
(exwm-input--set-active-window id) (exwm-input--set-active-window id)
(xcb:flush exwm--connection)) (xcb:flush exwm--connection))
id id
(or exwm--hints-input (or exwm--hints-input
(not (memq xcb:Atom:WM_TAKE_FOCUS exwm--protocols))))))) (not (memq xcb:Atom:WM_TAKE_FOCUS exwm--protocols)))
(memq xcb:Atom:WM_TAKE_FOCUS exwm--protocols)))))
(defun exwm-input--update-timestamp (callback &rest args) (defun exwm-input--update-timestamp (callback &rest args)
"Fetch the latest timestamp from the server and feed it to CALLBACK. "Fetch the latest timestamp from the server and feed it to CALLBACK.