Also send a WM_TAKE_FOCUS when setting focus with SetInputFocus

* exwm-input.el (exwm-input--set-focus): Send an extra WM_TAKE_FOCUS
event to workaround the key replay issue with Xorg 1.20 when keyboard
is grabbed.
This commit is contained in:
Chris Feng 2018-07-15 00:00:00 +08:00
parent 4bb2d87a8d
commit 6be729847e

View file

@ -158,16 +158,14 @@ This value should always be overwritten.")
"Set input focus to window ID in a proper way."
(when (exwm--id->buffer id)
(with-current-buffer (exwm--id->buffer id)
(cond
((and (not exwm--hints-input)
(memq xcb:Atom:WM_TAKE_FOCUS exwm--protocols))
(when (= (frame-parameter nil 'exwm-id)
(slot-value (xcb:+request-unchecked+reply exwm--connection
(make-instance 'xcb:GetInputFocus))
'focus))
(exwm--log "Focus on #x%x with WM_TAKE_FOCUS" id)
(exwm-input--update-timestamp
(lambda (timestamp id)
(lambda (timestamp id send-input-focus)
(when send-input-focus
(xcb:+request exwm--connection
(make-instance 'xcb:SetInputFocus
:revert-to xcb:InputFocus:Parent
:focus id
:time timestamp)))
(let ((event (make-instance 'xcb:icccm:WM_TAKE_FOCUS
:window id
:time timestamp)))
@ -175,19 +173,12 @@ This value should always be overwritten.")
(xcb:+request exwm--connection
(make-instance 'xcb:icccm:SendEvent
:destination id
:event event))
:event event)))
(exwm-input--set-active-window id)
(xcb:flush exwm--connection)))
id)))
(t
(exwm--log "Focus on #x%x with SetInputFocus" id)
(xcb:+request exwm--connection
(make-instance 'xcb:SetInputFocus
:revert-to xcb:InputFocus:Parent
:focus id
:time xcb:Time:CurrentTime))
(exwm-input--set-active-window id)
(xcb:flush exwm--connection))))))
(xcb:flush exwm--connection))
id
(or exwm--hints-input
(not (memq xcb:Atom:WM_TAKE_FOCUS exwm--protocols)))))))
(defun exwm-input--update-timestamp (callback &rest args)
"Fetch the latest timestamp from the server and feed it to CALLBACK.