Only check input focus for globally active model

* exwm-input.el (exwm-input--set-focus): Partly revert 810b471.
This commit is contained in:
Chris Feng 2016-08-14 12:24:40 +08:00
parent 108b3949c2
commit fe653ba244

View file

@ -61,38 +61,37 @@
(defun exwm-input--set-focus (id) (defun exwm-input--set-focus (id)
"Set input focus to window ID in a proper way." "Set input focus to window ID in a proper way."
(when (exwm--id->buffer id) (when (exwm--id->buffer id)
(let ((focus (slot-value (xcb:+request-unchecked+reply exwm--connection (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)) (make-instance 'xcb:GetInputFocus))
'focus))) 'focus))
(unless (= focus id) (exwm--log "Focus on #x%x with WM_TAKE_FOCUS" id)
(with-current-buffer (exwm--id->buffer id) (exwm-input--update-timestamp
(cond (lambda (timestamp id)
((and (not exwm--hints-input) (let ((event (make-instance 'xcb:icccm:WM_TAKE_FOCUS
(memq xcb:Atom:WM_TAKE_FOCUS exwm--protocols)) :window id
(when (= focus (frame-parameter nil 'exwm-id)) :time timestamp)))
(exwm--log "Focus on #x%x with WM_TAKE_FOCUS" id) (setq event (xcb:marshal event exwm--connection))
(exwm-input--update-timestamp (xcb:+request exwm--connection
(lambda (timestamp id) (make-instance 'xcb:icccm:SendEvent
(let ((event (make-instance 'xcb:icccm:WM_TAKE_FOCUS :destination id
:window id :event event))
:time timestamp))) (exwm-input--set-active-window id)
(setq event (xcb:marshal event exwm--connection)) (xcb:flush exwm--connection)))
(xcb:+request exwm--connection id)))
(make-instance 'xcb:icccm:SendEvent (t
:destination id (exwm--log "Focus on #x%x with SetInputFocus" id)
:event event)) (xcb:+request exwm--connection
(exwm-input--set-active-window id) (make-instance 'xcb:SetInputFocus
(xcb:flush exwm--connection))) :revert-to xcb:InputFocus:Parent
id))) :focus id
(t :time xcb:Time:CurrentTime))
(exwm--log "Focus on #x%x with SetInputFocus" id) (exwm-input--set-active-window id)
(xcb:+request exwm--connection (xcb:flush 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))))))))
(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.